home *** CD-ROM | disk | FTP | other *** search
/ Informática Multimedia: Special Games / INFESPGAMES.mdf / os2 / ribble / support / cstrng.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-09  |  2.0 KB  |  81 lines

  1. // -------------------------------
  2. //  Name:           CString.h
  3. //  Author:         J.R.Shannon
  4. //  Language:       C++
  5. //  Date:           6/11/92
  6. //  Revison:        2.1
  7. //  Last revision:  9/7/93
  8. //  Licence:        Public Domain
  9. //  Purpose:        String handling package
  10. // -------------------------------
  11. //
  12.  
  13. #include <CSupport.h>
  14. #include <CAssert.h>
  15.  
  16. #ifndef _CString_h
  17. #define _CString_h
  18.  
  19. #include <string.h>
  20. #include <sys/types.h>
  21.  
  22. //
  23. // INTERFACE
  24. //
  25.  
  26. class CSExport CString
  27. {
  28. public:
  29.   CString();
  30.   CString(const CString&);
  31.   CString(const char*);
  32.   CString(const char);
  33.   CString(const unsigned int);
  34.   ~CString();
  35.  
  36.   CString& operator=(const CString&);
  37.   CString& operator=(const char*);
  38.   CString& operator=(const char);
  39.   CString& operator+=(const CString&);
  40.   CString& operator+=(const char*);
  41.   CString& operator+=(const char);
  42.   CString  operator+(const CString&) const;
  43.   int operator==(const CString&) const;
  44.   int operator!=(const CString&) const;
  45.   int operator<=(const CString&) const;
  46.   int operator>=(const CString&) const;
  47.   int operator<(const CString&) const;
  48.   int operator>(const CString&) const;
  49.   int operator==(const char*) const;
  50.   int operator!=(const char*) const;
  51.   int operator<=(const char*) const;
  52.   int operator>=(const char*) const;
  53.   int operator<(const char*) const;
  54.   int operator>(const char*) const;
  55.   const char& operator[](size_t index);
  56.  
  57.   void Resync(void) { length = strlen(data); }
  58.   operator char*() const;   // Get a pointer to a char* representation of the CString
  59.   size_t len() const;
  60.  
  61.   char* index(const int);   // strchr and strrchr facilities
  62.   char* rindex(const int);
  63.  
  64.   void makeUpper(void);     // conver to upper case
  65.   void makeLower(void);     //           lower
  66.   void stripTrailing(char _ch);
  67.  
  68. private:
  69.   char*               data;
  70.   size_t              length;
  71.   size_t              chunk;
  72.  
  73.   enum { chunk_size = 16 };
  74.  
  75.   size_t  chunkRound(size_t) const;
  76. };
  77.  
  78.  
  79. #endif
  80.  
  81.