StringW.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783
  1. #include <bfc/wasabi_std.h>
  2. #include <bfc/std_mem.h>
  3. #include <bfc/nsguid.h>
  4. #include "StringW.h"
  5. #ifdef _WIN32
  6. #include <shlwapi.h>
  7. #endif
  8. StringW::StringW(const wchar_t *initial_val)
  9. : val(NULL)
  10. {
  11. setValue(initial_val);
  12. }
  13. StringW::StringW(const StringW &s)
  14. : val(NULL)
  15. {
  16. if (s == NULL) setValue(NULL);
  17. else setValue(s.getValue());
  18. }
  19. StringW::StringW(const StringW *s)
  20. : val(NULL)
  21. {
  22. if (s == NULL) setValue(NULL);
  23. else setValue(s->getValue());
  24. }
  25. StringW::~StringW()
  26. {
  27. FREE(val);
  28. val = NULL;
  29. }
  30. int StringW::replaceNumericField(int value, wchar_t fieldchar)
  31. {
  32. if (val == NULL || *val == '\0') return 0;
  33. int nrep = 0;
  34. for (const wchar_t *p = val; *p; p++)
  35. {
  36. if (*p == fieldchar) nrep++;
  37. else if (nrep) break;
  38. }
  39. if (nrep == 0) return 0; // no field found
  40. StringW rc;
  41. wchar_t fc[2] = { 0, 0 };
  42. fc[0] = fieldchar;
  43. for (int i = 0; i < nrep; i++) rc.cat(fc);
  44. StringPrintfW fmt(L"%%0%0dd", nrep);
  45. StringPrintfW replacement(fmt.getValue(), value);
  46. return replace(rc, replacement);
  47. }
  48. // Returns index of first found, -1 if not found.
  49. size_t StringW::lFindChar(wchar_t findval)
  50. {
  51. size_t length = len();
  52. for (size_t i = 0; i != length; i++)
  53. {
  54. if (val[i] == findval)
  55. {
  56. return i;
  57. }
  58. }
  59. return -1;
  60. }
  61. const wchar_t *StringW::setValue(const wchar_t *newval)
  62. {
  63. if (newval != val)
  64. {
  65. if ((unsigned long long)newval == NULL || ((unsigned long long)newval <= 65535))
  66. {
  67. FREE(val);
  68. val = NULL;
  69. }
  70. else
  71. {
  72. if (val)
  73. {
  74. size_t len = wcslen(newval);
  75. if (val != NULL)
  76. #ifdef STRING_REALLOC_OPTIMS
  77. {
  78. size_t oldlen = wcslen(val);
  79. // if smaller but greater than half previous size, don't realloc
  80. if (len > oldlen || len < oldlen / 2)
  81. val = (wchar_t *)REALLOC(val, sizeof(wchar_t) * (len + 1));
  82. }
  83. #else
  84. val = (wchar_t *)REALLOC(val, sizeof(wchar_t) * (len + 1));
  85. #endif
  86. else
  87. val = WMALLOC(len + 1);
  88. ASSERT(newval != NULL);
  89. MEMCPY_(val, newval, sizeof(wchar_t)*(len + 1));
  90. }
  91. else
  92. val = WCSDUP(newval);
  93. }
  94. }
  95. return getValue();
  96. }
  97. int StringW::isequal(const wchar_t *otherval) const
  98. {
  99. // TODO: benski> move to WCSCMPSAFE
  100. if (!otherval)
  101. otherval = L"";
  102. if (!getValue())
  103. return !wcscmp(L"", otherval);
  104. else
  105. return !wcscmp(getValue(), otherval);
  106. }
  107. int StringW::iscaseequal(const wchar_t *otherval) const
  108. {
  109. return !WCSICMPSAFE(getValue(), otherval);
  110. }
  111. int StringW::isempty() const
  112. {
  113. return (!val || !*val);
  114. }
  115. void StringW::toupper()
  116. {
  117. if (!isempty())
  118. {
  119. #ifdef _WIN32
  120. CharUpperW(val);
  121. #else
  122. wchar_t *itr = val;
  123. while (itr && *itr)
  124. {
  125. *itr = ::towupper(*itr);
  126. itr++;
  127. }
  128. #endif
  129. }
  130. }
  131. void StringW::tolower()
  132. {
  133. if (!isempty())
  134. {
  135. #ifdef _WIN32
  136. CharLowerW(val);
  137. #else
  138. wchar_t *itr = val;
  139. while (itr && *itr)
  140. {
  141. *itr = ::towlower(*itr);
  142. itr++;
  143. }
  144. #endif
  145. }
  146. }
  147. const wchar_t *StringW::getValueSafe(const wchar_t *def_val) const
  148. {
  149. if (val == NULL)
  150. return def_val;
  151. else
  152. return val;
  153. }
  154. const wchar_t *StringW::cat(const wchar_t *value)
  155. {
  156. if (value == NULL || *value == 0)
  157. return getValue();
  158. if (val == NULL)
  159. return setValue(value);
  160. return catn(value, wcslen(value));
  161. }
  162. const wchar_t *StringW::catn(const wchar_t *value, size_t len)
  163. {
  164. if (len == 0) return val;
  165. if (value == NULL || *value == 0) return getValue();
  166. if (val == NULL) return ncpy(value, len);
  167. size_t ol = wcslen(val);
  168. val = (wchar_t *)REALLOC(val, sizeof(wchar_t) * (ol + len + 1));
  169. val[ol + len] = 0;
  170. wcsncpy(val + ol, value, len);
  171. return val;
  172. }
  173. // replaces string with n chars of val or length of val, whichever is less.
  174. const wchar_t *StringW::ncpy(const wchar_t *newstr, size_t numchars)
  175. {
  176. val = (wchar_t *)REALLOC(val, sizeof(wchar_t) * (numchars + 1));
  177. val[numchars] = 0;
  178. wcsncpy(val, newstr, numchars);
  179. return getValue();
  180. }
  181. // swaps buffers with another string
  182. void StringW::swap(StringW *swapper)
  183. {
  184. wchar_t *tempChar = swapper->val;
  185. swapper->val = val;
  186. val = tempChar;
  187. }
  188. void StringW::swap(StringW &swapper) // swaps buffers with another string
  189. {
  190. wchar_t *tempChar = swapper.val;
  191. swapper.val = val;
  192. val = tempChar;
  193. }
  194. // take ownership of a buffer
  195. void StringW::own(wchar_t *swapper)
  196. {
  197. if (val)
  198. FREE(val);
  199. val = swapper;
  200. }
  201. const wchar_t *StringW::catPostSeparator(const wchar_t *value, const wchar_t separator)
  202. {
  203. if (value == NULL || *value == 0 || separator == 0) return getValue();
  204. size_t oldLen = val ? wcslen(val) : 0;
  205. size_t newLen = wcslen(value);
  206. val = (wchar_t *)REALLOC(val, sizeof(wchar_t) * (oldLen + newLen + 1 + 1)); // +1 for separator, +1 for null character
  207. wcsncpy(val + oldLen, value, newLen + 1);
  208. val[oldLen + newLen] = separator; // add the separator
  209. val[oldLen + newLen + 1] = 0; // null terminate
  210. return val;
  211. }
  212. size_t StringW::va_sprintf(const wchar_t *format, va_list args)
  213. {
  214. if (!format) return 0;
  215. va_list saveargs = args;
  216. // roughly evaluate size of dest string
  217. const wchar_t *p = format;
  218. size_t length = 0;
  219. while (p && *p)
  220. {
  221. if (*(p++) != '%') length++;
  222. else
  223. {
  224. void *arg = va_arg(args, void *);
  225. for (;;)
  226. {
  227. const wchar_t f = *p++;
  228. if (f == 'c') length++;
  229. else if (f == 'i') length += 16;
  230. else if (f == 'u') length += 16;
  231. else if (f == 'f') length += 64;
  232. else if (f == 'd' || f == 'f') length += 64;
  233. else if (f == 'x') length += 32; // Hex with LC Alphas: 0x0009a64c
  234. else if (f == 'X') length += 32; // Hex with UC Alphas: 0x0009A64C
  235. else if (f == 's')
  236. { // ::vsrintf can properly handle null.
  237. if (arg == NULL)
  238. {
  239. length += wcslen(L"(null)"); // Just to be explicit.
  240. }
  241. else
  242. {
  243. length += wcslen((const wchar_t *)arg);
  244. }
  245. }
  246. else if (f == 'S') // uppercase S mean narrow string
  247. { // ::vsrintf can properly handle null.
  248. if (arg == NULL)
  249. {
  250. length += STRLEN("(null)"); // Just to be explicit.
  251. }
  252. else
  253. {
  254. length += STRLEN((const char *)arg);
  255. }
  256. }
  257. else if (ISDIGIT(f)) continue;
  258. else if (f == '.') continue;
  259. else if (f == '%') length++;
  260. else ASSERTPR(0, "undefined format passed to stringprintf!");
  261. break;
  262. }
  263. }
  264. }
  265. if (val)
  266. {
  267. if (len() < length)
  268. val = (wchar_t *)REALLOC(val, sizeof(wchar_t) * (length + 1));
  269. }
  270. else
  271. val = WMALLOC(length + 1);
  272. // now write the string in val
  273. #ifdef _WIN32
  274. size_t remain;
  275. StringCchVPrintfExW(val, length+1, 0, &remain, 0, format, saveargs);
  276. return length-remain;
  277. #elif defined(__APPLE__)
  278. int real_len = ::vswprintf(val, length+1, format, saveargs);
  279. ASSERTPR(real_len <= (int)length, "String.printf overflow");
  280. return real_len;
  281. #endif
  282. }
  283. size_t StringW::len() const
  284. {
  285. return (val == NULL) ? 0 : wcslen(val);
  286. }
  287. void StringW::trunc(int newlen)
  288. {
  289. if (val)
  290. {
  291. int oldlen = (int)wcslen(val);
  292. if (newlen < 0) newlen = MAX(oldlen + newlen, 0);
  293. int trimLen = MIN(oldlen, newlen);
  294. val[trimLen] = 0;
  295. }
  296. }
  297. int StringW::lastChar()
  298. {
  299. if (isempty()) return -1;
  300. return val[len() - 1];
  301. }
  302. const wchar_t *StringW::prepend(const wchar_t *value)
  303. {
  304. if (value == NULL || *value == 0) return getValue();
  305. if (val == NULL) return setValue(value);
  306. StringPrintfW temp(L"%s%s", value, getValue());
  307. swap(&temp);
  308. return getValue();
  309. }
  310. int StringW::replace(const wchar_t *find, const wchar_t *replace)
  311. {
  312. if (len() == 0 || find == NULL || replace == NULL) return 0;
  313. int find_count = 0;
  314. wchar_t *p, *p2;
  315. size_t rep_len = wcslen(replace);
  316. size_t find_len = wcslen(find);
  317. ptrdiff_t size_diff = rep_len - find_len;
  318. if ( size_diff == 0 )
  319. {
  320. p = val;
  321. while ( p = wcsstr( p, find ) )
  322. {
  323. wcsncpy( p, replace, rep_len );
  324. p += find_len;
  325. find_count++;
  326. }
  327. }
  328. else
  329. {
  330. wchar_t *new_buf, *in;
  331. p = val;
  332. while ( p = wcsstr( p, find ) )
  333. {
  334. find_count++;
  335. p += find_len;
  336. }
  337. int length = (int)( len() + find_count * size_diff + 1 );
  338. new_buf = (wchar_t *)MALLOC(sizeof(wchar_t) * length);
  339. p = val;
  340. in = new_buf;
  341. while ( p2 = wcsstr( p, find ) )
  342. {
  343. wcsncpy( in, p, p2 - p );
  344. in += p2 - p;
  345. wcsncpy( in, replace, rep_len );
  346. in += rep_len;
  347. p = p2 + find_len;
  348. }
  349. wcscpy( in, p );
  350. new_buf[ len() + find_count * size_diff ] = 0;
  351. // just swap buffers
  352. FREE(val);
  353. val = new_buf;
  354. }
  355. return find_count;
  356. }
  357. const wchar_t *StringW::printf(const wchar_t *format, ...)
  358. {
  359. va_list args;
  360. va_start (args, format);
  361. va_sprintf(format, args);
  362. va_end(args);
  363. return getValue();
  364. }
  365. void StringW::AppendPath(const wchar_t *path)
  366. {
  367. FixSlashes();
  368. if (val)
  369. {
  370. #ifdef _WIN32
  371. wchar_t temp[MAX_PATH] = {0};
  372. PathCombineW(temp, val, path);
  373. setValue(temp);
  374. #else
  375. #warning find a better way
  376. wchar_t temp[PATH_MAX] = {0};
  377. swprintf(temp, PATH_MAX, L"%s%s", val, path);
  378. setValue(temp);
  379. #endif
  380. }
  381. else
  382. setValue(path);
  383. }
  384. void StringW::AppendFolder(const wchar_t *path)
  385. {
  386. #ifdef _WIN32
  387. FixSlashes();
  388. wchar_t temp[MAX_PATH] = {0};
  389. if (val)
  390. PathCombineW(temp, val, path);
  391. else
  392. WCSCPYN(temp, path, MAX_PATH);
  393. PathAddBackslashW(temp);
  394. setValue(temp);
  395. #else
  396. #warning find a better way
  397. wchar_t temp[PATH_MAX] = {0};
  398. swprintf(temp, PATH_MAX, L"%s%s/", val, path);
  399. setValue(temp);
  400. #endif
  401. }
  402. void StringW::AddBackslash()
  403. {
  404. FixSlashes();
  405. if (val)
  406. {
  407. #ifdef _WIN32
  408. wchar_t temp[MAX_PATH] = {0};
  409. WCSCPYN(temp, val, MAX_PATH);
  410. PathAddBackslashW(temp);
  411. #else
  412. wchar_t temp[PATH_MAX] = {0};
  413. WCSCPYN(temp, val, PATH_MAX);
  414. wcscat(temp, L"/");
  415. #warning port me
  416. #endif
  417. setValue(temp);
  418. }
  419. }
  420. void StringW::changeChar(wchar_t from, wchar_t to)
  421. {
  422. if (val == NULL) return ;
  423. size_t length = len();
  424. for (size_t i = 0; i != length; i++)
  425. if (val[i] == from) val[i] = to;
  426. }
  427. void StringW::RemovePath()
  428. {
  429. #ifdef _WIN32
  430. // benski> the OS-level function fucks up if there are forward slashes, so we'll fix it
  431. // TODO: remove eventually
  432. FixSlashes();
  433. if (val)
  434. PathRemoveFileSpecW(val);
  435. #else
  436. #warning port me
  437. #endif
  438. }
  439. void StringW::purge()
  440. {
  441. FREE(val);
  442. val = NULL;
  443. }
  444. StringW StringW::rSplitChar(const wchar_t *findval)
  445. {
  446. if (val == NULL) return StringW();
  447. // The index of the found character
  448. size_t idxval = rFindChar(findval);
  449. return rSplit(idxval);
  450. }
  451. // Same as above, save the "findval" is a string where it searches
  452. // for any of the characters in the string.
  453. size_t StringW::rFindChar(const wchar_t *findval)
  454. {
  455. size_t length = len();
  456. size_t numchars = wcslen(findval);
  457. for (size_t i = length - 1; i > 0; i--)
  458. {
  459. for (size_t j = 0; j != numchars; j++)
  460. {
  461. if (val[i] == findval[j])
  462. {
  463. return i;
  464. }
  465. }
  466. }
  467. return -1;
  468. }
  469. StringW StringW::lSplitChar(const wchar_t *findval)
  470. {
  471. if (val == NULL) return StringW();
  472. // The index of the found character
  473. size_t idxval = lFindChar(findval);
  474. return lSplit(idxval);
  475. }
  476. // Same as above, save the "findval" is a string where it searches
  477. // for any of the characters in the string.
  478. size_t StringW::lFindChar(const wchar_t *findval)
  479. {
  480. size_t length = len();
  481. size_t numchars = wcslen(findval);
  482. for (size_t i = 0; i != length; i++)
  483. {
  484. for (size_t j = 0; j != numchars; j++)
  485. {
  486. if (val[i] == findval[j])
  487. {
  488. return i;
  489. }
  490. }
  491. }
  492. return -1;
  493. }
  494. StringW StringW::rSplit(size_t idxval)
  495. {
  496. if (val == NULL) return StringW();
  497. if (idxval == -1)
  498. { // Not Found
  499. // Copy our contents to return on the stack
  500. StringW retval(val);
  501. // And zero the string.
  502. val[0] = 0;
  503. return retval;
  504. }
  505. else
  506. {
  507. // Copy from the found index downwards to the retval
  508. StringW retval(val + idxval);
  509. // Terminate the found char index
  510. val[idxval] = 0;
  511. // That was easier, wasn't it?
  512. return retval;
  513. }
  514. }
  515. // Splits string at findval. Characters passed by search, including the
  516. // found character, are MOVED to the returned string. If there is no char
  517. // to be found, the entire string is returnef and the called instance is
  518. // left empty. (Makes looped splits very easy).
  519. StringW StringW::lSplit(size_t idxval)
  520. {
  521. if (val == NULL) return StringW();
  522. if (idxval == -1)
  523. { // Not Found
  524. // Copy our contents to return on the stack
  525. StringW retval(val);
  526. // And zero the string.
  527. if (val)
  528. {
  529. val[0] = 0;
  530. }
  531. return retval;
  532. }
  533. else
  534. {
  535. StringW retval;
  536. // Copy into retval the number of characters to the found char index.
  537. retval.ncpy(val, idxval + 1);
  538. {
  539. StringW testscope;
  540. // Copy into retval the number of characters to the found char index.
  541. testscope.ncpy(val, idxval + 1);
  542. }
  543. #if USE == FAST_METHODS
  544. size_t len = wcslen(val + idxval + 1);
  545. MEMCPY(val, val + idxval + 1, sizeof(wchar_t)*(len + 1));
  546. #elif USE == SAFE_METHODS
  547. // Copy from the found index downwards to save for this object
  548. StringW temp(val + idxval + 1);
  549. // And then copy into ourselves the tempspace.
  550. *this = temp;
  551. #endif
  552. return retval;
  553. }
  554. }
  555. // Same as split, except the find char is cut completely.
  556. StringW StringW::lSpliceChar(const wchar_t *findval)
  557. {
  558. if (val == NULL) return StringW();
  559. //CUT // Auto-scope reference allows us to avoid a copy.
  560. //CUT String & retval = lSplitChar(findval);
  561. //BU gcc doesn't agree with you and neither do I :/
  562. StringW retval = lSplitChar(findval);
  563. // We need to strip the findval char, which is the end char.
  564. size_t end = retval.len();
  565. size_t num = wcslen(findval);
  566. if (end)
  567. {
  568. for (size_t i = 0; i != num; i++)
  569. {
  570. if (retval.val[end - 1] == findval[i])
  571. {
  572. retval.val[end - 1] = 0;
  573. }
  574. }
  575. }
  576. return retval;
  577. }
  578. StringW StringW::rSpliceChar(const wchar_t *findval)
  579. {
  580. if (val == NULL) return StringW();
  581. //CUT // Auto-scope reference allows us to avoid a copy.
  582. //CUT String & retval = rSplitChar(findval);
  583. //BU gcc doesn't agree with you and neither do I :/
  584. StringW retval = rSplitChar(findval);
  585. // We need to strip the findval char, which is the first char.
  586. // (But we still check for empty string:)
  587. size_t end = retval.len();
  588. size_t num = wcslen(findval);
  589. if (end)
  590. {
  591. for (size_t i = 0; i != num; i++)
  592. {
  593. if (retval.val[0] == findval[i])
  594. {
  595. #if USE == FAST_METHODS
  596. size_t len = wcslen(retval.val + 1);
  597. MEMCPY(retval.val, retval.val + 1, sizeof(wchar_t)*(len + 1));
  598. #elif USE == SAFE_METHODS
  599. StringW temp(retval.val + 1);
  600. retval = temp;
  601. #endif
  602. return retval;
  603. }
  604. }
  605. }
  606. return retval;
  607. }
  608. void StringW::FixSlashes()
  609. {
  610. if (val)
  611. {
  612. wchar_t *itr = val;
  613. while (itr && *itr)
  614. {
  615. if (*itr == '\\' || *itr == '/')
  616. *itr = Wasabi::Std::dirChar();
  617. #ifdef _WIN32
  618. itr = CharNextW(itr);
  619. #else
  620. itr++;
  621. #endif
  622. }
  623. }
  624. }
  625. /* ------------ */
  626. StringPrintfW::StringPrintfW(const wchar_t *format, ...)
  627. {
  628. va_list args;
  629. va_start (args, format);
  630. va_sprintf(format, args);
  631. va_end(args);
  632. }
  633. StringPrintfW::StringPrintfW(int value)
  634. {
  635. *this += value;
  636. }
  637. StringPrintfW::StringPrintfW(double value)
  638. {
  639. // TODO: review to use locale variant...
  640. wchar_t* locale = _wcsdup(_wsetlocale(LC_NUMERIC, NULL));
  641. _wsetlocale(LC_NUMERIC, L"C");
  642. *this += StringPrintfW(L"%f", value);
  643. if (locale)
  644. {
  645. _wsetlocale(LC_NUMERIC, locale);
  646. free(locale);
  647. }
  648. }
  649. StringPrintfW::StringPrintfW(GUID g)
  650. {
  651. wchar_t splab[nsGUID::GUID_STRLEN + 1] = {0};
  652. nsGUID::toCharW(g, splab);
  653. cat(splab);
  654. }
  655. /* ------------ */
  656. int StringWComparator::compareItem(StringW *p1, StringW* p2)
  657. {
  658. return wcscmp(p1->getValue(), p2->getValue());
  659. }
  660. int StringWComparator::compareAttrib(const wchar_t *attrib, StringW *item)
  661. {
  662. return wcscmp(attrib, item->getValue());
  663. }
  664. /* ------------ */
  665. _DebugStringW::_DebugStringW(const wchar_t *format, ...)
  666. {
  667. va_list args;
  668. va_start (args, format);
  669. va_sprintf(format, args);
  670. va_end(args);
  671. debugPrint();
  672. }
  673. void _DebugStringW::debugPrint()
  674. {
  675. #ifdef _WIN32
  676. OutputDebugStringW(getValue());
  677. if (lastChar() != L'\n') OutputDebugStringW(L"\n");
  678. #else
  679. #warning port me
  680. #endif
  681. }
  682. StringPathCombine::StringPathCombine(const wchar_t *path, const wchar_t *filename)
  683. {
  684. #ifdef _WIN32
  685. wchar_t temp[MAX_PATH] = {0};
  686. PathCombineW(temp, path, filename);
  687. setValue(temp);
  688. #else
  689. setValue(path);
  690. AppendPath(filename);
  691. #endif
  692. }
  693. // StringW operators using StringPrintf
  694. const wchar_t *StringW::operator +=(wchar_t value)
  695. {
  696. wchar_t add[2]={value, 0};
  697. return cat(add);
  698. // the "Fast" methods and the Printf be
  699. // built off of that?
  700. }
  701. const wchar_t *StringW::operator +=(int value)
  702. {
  703. wchar_t num[64] = {0};
  704. #ifdef _WIN32
  705. _itow(value, num, 10);
  706. #else
  707. WCSNPRINTF(num, 64, L"%d", value);
  708. #endif
  709. return cat(num);
  710. }
  711. const wchar_t *StringW::operator +=(GUID guid)
  712. {
  713. wchar_t guidstr[64] = {0};
  714. nsGUID::toCharW(guid, guidstr);
  715. return cat(guidstr);
  716. }