home *** CD-ROM | disk | FTP | other *** search
/ Graphics 16,000 / graphics-16000.iso / msdos / utils / graphtal.lzh / Graphtal.Amiga / rcString.h < prev    next >
C/C++ Source or Header  |  1992-11-17  |  2KB  |  80 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.  *                     University of Berne, Switzerland
  8.  * All rights reserved.
  9.  *
  10.  * This software may be freely copied, modified, and redistributed
  11.  * provided that this copyright notice is preserved on all copies.
  12.  *
  13.  * You may not distribute this software, in whole or in part, as part of
  14.  * any commercial product without the express consent of the authors.
  15.  *
  16.  * There is no warranty or other guarantee of fitness of this software
  17.  * for any purpose.  It is provided solely "as is".
  18.  *
  19.  */
  20.  
  21. #ifndef rcString_H
  22. #define  rcString_H
  23.  
  24. #include <string.h>
  25.  
  26. //___________________________________________________________ rcString
  27. // rcString - a reference counted String class
  28.  
  29. typedef char* _Char_p_;
  30. class rcStringRep;
  31. class ostream;
  32.  
  33. class rcString
  34. {
  35. public:
  36.   rcString();
  37.   rcString(char);
  38.   rcString(const char*);
  39.   rcString(const rcString&);
  40.   ~rcString();
  41.  
  42.   char& operator[](unsigned);
  43.   char  operator[](unsigned) const;
  44.  
  45.   rcString operator()(unsigned, unsigned);
  46.  
  47.   const rcString& operator=(char);
  48.   const rcString& operator=(const char*);
  49.   const rcString& operator=(const rcString&);
  50.  
  51.   int operator==(const rcString&) const;
  52.   int operator==(const char*) const;
  53.   int operator!=(const rcString&) const;
  54.   int operator!=(const char*) const;
  55.   int operator< (const rcString&) const;
  56.   int operator<=(const rcString&) const;
  57.   int operator> (const rcString&) const;
  58.   int operator>=(const rcString&) const;
  59.   
  60.   const char* chars() const;
  61.   operator const char*() const;
  62.  
  63.   unsigned length() const;
  64.   int empty() const;
  65.  
  66.   friend rcString operator+(const rcString&, const char*);
  67.   friend rcString operator+(const char*, const rcString&);
  68.   friend rcString operator+(const rcString&, const rcString&);
  69.  
  70.   friend ostream& operator<<(ostream&, const rcString&);
  71.  
  72. private:
  73.   rcString(_Char_p_ *r);
  74.  
  75. private:
  76.   rcStringRep *rep;
  77. };
  78.  
  79. #endif  // rcString_H 
  80.