00001 #ifndef _CDBSTRING_H 00002 #define _CDBSTRING_H 1 00003 00004 #include "cdbcharactervector.h" 00005 00006 #ifdef SUPPORT_STL 00007 #include <iostream> 00008 #ifdef SUPPORT_NATIVE 00009 #include <string> 00010 #endif 00011 #endif 00012 00013 #ifdef SUPPORT_ICU 00014 #include "unicode/unistr.h" 00015 #endif 00016 00029 class CDBstring : public CDBcharacterVector { 00030 public: 00032 typedef CDBcharacterIterator iterator; 00034 typedef const CDBcharacterIterator const_iterator; 00035 00037 CDBstring( const Mchar *p = 0 ); 00039 CDBstring( const CDBstring &ref ); 00040 00041 inline CDBstring &operator=(const CDBstring &ref) { 00042 assign(ref.m_Data, ref.m_DataLen); 00043 return *this; 00044 } 00045 CDBstring operator+(const CDBstring &ref) const; 00046 CDBstring &operator+=(const CDBstring &ref); 00047 CDBstring operator+(const Mchar &c) const; 00048 CDBstring &operator+=(const Mchar &c); 00049 00050 bool operator==(const CDBstring &s1); 00051 bool operator!=(const CDBstring &s1); 00052 00062 CDBstring substr(const iterator &istart, const iterator &iend) const; 00063 00074 CDBstring substr(int istart, int ifor) const; 00075 00077 Mchar &at(size_t pos); 00079 Mchar at(size_t pos) const; 00080 00081 inline Mchar &operator[](size_t pos) { 00082 return at(pos); 00083 } 00084 00085 inline Mchar operator[](size_t pos) const { 00086 return at(pos); 00087 } 00088 00089 const Mchar *strstr(const CDBstring &search); 00090 00098 const Mchar *c_str() const; 00099 00100 #if !defined(USE_NATIVE) && defined(SUPPORT_NATIVE) 00101 CDBstring( const char *sup ); 00102 #endif 00103 #if !defined(USE_WCHAR) && defined(SUPPORT_WCHAR) 00104 CDBstring( const wchar_t *sup ); 00105 #endif 00106 #if !defined(USE_ICU) && defined(SUPPORT_ICU) 00107 CDBstring( const UChar *sup ); 00108 #endif 00109 00110 #ifdef SUPPORT_NATIVE 00111 int toAscii(char *dst, int dst_size) const; 00112 #endif 00113 00114 #ifdef SUPPORT_WCHAR 00115 int toWchar(wchar_t *dst, int dst_size) const; 00116 #endif 00117 00118 #ifdef SUPPORT_ICU 00119 int toIcu(UChar *dst, int dst_size) const; 00120 #endif 00121 00122 #ifdef SUPPORT_STL 00123 00124 #ifdef SUPPORT_NATIVE 00125 CDBstring(const std::string &stl); 00126 operator std::string(); 00127 #endif 00128 00129 #ifdef SUPPORT_WCHAR 00130 CDBstring(const std::wstring &stl); 00131 operator std::wstring(); 00132 #endif 00133 00134 #endif 00135 00136 #ifdef SUPPORT_ICU 00137 CDBstring(const UnicodeString &ic); 00138 operator UnicodeString(); 00139 #endif 00140 00141 int toUtf8(char *dst, int dst_size) const; 00142 int fromUtf8(const char *src); 00143 00144 void optimize(); 00145 }; 00146 00147 #ifdef SUPPORT_STL 00148 00155 std::ostream& operator << (std::ostream& os, const CDBstring &s); 00156 #endif 00157 00158 #endif