Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

cmt_string.h

Go to the documentation of this file.
00001 #ifndef __cmt_string_h__
00002 #define __cmt_string_h__
00003 
00004 #include <stdio.h>
00005 #include <string.h>
00006 
00007 class cmt_string
00008 {
00009 public:
00010   typedef enum
00011     {
00012       npos = -1
00013     } pos_type;
00014 
00015     //
00016     // Constructors
00017     //
00018   cmt_string ();
00019   cmt_string (int n);
00020   cmt_string (char c);
00021   cmt_string (const char* text);
00022   cmt_string (const cmt_string& other);
00023   ~cmt_string ();
00024 
00025     //
00026     // Operators
00027     //
00028   cmt_string& operator = (char c);
00029   cmt_string& operator = (const char* text);
00030   cmt_string& operator = (const cmt_string& other);
00031 
00032   bool read (const cmt_string& file_name);
00033   bool write (const cmt_string& file_name) const;
00034   void write (FILE* f) const;
00035   void write (ostream& output);
00036 
00037   operator const char* () const;
00038 
00039   const char* c_str () const;
00040   /*char* c_str (); */
00041 
00042   void operator += (char c);
00043   void operator += (const char* text);
00044   void operator += (const cmt_string& other);
00045 
00046   cmt_string operator + (char c) const;
00047   cmt_string operator + (const char* text) const;
00048   cmt_string operator + (const cmt_string& other) const;
00049 
00050   char operator [] (int index) const;
00051   char& operator [] (int index);
00052 
00053   int size () const;
00054   int size ();
00055   void resize (int n);
00056 
00057   int find (char c) const;
00058   int find (const char* text) const;
00059   int find (const cmt_string& other) const;
00060   int find (int pos, char c) const;
00061   int find (int pos, const char* text) const;
00062   int find (int pos, const cmt_string& other) const;
00063 
00064   int find_last_of (char c) const;
00065   int find_last_of (const char* text) const;
00066   int find_last_of (const cmt_string& other) const;
00067 
00068   void erase (int pos);
00069   void erase (int pos, int length);
00070 
00071   void replace (const char* pattern, const char* replacement);
00072   void replace (const cmt_string& pattern, const cmt_string& replacement);
00073 
00074   void replace_all (const char* pattern, const char* replacement);
00075   void replace_all (const cmt_string& pattern, const cmt_string& replacement);
00076 
00077   void trim ();
00078 
00079   cmt_string substr (int pos) const;
00080   cmt_string substr (int pos, int length) const;
00081 
00082   void substr (int pos, cmt_string& dest) const;
00083   void substr (int pos, int length, cmt_string& dest) const;
00084 
00085   bool operator < (const char* text) const;
00086   bool operator < (const cmt_string& other) const;
00087 
00088   bool operator == (const char* text) const;
00089   bool operator == (const cmt_string& other) const;
00090 
00091   bool compare_no_case (const char* text) const;
00092   bool compare_no_case (const cmt_string& other) const;
00093 
00094   bool operator != (const char* text) const;
00095   bool operator != (const cmt_string& other) const;
00096 
00097   bool operator > (const char* text) const;
00098   bool operator > (const cmt_string& other) const;
00099 
00100 private:
00101   void extend (int n);
00102   void allocate (int n);
00103 
00104   char* _data;
00105   int _allocated;
00106   int _size;
00107 };
00108 
00109 ostream& operator << (ostream& o, const cmt_string& s);
00110 cmt_string operator + (const char* text, const cmt_string& s);
00111 cmt_string operator + (char c, const cmt_string& s);
00112 
00113 #endif

Generated at Thu Apr 11 16:49:42 2002 for CMT by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000