00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef _UESQL_STRING__
00027 #define _UESQL_STRING__
00028
00029 #include <mpcl/text/string.hh>
00030 #include "type.hh"
00031
00032
00034 namespace uesqlc
00035 {
00036
00038 class TString :
00039 public IType ,
00040 public mpcl::text::TString
00041 {
00042
00043 public:
00044
00046 typedef
00047 mpcl::text::TString::size_type
00048 size_type;
00049
00050
00051 public:
00052
00053
00054
00055
00056
00057 explicit TString (void) :
00058 IType () ,
00059 mpcl::text::TString () {}
00060
00062 TString (const TString& rkySTRING) :
00063 IType () ,
00064 mpcl::text::TString (rkySTRING)
00065 {
00066 setNull (rkySTRING.isNull());
00067 }
00068
00069 TString ( const TString& rkySTRING ,
00070 size_type zOFFSET ,
00071 size_type zLENGTH = npos ) :
00072 IType () ,
00073 mpcl::text::TString (rkySTRING, zOFFSET, zLENGTH)
00074 {
00075 setNull (rkySTRING.isNull());
00076 }
00077
00078 TString (const mpcl::text::TString& rkySOURCE) :
00079 IType () ,
00080 mpcl::text::TString (rkySOURCE)
00081 {
00082 setNull (false);
00083 }
00084
00090 TString (const char* pkcVALUE, size_type zLENGTH) :
00091 IType () ,
00092 mpcl::text::TString ()
00093 {
00094 if ( pkcVALUE )
00095 {
00096 setNull (false);
00097 assign (pkcVALUE, zLENGTH);
00098 }
00099 }
00100
00106 TString (const char* pkcVALUE) :
00107 IType () ,
00108 mpcl::text::TString ()
00109 {
00110 if ( pkcVALUE )
00111 {
00112 setNull (false);
00113 assign (pkcVALUE);
00114 }
00115 }
00116
00117 TString (size_type zTIMES, char cSOURCE) :
00118 IType () ,
00119 mpcl::text::TString (zTIMES, cSOURCE)
00120 {
00121 setNull (false);
00122 }
00123
00124 template<typename InputIterator>
00125 TString (InputIterator tBEGIN_ITER, InputIterator tEND_ITER) :
00126 IType () ,
00127 mpcl::text::TString (tBEGIN_ITER, tEND_ITER)
00128 {
00129 setNull (false);
00130 }
00131
00132 TString& operator = (const TString& rkySTRING)
00133 {
00134 mpcl::text::TString::operator = (rkySTRING);
00135 setNull (rkySTRING.isNull());
00136 return *this;
00137 }
00138
00139 TString& operator = (const mpcl::text::TString& rkySOURCE)
00140 {
00141 mpcl::text::TString::operator = (rkySOURCE);
00142 setNull (false);
00143 return *this;
00144 }
00145
00146 TString& operator = (const char* pkcVALUE)
00147 {
00148 if ( !pkcVALUE )
00149 {
00150 throw mpcl::TConstraintException ("null string", __FILE__, __LINE__);
00151 }
00152 mpcl::text::TString::operator = (pkcVALUE);
00153 setNull (false);
00154 return *this;
00155 }
00156
00157 TString& operator = (char cSOURCE)
00158 {
00159 mpcl::text::TString::operator = (cSOURCE);
00160 setNull (false);
00161 return *this;
00162 }
00163
00170 void set (const char* pkcVALUE)
00171 {
00172 if ( !pkcVALUE )
00173 {
00174 erase();
00175 setNull (true);
00176 }
00177 else
00178 {
00179 assign (pkcVALUE);
00180 setNull (false);
00181 }
00182 }
00183
00188 void set (const std::string& rkyVALUE)
00189 {
00190 assign (rkyVALUE);
00191 setNull (false);
00192 }
00193
00194
00195 public:
00196
00197
00198
00199
00200
00205 mpcl::text::TString get (void) const
00206 {
00207
00208 mpcl::text::TString yResult;
00209 mpcl::text::TString yEscaped (*this);
00210
00211 if ( isNull() )
00212 {
00213 yResult = "null";
00214 }
00215 else
00216 {
00217 yEscaped.replaceAll ("'", "''");
00218 yEscaped.replaceAll ("\\", "\\\\");
00219 yResult = '\'';
00220 yResult.append (yEscaped);
00221 yResult.append (1, '\'');
00222 }
00223 return yResult;
00224
00225 }
00226
00227 };
00228
00229 }
00230
00231
00232 #endif // not _UESQL_STRING__