home *** CD-ROM | disk | FTP | other *** search
- /**************************************************************************
- These C++ classes are copyright 1989, 1990, by William Herrera.
- All those who put this code or its derivatives in a commercial product MUST
- mention this copyright in their documentation for users of the products in
- which this code or its derivative classes are used. Otherwise, this code
- may be freely distributed and freely used for any purpose.
- contacts:
- GENIE
- FidoNet: c_plusplus
- **************************************************************************/
- // file gcstring.hpp
- // this class demonstrates the use of the gcobject base class
- // to implement a fast executing string class.
-
- #ifndef GCSTRING_HPP
- #define GCSTRING_HPP 1
-
- #include "gcobject.hpp"
-
- class gcstring : public gcobject
- {
- data_record ** str; // pointer to data record in gcobject memory.
- protected:
- char * GetPtr() { return (char *)((*str)->data); }
- gcstring(const char * p1, const char * p2);
- public:
- static void Initialize(unsigned int bufsize=5000, int gc_interval=12000);
- gcstring(); // gcstring s; default constructor
- gcstring(const char *); // gcstring s("Hello");
- gcstring(const gcstring &); // copy-initializer
- ~gcstring(); // destructor
- gcstring operator =(const gcstring &); // gcstring s = gcstring st;
- gcstring operator =(const char *); // gcstring s = char * s;
- int operator [](const int i); // reference a char in string.
- gcstring operator +(const gcstring & st);
- char * strdup() { return ::strdup(GetPtr()); } // allocates on heap.
- int cmp(const gcstring & s);
- int cmp(char * p);
- friend istream & operator >>(istream & ist, gcstring & s);
- friend ostream & operator <<(ostream & ost, const gcstring & s);
- };
-
- istream & operator >>(istream & ist, gcstring & s);
- ostream & operator <<(ostream & ost, const gcstring & s);
-
- #endif
-
- // end of file gcstring.hpp
-