#include <SqlStringBuffer.h>
Public Member Functions | |
SqlStringBufferUCS2 (SqlStringBuffer const &src) | |
SqlStringBufferUCS2 (SqlStringBuffer const &src, int leftBumper, int rightBumper) | |
void | init () |
bool | verify () |
void | randomize (uint start= 'A', uint lower= ' ', uint upper= '~') |
void | patternfill (uint start= 'A', uint lower= ' ', uint upper= '~') |
string | dump () |
bool | equal (SqlStringBufferUCS2 const &other) |
Public Attributes | |
char * | mStr |
char * | mStrPostPad |
char * | mRightP |
char * | mLeftP |
const int | mStorage |
const int | mSize |
const int | mLeftPad |
const int | mRightPad |
const int | mLeftBump |
const int | mRightBump |
const int | mTotal |
string | mS |
Static Public Attributes | |
static const uint | mBumperChar |
static const int | mBumperLen |
Definition at line 85 of file SqlStringBuffer.h.
SqlStringBufferUCS2::SqlStringBufferUCS2 | ( | SqlStringBuffer const & | src | ) | [explicit] |
Definition at line 128 of file SqlStringBuffer.cpp.
References init(), mBumperChar, mS, SqlStringBuffer::mStorage, mStr, SqlStringBuffer::mStr, and mTotal.
00129 : mStorage(src.mStorage *2), 00130 mSize(src.mSize * 2), 00131 mLeftPad(src.mLeftPad * 2), 00132 mRightPad(src.mRightPad * 2), 00133 // force alignment when copying from potentially unaligned 00134 mLeftBump(src.mLeftBump & 1 ? src.mLeftBump + 1 : src.mLeftBump), 00135 mRightBump(src.mRightBump & 1 ? src.mRightBump + 1 : src.mRightBump), 00136 mTotal(src.mStorage * 2 + mLeftBump + mRightBump) 00137 { 00138 mS.assign(mTotal, mBumperChar); 00139 00140 init(); 00141 00142 char *srcP = src.mStr; 00143 char *dstP = mStr; 00144 int i = src.mStorage; 00145 while (i > 0) { 00146 #ifdef LITTLEENDIAN 00147 *(dstP++) = *(srcP++); 00148 *(dstP++) = 0x00; 00149 #else 00150 *(dstP++) = 0x00; 00151 *(dstP++) = *(srcP++); 00152 #endif 00153 i--; 00154 } 00155 }
SqlStringBufferUCS2::SqlStringBufferUCS2 | ( | SqlStringBuffer const & | src, | |
int | leftBumper, | |||
int | rightBumper | |||
) | [explicit] |
Definition at line 157 of file SqlStringBuffer.cpp.
References init(), mBumperChar, mLeftBump, mRightBump, mS, SqlStringBuffer::mStorage, mStr, SqlStringBuffer::mStr, and mTotal.
00161 : mStorage(src.mStorage *2), 00162 mSize(src.mSize * 2), 00163 mLeftPad(src.mLeftPad * 2), 00164 mRightPad(src.mRightPad * 2), 00165 mLeftBump(leftBumper), 00166 mRightBump(rightBumper), 00167 mTotal(src.mStorage * 2 + leftBumper + rightBumper) 00168 { 00169 // force alignment 00170 assert(!(mLeftBump & 1)); 00171 assert(!(mRightBump & 1)); 00172 00173 mS.assign(mTotal, mBumperChar); 00174 00175 init(); 00176 00177 char *srcP = src.mStr; 00178 char *dstP = mStr; 00179 int i = src.mStorage; 00180 while (i > 0) { 00181 #ifdef LITTLEENDIAN 00182 *(dstP++) = *(srcP++); 00183 *(dstP++) = 0x00; 00184 #else 00185 *(dstP++) = 0x00; 00186 *(dstP++) = *(srcP++); 00187 #endif 00188 i--; 00189 } 00190 }
void SqlStringBufferUCS2::init | ( | ) |
Definition at line 194 of file SqlStringBuffer.cpp.
References mLeftBump, mLeftP, mLeftPad, mRightBump, mRightP, mRightPad, mS, mSize, mStorage, mStr, and mStrPostPad.
Referenced by SqlStringBufferUCS2().
00195 { 00196 assert(mLeftBump > 0); 00197 assert(mRightBump > 0); 00198 assert(mStorage == mSize + mLeftPad + mRightPad); 00199 00200 mLeftP = const_cast<char *>(mS.c_str()); // Too abusive of string()? 00201 mStr = mLeftP + mLeftBump; 00202 mStrPostPad = mStr + mLeftPad; 00203 mRightP = mStr + mStorage; 00204 }
bool SqlStringBufferUCS2::verify | ( | ) |
Definition at line 208 of file SqlStringBuffer.cpp.
References mBumperChar, mLeftBump, mLeftPad, mRightBump, mRightPad, mS, mSize, and mTotal.
Referenced by SqlStringTest::testSqlStringAlterCase_UCS2(), SqlStringTest::testSqlStringBuffer_UCS2(), SqlStringTest::testSqlStringCpy_Fix(), SqlStringTest::testSqlStringCpy_Var(), and SqlStringTest::testSqlStringTrim_Helper().
00209 { 00210 string verS(mTotal, mBumperChar); 00211 if (mS.compare(0, mLeftBump, verS, 0, mLeftBump)) { 00212 return false; 00213 } 00214 if (mS.compare( 00215 mLeftBump + mLeftPad + mSize + mRightPad, 00216 mRightBump, verS, 0, mRightBump)) 00217 { 00218 return false; 00219 } 00220 return true; 00221 }
Definition at line 224 of file SqlStringBuffer.cpp.
References mSize, mStrPostPad, and patternfill().
Referenced by SqlStringTest::testSqlStringBuffer_UCS2().
00228 { 00229 patternfill(start, lower, upper); 00230 00231 vector <uint16_t> r; 00232 uint16_t tmp; 00233 int i = 0; 00234 while (i < mSize) { 00235 #ifdef LITTLEENDIAN 00236 tmp = mStrPostPad[i + 1] << 8 | mStrPostPad[i]; 00237 #else 00238 tmp = mStrPostPad[i] << 8 | mStrPostPad[i + 1]; 00239 #endif 00240 r.push_back(tmp); 00241 i += 2; 00242 } 00243 00244 00245 random_shuffle(r.begin(), r.end()); 00246 i = 0; 00247 vector<uint16_t>::iterator iter = r.begin(); 00248 while (i < mSize) { 00249 tmp = *(iter++); 00250 #ifdef LITTLEENDIAN 00251 mStrPostPad[i++] = tmp & 0xff; 00252 mStrPostPad[i++] = (tmp >> 8) & 0xff; 00253 #else 00254 mStrPostPad[i++] = (tmp >> 8) & 0xff; 00255 mStrPostPad[i++] = tmp & 0xff; 00256 #endif 00257 } 00258 }
Definition at line 261 of file SqlStringBuffer.cpp.
References mSize, and mStrPostPad.
Referenced by randomize().
00265 { 00266 uint c = start; 00267 int i = 0; 00268 00269 while (i < mSize) { 00270 #ifdef LITTLEENDIAN 00271 mStrPostPad[i++] = c & 0xff; 00272 mStrPostPad[i++] = (c >> 8) & 0xff; 00273 #else 00274 mStrPostPad[i++] = (c >> 8) & 0xff; 00275 mStrPostPad[i++] = c & 0xff; 00276 #endif 00277 if (++c > upper) { 00278 c = lower; 00279 } 00280 } 00281 }
string SqlStringBufferUCS2::dump | ( | ) |
Definition at line 284 of file SqlStringBuffer.cpp.
References mLeftBump, mLeftP, mRightBump, mSize, mStorage, mStr, and mTotal.
Referenced by SqlStringTest::testSqlStringAlterCase_UCS2().
00285 { 00286 int i = 0; 00287 string ret; 00288 char buf[100]; 00289 00290 sprintf( 00291 buf, "DUMP: Storage=%d LeftBump=%d Size=%d RightBump=%d LP=%p Str=%p\n", 00292 mStorage, mLeftBump, mSize, mRightBump, 00293 mLeftP, mStr); 00294 ret += buf; 00295 00296 i = 0; 00297 while (i < mTotal) { 00298 sprintf( 00299 buf, 00300 " %d:%x(%c)", 00301 i, 00302 mLeftP[i], 00303 (mLeftP[i] >= ' ' ? mLeftP[i] : '_')); 00304 ret += buf; 00305 i++; 00306 } 00307 00308 ret += "\nLeft Bumper:\n"; 00309 i = 0; 00310 while (i < mLeftBump) { 00311 sprintf(buf, "%d: 0x%x (%c)\n", i, mLeftP[i], mLeftP[i]); 00312 ret += buf; 00313 i++; 00314 } 00315 00316 ret += "\nText:\n"; 00317 i = 0; 00318 while (i < mStorage) { 00319 sprintf( 00320 buf, "%d: 0x%x (%c) 0x%x (%c)\n", i, 00321 mStr[i], (mStr[i] >= ' ' ? mStr[i] : '_'), 00322 mStr[i + 1], (mStr[i + 1] >= ' ' ? mStr[i + 1] : '_')); 00323 ret += buf; 00324 i += 2; 00325 } 00326 00327 ret += "\nRight Bumper:\n"; 00328 i = 0; 00329 while (i < mRightBump) { 00330 sprintf( 00331 buf, "%d: 0x%x (%c)\n", i, mStr[i + mStorage], mStr[i + mStorage]); 00332 ret += buf; 00333 i++; 00334 } 00335 00336 return ret; 00337 }
bool SqlStringBufferUCS2::equal | ( | SqlStringBufferUCS2 const & | other | ) |
const uint SqlStringBufferUCS2::mBumperChar [static] |
const int SqlStringBufferUCS2::mBumperLen [static] |
Definition at line 89 of file SqlStringBuffer.h.
Definition at line 115 of file SqlStringBuffer.h.
Referenced by dump(), init(), SqlStringBufferUCS2(), SqlStringTest::testSqlStringAlterCase_UCS2(), SqlStringTest::testSqlStringBuffer_UCS2(), SqlStringTest::testSqlStringCpy_Fix(), SqlStringTest::testSqlStringCpy_Var(), and SqlStringTest::testSqlStringTrim_Helper().
Definition at line 116 of file SqlStringBuffer.h.
Referenced by init(), patternfill(), and randomize().
Definition at line 117 of file SqlStringBuffer.h.
Referenced by init(), and SqlStringTest::testSqlStringBuffer_UCS2().
Definition at line 118 of file SqlStringBuffer.h.
Referenced by dump(), equal(), init(), and SqlStringTest::testSqlStringBuffer_UCS2().
const int SqlStringBufferUCS2::mStorage |
Definition at line 119 of file SqlStringBuffer.h.
Referenced by dump(), init(), SqlStringTest::testSqlStringAlterCase_UCS2(), SqlStringTest::testSqlStringBuffer_UCS2(), SqlStringTest::testSqlStringCpy_Fix(), SqlStringTest::testSqlStringCpy_Var(), and SqlStringTest::testSqlStringTrim_Helper().
const int SqlStringBufferUCS2::mSize |
Definition at line 120 of file SqlStringBuffer.h.
Referenced by dump(), init(), patternfill(), randomize(), SqlStringTest::testSqlStringAlterCase_UCS2(), SqlStringTest::testSqlStringBuffer_UCS2(), SqlStringTest::testSqlStringCpy_Fix(), and verify().
const int SqlStringBufferUCS2::mLeftPad |
Definition at line 121 of file SqlStringBuffer.h.
Referenced by init(), SqlStringTest::testSqlStringBuffer_UCS2(), and verify().
const int SqlStringBufferUCS2::mRightPad |
Definition at line 122 of file SqlStringBuffer.h.
Referenced by init(), SqlStringTest::testSqlStringBuffer_UCS2(), and verify().
const int SqlStringBufferUCS2::mLeftBump |
Definition at line 123 of file SqlStringBuffer.h.
Referenced by dump(), init(), SqlStringBufferUCS2(), and verify().
const int SqlStringBufferUCS2::mRightBump |
Definition at line 124 of file SqlStringBuffer.h.
Referenced by dump(), init(), SqlStringBufferUCS2(), and verify().
const int SqlStringBufferUCS2::mTotal |
Definition at line 125 of file SqlStringBuffer.h.
Referenced by dump(), equal(), SqlStringBufferUCS2(), and verify().
string SqlStringBufferUCS2::mS |
Definition at line 126 of file SqlStringBuffer.h.
Referenced by init(), SqlStringBufferUCS2(), SqlStringTest::testSqlStringBuffer_UCS2(), and verify().