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