home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c100 / 2.ddi / GCOBJECT.ZIP / GCSTRING.HPP < prev    next >
Encoding:
C/C++ Source or Header  |  1990-07-09  |  1.9 KB  |  49 lines

  1. /**************************************************************************
  2. These C++ classes are copyright 1989, 1990, by William Herrera.
  3. All those who put this code or its derivatives in a commercial product MUST
  4. mention this copyright in their documentation for users of the products in
  5. which this code or its derivative classes are used.  Otherwise, this code
  6. may be freely distributed and freely used for any purpose.
  7. contacts:
  8. GENIE
  9. FidoNet: c_plusplus
  10. **************************************************************************/
  11. // file gcstring.hpp
  12. // this class demonstrates the use of the gcobject base class
  13. // to implement a fast executing string class.
  14.  
  15. #ifndef GCSTRING_HPP
  16. #define GCSTRING_HPP 1
  17.  
  18. #include "gcobject.hpp"
  19.  
  20. class gcstring : public gcobject
  21. {
  22.     data_record ** str;      // pointer to data record in gcobject memory.
  23. protected:
  24.     char * GetPtr() { return (char *)((*str)->data); }
  25.     gcstring(const char * p1, const char * p2);
  26. public:
  27.     static void Initialize(unsigned int bufsize=5000, int gc_interval=12000);
  28.     gcstring();   // gcstring s; default constructor
  29.     gcstring(const char *);   // gcstring s("Hello");
  30.     gcstring(const gcstring &);     // copy-initializer
  31.     ~gcstring();          // destructor
  32.     gcstring operator =(const gcstring &); // gcstring s = gcstring st;
  33.     gcstring operator =(const char *); // gcstring s = char * s;
  34.     int operator [](const int i); // reference a char in string.
  35.     gcstring operator +(const gcstring & st);
  36.     char * strdup() { return ::strdup(GetPtr()); }    // allocates on heap.
  37.     int cmp(const gcstring & s);
  38.     int cmp(char * p);
  39.     friend istream & operator >>(istream & ist, gcstring & s);
  40.     friend ostream & operator <<(ostream & ost, const gcstring & s);
  41. };
  42.  
  43. istream & operator >>(istream & ist, gcstring & s);
  44. ostream & operator <<(ostream & ost, const gcstring & s);
  45.  
  46. #endif
  47.  
  48. // end of file gcstring.hpp
  49.