| 1 |
|
|---|
| 2 | #include "ole32.h"
|
|---|
| 3 |
|
|---|
| 4 | #include "oString.h"
|
|---|
| 5 |
|
|---|
| 6 | // ======================================================================
|
|---|
| 7 | // oStringBase - Base stuff for oString classes
|
|---|
| 8 | // ======================================================================
|
|---|
| 9 |
|
|---|
| 10 | // Block size.
|
|---|
| 11 | long oStringBase::blockSize = 32;
|
|---|
| 12 |
|
|---|
| 13 | // Initialise to nothing...
|
|---|
| 14 | oStringBase::oStringBase(long bytePerChar)
|
|---|
| 15 | {
|
|---|
| 16 | m_bytePerChar = bytePerChar;
|
|---|
| 17 | m_Heap = GetProcessHeap();
|
|---|
| 18 | }
|
|---|
| 19 |
|
|---|
| 20 | // Destructor
|
|---|
| 21 | oStringBase::~oStringBase()
|
|---|
| 22 | {
|
|---|
| 23 | freeBuf();
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 | // calculate the buffersize needed for this string (quantised to blockSize)
|
|---|
| 27 | long oStringBase::calcBufLen(long strLen)
|
|---|
| 28 | {
|
|---|
| 29 | long tmp;
|
|---|
| 30 |
|
|---|
| 31 | tmp = ((strLen * m_bytePerChar) / blockSize) + 1;
|
|---|
| 32 |
|
|---|
| 33 | return tmp * blockSize;
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | // Get a buffer of required length...
|
|---|
| 37 | void oStringBase::getBuf(long strLen)
|
|---|
| 38 | {
|
|---|
| 39 | // Sanity check...
|
|---|
| 40 | if (strLen < 1)
|
|---|
| 41 | {
|
|---|
| 42 | dprintf(("oStringBase: Warning! ::getBuf - strlen < 1!"));
|
|---|
| 43 | strLen = 1;
|
|---|
| 44 | }
|
|---|
| 45 |
|
|---|
| 46 | // Allocate new buffer...
|
|---|
| 47 | m_bufLen = calcBufLen(strLen);
|
|---|
| 48 | m_strBuf = (LPSTR)HeapAlloc(m_Heap, 0, m_bufLen);
|
|---|
| 49 | m_strLen = 1;
|
|---|
| 50 | m_strBuf[0] = 0; // Ensure terminated.
|
|---|
| 51 | }
|
|---|
| 52 |
|
|---|
| 53 | // Free buffer...
|
|---|
| 54 | void oStringBase::freeBuf()
|
|---|
| 55 | {
|
|---|
| 56 | HeapFree(m_Heap, 0, m_strBuf);
|
|---|
| 57 | }
|
|---|
| 58 |
|
|---|
| 59 | // Re-allocate buffer if more space is required...
|
|---|
| 60 | void oStringBase::adjBuf(long strLen)
|
|---|
| 61 | {
|
|---|
| 62 | if ((strLen * m_bytePerChar) > m_bufLen)
|
|---|
| 63 | {
|
|---|
| 64 | long bufLen = calcBufLen(strLen);
|
|---|
| 65 |
|
|---|
| 66 | // Allocate new buffer...
|
|---|
| 67 | m_strBuf = (LPSTR)HeapReAlloc(m_Heap, 0, m_strBuf, bufLen);
|
|---|
| 68 |
|
|---|
| 69 | // Save new buffer...
|
|---|
| 70 | m_bufLen = bufLen;
|
|---|
| 71 | }
|
|---|
| 72 | }
|
|---|
| 73 |
|
|---|
| 74 | // ======================================================================
|
|---|
| 75 | // oStringA - String manipulation based on ASCII
|
|---|
| 76 | // ======================================================================
|
|---|
| 77 |
|
|---|
| 78 | // Initialise to nothing...
|
|---|
| 79 | oStringA::oStringA( void) : oStringBase(sizeof(char))
|
|---|
| 80 | {
|
|---|
| 81 | getBuf( 1); // Incl. terminator...
|
|---|
| 82 | }
|
|---|
| 83 |
|
|---|
| 84 | // Initialise to a specified length...
|
|---|
| 85 | oStringA::oStringA(int defLen) : oStringBase(sizeof(char))
|
|---|
| 86 | {
|
|---|
| 87 | getBuf( defLen + 1);
|
|---|
| 88 | }
|
|---|
| 89 |
|
|---|
| 90 | // Initialise from Unicode string...
|
|---|
| 91 | oStringA::oStringA(LPCWSTR pUnicode) : oStringBase(sizeof(char))
|
|---|
| 92 | {
|
|---|
| 93 | long strLen = lstrlenW(pUnicode) + 1;
|
|---|
| 94 |
|
|---|
| 95 | getBuf( strLen);
|
|---|
| 96 | UnicodeToAscii((LPWSTR)pUnicode, m_strBuf);
|
|---|
| 97 | m_strLen = strLen;
|
|---|
| 98 | }
|
|---|
| 99 |
|
|---|
| 100 | // Initialise from ASCII string...
|
|---|
| 101 | oStringA::oStringA(LPCSTR pAscii) : oStringBase(sizeof(char))
|
|---|
| 102 | {
|
|---|
| 103 | long strLen = strlen(pAscii) + 1;
|
|---|
| 104 |
|
|---|
| 105 | getBuf( strLen);
|
|---|
| 106 | strcpy(m_strBuf, pAscii);
|
|---|
| 107 | m_strLen = strLen;
|
|---|
| 108 | }
|
|---|
| 109 |
|
|---|
| 110 | // Initialise from another oString
|
|---|
| 111 | oStringA::oStringA(const oStringA &ref) : oStringBase(sizeof(char))
|
|---|
| 112 | {
|
|---|
| 113 | getBuf( ref.m_strLen);
|
|---|
| 114 | strcpy(m_strBuf, ref.m_strBuf);
|
|---|
| 115 | m_strLen = ref.m_strLen;
|
|---|
| 116 | }
|
|---|
| 117 |
|
|---|
| 118 | // Initialise from CLSID
|
|---|
| 119 | oStringA::oStringA( REFCLSID pClsId) : oStringBase(sizeof(char))
|
|---|
| 120 | {
|
|---|
| 121 | getBuf( 50); // Incl. terminator...
|
|---|
| 122 |
|
|---|
| 123 | // Assign string...
|
|---|
| 124 | operator=(pClsId);
|
|---|
| 125 | }
|
|---|
| 126 |
|
|---|
| 127 | // Return pointer to string...
|
|---|
| 128 | oStringA::operator LPSTR()
|
|---|
| 129 | {
|
|---|
| 130 | return (LPSTR)m_strBuf;
|
|---|
| 131 | }
|
|---|
| 132 |
|
|---|
| 133 |
|
|---|
| 134 | // Assign
|
|---|
| 135 | oStringA oStringA::operator = (const oStringA & string)
|
|---|
| 136 | {
|
|---|
| 137 | // Lose old string...
|
|---|
| 138 | freeBuf();
|
|---|
| 139 |
|
|---|
| 140 | // Setup new string...
|
|---|
| 141 | getBuf( string.m_strLen);
|
|---|
| 142 | strcpy(m_strBuf, string.m_strBuf);
|
|---|
| 143 | m_strLen = string.m_strLen;
|
|---|
| 144 | return *this;
|
|---|
| 145 | }
|
|---|
| 146 |
|
|---|
| 147 | oStringA oStringA::operator = (LPCSTR pAscii)
|
|---|
| 148 | {
|
|---|
| 149 | long strLen = strlen(pAscii) + 1;
|
|---|
| 150 |
|
|---|
| 151 | // Lose old string...
|
|---|
| 152 | freeBuf();
|
|---|
| 153 |
|
|---|
| 154 | // Setup new string...
|
|---|
| 155 | getBuf( strLen);
|
|---|
| 156 | strcpy(m_strBuf, pAscii);
|
|---|
| 157 | m_strLen = strLen;
|
|---|
| 158 | return *this;
|
|---|
| 159 | }
|
|---|
| 160 |
|
|---|
| 161 | oStringA oStringA::operator = (LPCWSTR pUnicode)
|
|---|
| 162 | {
|
|---|
| 163 | long strLen = lstrlenW(pUnicode) + 1;
|
|---|
| 164 |
|
|---|
| 165 | // Lose old string...
|
|---|
| 166 | freeBuf();
|
|---|
| 167 |
|
|---|
| 168 | // Setup new string...
|
|---|
| 169 | getBuf( strLen);
|
|---|
| 170 | UnicodeToAscii((LPWSTR)pUnicode, m_strBuf);
|
|---|
| 171 | m_strLen = strLen;
|
|---|
| 172 | return *this;
|
|---|
| 173 | }
|
|---|
| 174 |
|
|---|
| 175 | oStringA oStringA::operator = (REFCLSID rClsId)
|
|---|
| 176 | {
|
|---|
| 177 | // Lose old string...
|
|---|
| 178 | freeBuf();
|
|---|
| 179 |
|
|---|
| 180 | // Setup new string...
|
|---|
| 181 | getBuf( 50);
|
|---|
| 182 | m_strLen = sprintf(m_strBuf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
|
|---|
| 183 | rClsId->Data1,
|
|---|
| 184 | rClsId->Data2,
|
|---|
| 185 | rClsId->Data3,
|
|---|
| 186 | rClsId->Data4[0],
|
|---|
| 187 | rClsId->Data4[1],
|
|---|
| 188 | rClsId->Data4[2],
|
|---|
| 189 | rClsId->Data4[3],
|
|---|
| 190 | rClsId->Data4[4],
|
|---|
| 191 | rClsId->Data4[5],
|
|---|
| 192 | rClsId->Data4[6],
|
|---|
| 193 | rClsId->Data4[7]);
|
|---|
| 194 | return *this;
|
|---|
| 195 | }
|
|---|
| 196 |
|
|---|
| 197 | // Add String to String
|
|---|
| 198 | oStringA oStringA::operator + (const oStringA & string)
|
|---|
| 199 | {
|
|---|
| 200 | // two terminators to account for...
|
|---|
| 201 | oStringA product(m_strLen + string.m_strLen - 1);
|
|---|
| 202 |
|
|---|
| 203 | memcpy(product.m_strBuf, m_strBuf, m_strLen);
|
|---|
| 204 | strcpy(product.m_strBuf + m_strLen - 1, string.m_strBuf);
|
|---|
| 205 | product.m_strLen = m_strLen + string.m_strLen - 1;
|
|---|
| 206 |
|
|---|
| 207 | return product;
|
|---|
| 208 | }
|
|---|
| 209 |
|
|---|
| 210 | // Add String to ASCII string
|
|---|
| 211 | oStringA oStringA::operator + (LPCSTR pAscii)
|
|---|
| 212 | {
|
|---|
| 213 | long strLen = m_strLen + strlen(pAscii);
|
|---|
| 214 |
|
|---|
| 215 | oStringA product(strLen);
|
|---|
| 216 |
|
|---|
| 217 | memcpy(product.m_strBuf, m_strBuf, m_strLen);
|
|---|
| 218 | strcpy(product.m_strBuf + m_strLen - 1, pAscii);
|
|---|
| 219 | product.m_strLen = strLen;
|
|---|
| 220 |
|
|---|
| 221 | return product;
|
|---|
| 222 | }
|
|---|
| 223 |
|
|---|
| 224 | // Add String to UNICODE string
|
|---|
| 225 | oStringA oStringA::operator + (LPCWSTR pUnicode)
|
|---|
| 226 | {
|
|---|
| 227 | long strLen = m_strLen + lstrlenW(pUnicode);
|
|---|
| 228 |
|
|---|
| 229 | oStringA product(strLen);
|
|---|
| 230 |
|
|---|
| 231 | memcpy(product.m_strBuf, m_strBuf, m_strLen);
|
|---|
| 232 | UnicodeToAscii((LPWSTR)pUnicode, product.m_strBuf + m_strLen - 1);
|
|---|
| 233 | product.m_strLen = strLen;
|
|---|
| 234 |
|
|---|
| 235 | return product;
|
|---|
| 236 | }
|
|---|
| 237 |
|
|---|
| 238 | // Concatenate string object
|
|---|
| 239 | oStringA oStringA::operator += (const oStringA & string)
|
|---|
| 240 | {
|
|---|
| 241 | // two terminators to account for...
|
|---|
| 242 | long strLen = m_strLen + string.m_strLen - 1;
|
|---|
| 243 |
|
|---|
| 244 | adjBuf( strLen);
|
|---|
| 245 | strcpy(m_strBuf + m_strLen - 1, string.m_strBuf);
|
|---|
| 246 | m_strLen = strLen;
|
|---|
| 247 |
|
|---|
| 248 | return *this;
|
|---|
| 249 | }
|
|---|
| 250 |
|
|---|
| 251 | // Concatenate Ascii string
|
|---|
| 252 | oStringA oStringA::operator += (LPCSTR pAscii)
|
|---|
| 253 | {
|
|---|
| 254 | long strLen = m_strLen + strlen(pAscii);
|
|---|
| 255 |
|
|---|
| 256 | adjBuf( strLen);
|
|---|
| 257 | strcpy(m_strBuf + m_strLen - 1, pAscii);
|
|---|
| 258 | m_strLen = strLen;
|
|---|
| 259 |
|
|---|
| 260 | return *this;
|
|---|
| 261 | }
|
|---|
| 262 |
|
|---|
| 263 | // Concatenate Unicode string
|
|---|
| 264 | oStringA oStringA::operator += (LPCWSTR pUnicode)
|
|---|
| 265 | {
|
|---|
| 266 | long strLen = m_strLen + lstrlenW(pUnicode);
|
|---|
| 267 |
|
|---|
| 268 | adjBuf( strLen);
|
|---|
| 269 | UnicodeToAscii((LPWSTR)pUnicode, m_strBuf + m_strLen - 1);
|
|---|
| 270 | m_strLen = strLen;
|
|---|
| 271 |
|
|---|
| 272 | return *this;
|
|---|
| 273 | }
|
|---|
| 274 |
|
|---|
| 275 | // ======================================================================
|
|---|
| 276 | // oStringW - String manipulation based on Unicode
|
|---|
| 277 | // ======================================================================
|
|---|
| 278 |
|
|---|
| 279 | // Initialise to nothing...
|
|---|
| 280 | oStringW::oStringW( void) : oStringBase(sizeof(WCHAR))
|
|---|
| 281 | {
|
|---|
| 282 | getBuf( 1); // Incl. terminator...
|
|---|
| 283 | }
|
|---|
| 284 |
|
|---|
| 285 | // Initialise to a specified length...
|
|---|
| 286 | oStringW::oStringW(int defLen) : oStringBase(sizeof(WCHAR))
|
|---|
| 287 | {
|
|---|
| 288 | getBuf( defLen + 1);
|
|---|
| 289 | }
|
|---|
| 290 |
|
|---|
| 291 | // Initialise from Unicode string...
|
|---|
| 292 | oStringW::oStringW(LPCWSTR pUnicode) : oStringBase(sizeof(WCHAR))
|
|---|
| 293 | {
|
|---|
| 294 | long strLen = lstrlenW((const WCHAR *)pUnicode) + 1;
|
|---|
| 295 |
|
|---|
| 296 | getBuf(strLen);
|
|---|
| 297 | lstrcpyW((LPWSTR)m_strBuf, pUnicode);
|
|---|
| 298 | m_strLen = strLen;
|
|---|
| 299 | }
|
|---|
| 300 |
|
|---|
| 301 | // Initialise from Unicode string...
|
|---|
| 302 | oStringW::oStringW(const wchar_t * pUnicode) : oStringBase(sizeof(WCHAR))
|
|---|
| 303 | {
|
|---|
| 304 | long strLen = lstrlenW((LPWSTR)pUnicode) + 1;
|
|---|
| 305 |
|
|---|
| 306 | getBuf(strLen);
|
|---|
| 307 | lstrcpyW((LPWSTR)m_strBuf, (LPCWSTR)pUnicode);
|
|---|
| 308 | m_strLen = strLen;
|
|---|
| 309 | }
|
|---|
| 310 |
|
|---|
| 311 | // Initialise from ASCII string...
|
|---|
| 312 | oStringW::oStringW(LPCSTR pAscii) : oStringBase(sizeof(WCHAR))
|
|---|
| 313 | {
|
|---|
| 314 | long strLen = strlen(pAscii) + 1;
|
|---|
| 315 |
|
|---|
| 316 | getBuf( strLen);
|
|---|
| 317 | AsciiToUnicode((char *)pAscii, (LPWSTR)m_strBuf);
|
|---|
| 318 | m_strLen = strLen;
|
|---|
| 319 | }
|
|---|
| 320 |
|
|---|
| 321 | // Initialise from another oString
|
|---|
| 322 | oStringW::oStringW(const oStringW &ref) : oStringBase(sizeof(WCHAR))
|
|---|
| 323 | {
|
|---|
| 324 | getBuf( ref.m_strLen);
|
|---|
| 325 | lstrcpyW((LPWSTR)m_strBuf, (LPWSTR)ref.m_strBuf);
|
|---|
| 326 | m_strLen = ref.m_strLen;
|
|---|
| 327 | }
|
|---|
| 328 |
|
|---|
| 329 | // Initialise from CLSID
|
|---|
| 330 | oStringW::oStringW( REFCLSID pClsId) : oStringBase(sizeof(WCHAR))
|
|---|
| 331 | {
|
|---|
| 332 | getBuf( 50); // Incl. terminator...
|
|---|
| 333 |
|
|---|
| 334 | // Assign string...
|
|---|
| 335 | operator=(pClsId);
|
|---|
| 336 | }
|
|---|
| 337 |
|
|---|
| 338 | // Return pointer to string...
|
|---|
| 339 | oStringW::operator LPWSTR()
|
|---|
| 340 | {
|
|---|
| 341 | return (LPWSTR)m_strBuf;
|
|---|
| 342 | }
|
|---|
| 343 |
|
|---|
| 344 | // Assign
|
|---|
| 345 | oStringW oStringW::operator = (const oStringW & string)
|
|---|
| 346 | {
|
|---|
| 347 | // Lose old string...
|
|---|
| 348 | freeBuf();
|
|---|
| 349 |
|
|---|
| 350 | // Setup new string...
|
|---|
| 351 | getBuf( string.m_strLen);
|
|---|
| 352 | lstrcpyW((LPWSTR)m_strBuf, (LPWSTR)string.m_strBuf);
|
|---|
| 353 | m_strLen = string.m_strLen;
|
|---|
| 354 | return *this;
|
|---|
| 355 | }
|
|---|
| 356 |
|
|---|
| 357 | oStringW oStringW::operator = (LPCSTR pAscii)
|
|---|
| 358 | {
|
|---|
| 359 | long strLen = strlen(pAscii) + 1;
|
|---|
| 360 |
|
|---|
| 361 | // Lose old string...
|
|---|
| 362 | freeBuf();
|
|---|
| 363 |
|
|---|
| 364 | // Setup new string...
|
|---|
| 365 | getBuf( strLen);
|
|---|
| 366 | AsciiToUnicode((char *)pAscii, (LPWSTR)m_strBuf);
|
|---|
| 367 | m_strLen = strLen;
|
|---|
| 368 | return *this;
|
|---|
| 369 | }
|
|---|
| 370 |
|
|---|
| 371 | oStringW oStringW::operator = (LPCWSTR pUnicode)
|
|---|
| 372 | {
|
|---|
| 373 | long strLen = lstrlenW(pUnicode) + 1;
|
|---|
| 374 |
|
|---|
| 375 | // Lose old string...
|
|---|
| 376 | freeBuf();
|
|---|
| 377 |
|
|---|
| 378 | // Setup new string...
|
|---|
| 379 | getBuf( strLen);
|
|---|
| 380 | lstrcpyW((LPWSTR)m_strBuf, pUnicode);
|
|---|
| 381 | m_strLen = strLen;
|
|---|
| 382 | return *this;
|
|---|
| 383 | }
|
|---|
| 384 |
|
|---|
| 385 | oStringW oStringW::operator = (const wchar_t * pUnicode)
|
|---|
| 386 | {
|
|---|
| 387 | long strLen = lstrlenW((LPWSTR)pUnicode) + 1;
|
|---|
| 388 |
|
|---|
| 389 | // Lose old string...
|
|---|
| 390 | freeBuf();
|
|---|
| 391 |
|
|---|
| 392 | // Setup new string...
|
|---|
| 393 | getBuf( strLen);
|
|---|
| 394 | lstrcpyW((LPWSTR)m_strBuf, (LPWSTR)pUnicode);
|
|---|
| 395 | m_strLen = strLen;
|
|---|
| 396 | return *this;
|
|---|
| 397 | }
|
|---|
| 398 |
|
|---|
| 399 | oStringW oStringW::operator = (REFCLSID rClsId)
|
|---|
| 400 | {
|
|---|
| 401 | char tmp[50];
|
|---|
| 402 |
|
|---|
| 403 | // Lose old string...
|
|---|
| 404 | freeBuf();
|
|---|
| 405 |
|
|---|
| 406 | // Setup new string...
|
|---|
| 407 | getBuf( 50);
|
|---|
| 408 | m_strLen = sprintf(tmp, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
|
|---|
| 409 | rClsId->Data1,
|
|---|
| 410 | rClsId->Data2,
|
|---|
| 411 | rClsId->Data3,
|
|---|
| 412 | rClsId->Data4[0],
|
|---|
| 413 | rClsId->Data4[1],
|
|---|
| 414 | rClsId->Data4[2],
|
|---|
| 415 | rClsId->Data4[3],
|
|---|
| 416 | rClsId->Data4[4],
|
|---|
| 417 | rClsId->Data4[5],
|
|---|
| 418 | rClsId->Data4[6],
|
|---|
| 419 | rClsId->Data4[7]);
|
|---|
| 420 | AsciiToUnicode(tmp, (LPWSTR)m_strBuf);
|
|---|
| 421 | return *this;
|
|---|
| 422 | }
|
|---|
| 423 |
|
|---|
| 424 | // Add String to String
|
|---|
| 425 | oStringW oStringW::operator + (const oStringW & string)
|
|---|
| 426 | {
|
|---|
| 427 | // two terminators to account for...
|
|---|
| 428 | oStringW product(m_strLen + string.m_strLen - 1);
|
|---|
| 429 |
|
|---|
| 430 | lstrcpyW((LPWSTR)product.m_strBuf, (LPWSTR)m_strBuf);
|
|---|
| 431 | lstrcpyW((LPWSTR)product.m_strBuf + m_strLen - 1, (LPWSTR)string.m_strBuf);
|
|---|
| 432 | product.m_strLen = m_strLen + string.m_strLen - 1;
|
|---|
| 433 |
|
|---|
| 434 | return product;
|
|---|
| 435 | }
|
|---|
| 436 |
|
|---|
| 437 | // Add String to ASCII string
|
|---|
| 438 | oStringW oStringW::operator + (LPCSTR pAscii)
|
|---|
| 439 | {
|
|---|
| 440 | long strLen = m_strLen + strlen(pAscii);
|
|---|
| 441 |
|
|---|
| 442 | oStringW product(strLen);
|
|---|
| 443 |
|
|---|
| 444 | lstrcpyW((LPWSTR)product.m_strBuf, (LPWSTR)m_strBuf);
|
|---|
| 445 | AsciiToUnicode((char *)pAscii, (LPWSTR)product.m_strBuf + m_strLen - 1);
|
|---|
| 446 | product.m_strLen = strLen;
|
|---|
| 447 |
|
|---|
| 448 | return product;
|
|---|
| 449 | }
|
|---|
| 450 |
|
|---|
| 451 | // Add String to UNICODE string
|
|---|
| 452 | oStringW oStringW::operator + (LPCWSTR pUnicode)
|
|---|
| 453 | {
|
|---|
| 454 | long strLen = m_strLen + lstrlenW(pUnicode);
|
|---|
| 455 |
|
|---|
| 456 | oStringW product(strLen);
|
|---|
| 457 |
|
|---|
| 458 | lstrcpyW((LPWSTR)product.m_strBuf, (LPWSTR)m_strBuf);
|
|---|
| 459 | lstrcpyW((LPWSTR)product.m_strBuf + m_strLen - 1, (LPWSTR)pUnicode);
|
|---|
| 460 | product.m_strLen = strLen;
|
|---|
| 461 |
|
|---|
| 462 | return product;
|
|---|
| 463 | }
|
|---|
| 464 |
|
|---|
| 465 | // Add String to UNICODE string
|
|---|
| 466 | oStringW oStringW::operator + (const wchar_t * pUnicode)
|
|---|
| 467 | {
|
|---|
| 468 | long strLen = m_strLen + lstrlenW((LPWSTR)pUnicode);
|
|---|
| 469 |
|
|---|
| 470 | oStringW product(strLen);
|
|---|
| 471 |
|
|---|
| 472 | lstrcpyW((LPWSTR)product.m_strBuf, (LPWSTR)m_strBuf);
|
|---|
| 473 | lstrcpyW((LPWSTR)product.m_strBuf + m_strLen - 1, (LPWSTR)pUnicode);
|
|---|
| 474 | product.m_strLen = strLen;
|
|---|
| 475 |
|
|---|
| 476 | return product;
|
|---|
| 477 | }
|
|---|
| 478 |
|
|---|
| 479 | // Concatenate string object
|
|---|
| 480 | oStringW oStringW::operator += (const oStringW & string)
|
|---|
| 481 | {
|
|---|
| 482 | // two terminators to account for...
|
|---|
| 483 | long strLen = m_strLen + string.m_strLen - 1;
|
|---|
| 484 |
|
|---|
| 485 | adjBuf( strLen);
|
|---|
| 486 | lstrcpyW((LPWSTR)m_strBuf + m_strLen - 1, (LPWSTR)string.m_strBuf);
|
|---|
| 487 | m_strLen = strLen;
|
|---|
| 488 |
|
|---|
| 489 | return *this;
|
|---|
| 490 | }
|
|---|
| 491 |
|
|---|
| 492 | // Concatenate Ascii string
|
|---|
| 493 | oStringW oStringW::operator += (LPCSTR pAscii)
|
|---|
| 494 | {
|
|---|
| 495 | long strLen = m_strLen + strlen(pAscii);
|
|---|
| 496 |
|
|---|
| 497 | adjBuf( strLen);
|
|---|
| 498 | AsciiToUnicode((char *)pAscii, (LPWSTR)m_strBuf + m_strLen - 1);
|
|---|
| 499 | m_strLen = strLen;
|
|---|
| 500 |
|
|---|
| 501 | return *this;
|
|---|
| 502 | }
|
|---|
| 503 |
|
|---|
| 504 | // Concatenate Unicode string
|
|---|
| 505 | oStringW oStringW::operator += (LPCWSTR pUnicode)
|
|---|
| 506 | {
|
|---|
| 507 | long strLen = m_strLen + lstrlenW(pUnicode);
|
|---|
| 508 |
|
|---|
| 509 | adjBuf( strLen);
|
|---|
| 510 | lstrcpyW((LPWSTR)m_strBuf + m_strLen - 1, (LPWSTR)pUnicode);
|
|---|
| 511 | m_strLen = strLen;
|
|---|
| 512 |
|
|---|
| 513 | return *this;
|
|---|
| 514 | }
|
|---|
| 515 |
|
|---|
| 516 | // Concatenate Unicode string
|
|---|
| 517 | oStringW oStringW::operator += (const wchar_t * pUnicode)
|
|---|
| 518 | {
|
|---|
| 519 | long strLen = m_strLen + lstrlenW((LPWSTR)pUnicode);
|
|---|
| 520 |
|
|---|
| 521 | adjBuf( strLen);
|
|---|
| 522 | lstrcpyW((LPWSTR)m_strBuf + m_strLen - 1, (LPWSTR)pUnicode);
|
|---|
| 523 | m_strLen = strLen;
|
|---|
| 524 |
|
|---|
| 525 | return *this;
|
|---|
| 526 | }
|
|---|
| 527 |
|
|---|
| 528 |
|
|---|