Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __CDC_STRING
00023 #define __CDC_STRING
00024
00025 #include "Interfaces/BufferHolder.h"
00026 #include <string>
00027 using namespace std;
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 class CdcString : public string
00041 {
00042 public:
00043
00044
00045 CdcString ()
00046 :string () {}
00047 CdcString (char ch)
00048 :string (1, ch) {}
00049 CdcString (const char* str)
00050 :string (str) {}
00051 CdcString (char* str)
00052 :string (str) {}
00053 CdcString (const char* str, int len)
00054 :string (str, len) {}
00055 CdcString (char* str, int len)
00056 :string (str, len) {}
00057 CdcString (const string& str)
00058 :string (str) {}
00059 CdcString (const CdcString& str)
00060 :string (str.GetBuffer ()) {}
00061 CdcString (BufferHolder bh)
00062 { if (!bh.empty ()) *this = string (bh.pointer, bh.size); }
00063
00064
00065 int GetLength () const
00066 { return length (); }
00067
00068
00069 bool IsEmpty () const
00070 { return empty (); }
00071
00072
00073 int Compare (const CdcString& str) const
00074 { return compare (str); }
00075
00076
00077 int CompareNoCase (const CdcString& str) const;
00078
00079
00080 int CompareEnd (const CdcString& str) const;
00081
00082
00083
00084
00085 CdcString Mid (int first, int count = CdcString::npos) const
00086 { return CdcString (substr (first, count)); }
00087
00088
00089 CdcString Left (int count) const
00090 { return CdcString (substr (0, count)); }
00091
00092
00093 CdcString Right (int count) const
00094 { return CdcString (substr (GetLength () - count)); }
00095
00096
00097 void MakeUpper ();
00098
00099
00100 void MakeLower ();
00101
00102
00103
00104
00105
00106
00107 void Replace (const CdcString& strOld, const CdcString& strNew);
00108
00109
00110 void TrimLeft ();
00111
00112
00113 void TrimRight ();
00114
00115
00116 CdcString& Trim ()
00117 { TrimLeft (); TrimRight (); return *this;}
00118
00119
00120
00121 int Find (const CdcString& str, int start = 0) const
00122 { return find (str, start); }
00123 int Find (const char* str, int start = 0) const
00124 { return find (str, start); }
00125 int Find (char c, int start = 0) const
00126 { return find (c, start); }
00127
00128 int ReverseFind (const CdcString& str, int start = -1) const
00129 { start = start == -1 ? length () -1 : start;
00130 return rfind (str, start); }
00131 int ReverseFind (const char* str, int start = -1) const
00132 { start = start == -1 ? length () -1 : start;
00133 return rfind (str, start); }
00134 int ReverseFind (char c, int start = -1) const
00135 { start = start == -1 ? length () -1 : start;
00136 return rfind (c, start); }
00137
00138
00139 int FindOneOf (const CdcString& charSet, int start = 0) const
00140 { return find_first_of (charSet, start); }
00141
00142
00143 const char* GetBuffer () const
00144 { return c_str (); }
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154 CdcString SpanIncluding (const CdcString& charSet) const;
00155
00156 operator const char*() const
00157 { return this->GetBuffer (); }
00158
00159 char operator [] (int place) const
00160 { return at (place); }
00161
00162 char& operator [] (int place)
00163 { return at (place); }
00164
00165 static CdcString IntToString (int num, const char* format = "%d");
00166 };
00167
00168 #endif
00169