home *** CD-ROM | disk | FTP | other *** search
/ Photo CD Demo 1 / Demo.bin / graphtal / rcstring.h < prev    next >
C/C++ Source or Header  |  1992-10-19  |  2KB  |  79 lines

  1. /*
  2.  * rcString.h - class definition for reference counted string
  3.  *              manipulations.
  4.  *
  5.  * Copyright (C) 1992, Christoph Streit (streit@iam.unibe.ch)
  6.  *                     Igor Metz (metz@iam.unibe.ch)
  7.  * All rights reserved.
  8.  *
  9.  * This software may be freely copied, modified, and redistributed
  10.  * provided that this copyright notice is preserved on all copies.
  11.  *
  12.  * You may not distribute this software, in whole or in part, as part of
  13.  * any commercial product without the express consent of the authors.
  14.  *
  15.  * There is no warranty or other guarantee of fitness of this software
  16.  * for any purpose.  It is provided solely "as is".
  17.  *
  18.  */
  19.  
  20. #ifndef rcString_H
  21. #define  rcString_H
  22.  
  23. #include <string.h>
  24.  
  25. //___________________________________________________________ rcString
  26. // rcString - a reference counted String class
  27.  
  28. typedef char* _Char_p_;
  29. class rcStringRep;
  30. class ostream;
  31.  
  32. class rcString
  33. {
  34. public:
  35.   rcString();
  36.   rcString(char);
  37.   rcString(const char*);
  38.   rcString(const rcString&);
  39.   ~rcString();
  40.  
  41.   char& operator[](unsigned);
  42.   char  operator[](unsigned) const;
  43.  
  44.   rcString operator()(unsigned, unsigned);
  45.  
  46.   const rcString& operator=(char);
  47.   const rcString& operator=(const char*);
  48.   const rcString& operator=(const rcString&);
  49.  
  50.   int operator==(const rcString&) const;
  51.   int operator==(const char*) const;
  52.   int operator!=(const rcString&) const;
  53.   int operator!=(const char*) const;
  54.   int operator< (const rcString&) const;
  55.   int operator<=(const rcString&) const;
  56.   int operator> (const rcString&) const;
  57.   int operator>=(const rcString&) const;
  58.   
  59.   const char* chars() const;
  60.   operator const char*() const;
  61.  
  62.   unsigned length() const;
  63.   int empty() const;
  64.  
  65.   friend rcString operator+(const rcString&, const char*);
  66.   friend rcString operator+(const char*, const rcString&);
  67.   friend rcString operator+(const rcString&, const rcString&);
  68.  
  69.   friend ostream& operator<<(ostream&, const rcString&);
  70.  
  71. private:
  72.   rcString(_Char_p_ *r);
  73.  
  74. private:
  75.   rcStringRep *rep;
  76. };
  77.  
  78. #endif  // rcString_H 
  79.