home *** CD-ROM | disk | FTP | other *** search
- #ifndef _STRING_HH
- #define _STRING_HH
-
- /* %Z%%I% %G% %U% %W% */
- /*
- * COMPONENT_NAME: (COMINC) Common Header File for RTTI
- *
- * ORIGINS: 27
- *
- * (C) COPYRIGHT International Business Machines Corp. 1992
- * This work was supported by a grant from International Business
- * Machines, Inc. These procedures are contributed to the public domain
- * by International Business Machines Inc. "AS IS" without any warranty
- * of any kind including the warranty of merchantability or fitness
- * for a particular purpose.
- *
- * This is free software. Feel free to redistribute and/or modify it.
- * Please send us e-mail and let us know if you have any problems
- * or suggestions.
- *
- * Arindam Banerji
- * axb@cse.nd.edu
- *
- */
-
- #ifndef _KERNEL
- #include <iostream.h>
- #endif // !_KERNEL
- #include <string.h>
- // String.hh
- // This defines the string class .
-
- const int INPUTBUFSIZE = 512 ;
-
- class string
- {
- private :
- struct srep {
- char *s ; // pointer to data
- int n ; // reference count
- srep() { n = 1 ; }
- } ; // the internal representation format
- srep *p ; // the actual repreesntation
-
- public :
- string ( const char *) ;
- string() ;
- string ( const string &) ;
- string& operator= ( const char *) ;
- string& operator= (const string &) ;
- ~string () ;
- char& operator[] (int i ) ;
- operator char *() ;
- #ifndef _KERNEL
- friend ostream& operator << (ostream &, const string &) ;
- friend istream& operator >> (istream &, string &) ;
- #endif // ! _KERNEL
- void display(void) ;
-
- friend int operator== ( const string &x, const char *s)
- { return strcmp(x.p->s, s) == 0 ; }
-
- friend int operator== ( const string &x, const string &y)
- { return strcmp(x.p->s, y.p->s) == 0 ; }
-
- friend int operator!= (const string &x, const char *s)
- { return strcmp(x.p->s, s) != 0 ; }
-
- friend int operator!= (const string &x, const string &y)
- { return strcmp(x.p->s, y.p->s) != 0 ; }
- } ;
-
- #endif // _STRING_HH
-