Personal tools
You are here: Home Projects C++ Cfront releases Release 3.0.3 source demo lang String.h
Document Actions

String.h

by Michael L Powell last modified 2007-01-26 03:20

Click here to get the file

Size 1.7 kB - File type text/plain

File contents

/*ident	"@(#)cls4:demo/lang/String.h	1.1" */
/*#########################################################################
#                       Copyright (c) 1991 AT&T
#                         All Rights Reserved   
#
#                THIS IS PROPRIETARY SOURCE CODE OF AT&T
#       
#                     This code has been published in
#                         C++ Primer, 2nd Edition 
#			    by Stanley Lippman
#                    Addison_Wesley Publishing Company
#
#########################################################################*/
#ifndef STRING_H
#define STRING_H

#include <iostream.h>
#include <string.h>

class String;
class StringIterator {
public:
	StringIterator(String& s) { ps = &s; index = 0; }
	char operator()();
private:
	String *ps;
	int index;
};

const int String_size = 1024; // arbitrary constant

class String {
    friend ostream& operator <<(ostream&,String&);
    friend istream& operator >>(istream&,String&);
    friend String operator+(String&,String&);
    friend class StringIterator;
public:
    String(int);
    String(char*);
    String(const String&);
    String();
    ~String() { delete str; }

    String& operator()(int,int);
    char& operator[](int);
    String& operator=(const char*);
    String& operator=(const String&);
    String& operator+=(const String&);
    int operator==(const String &s); 

    int operator==(const char *s) { return (strcmp(str,s)==0); }
    int operator!() { return( len == 0 ); } 
    void print() { cout<< "< " << len << ", " << str << " >\n";}
    inline void checkBounds(int);
    int getLen() { return len; }
    int operator <(String& s);
    int operator >(String& s);
    void set(char*);
private:
    int len;
    char *str;
};

#endif
« December 2014 »
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
 

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: