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