ustring.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749
  1. // Name: wx/ustring.h
  2. // Purpose: 32-bit string (UCS-4)
  3. // Author: Robert Roebling
  4. // Copyright: (c) Robert Roebling
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. #ifndef _WX_USTRING_H_
  8. #define _WX_USTRING_H_
  9. #include "wx/defs.h"
  10. #include "wx/string.h"
  11. #include <string>
  12. #if SIZEOF_WCHAR_T == 2
  13. typedef wxWCharBuffer wxU16CharBuffer;
  14. typedef wxScopedWCharBuffer wxScopedU16CharBuffer;
  15. #else
  16. typedef wxCharTypeBuffer<wxChar16> wxU16CharBuffer;
  17. typedef wxScopedCharTypeBuffer<wxChar16> wxScopedU16CharBuffer;
  18. #endif
  19. #if SIZEOF_WCHAR_T == 4
  20. typedef wxWCharBuffer wxU32CharBuffer;
  21. typedef wxScopedWCharBuffer wxScopedU32CharBuffer;
  22. #else
  23. typedef wxCharTypeBuffer<wxChar32> wxU32CharBuffer;
  24. typedef wxScopedCharTypeBuffer<wxChar32> wxScopedU32CharBuffer;
  25. #endif
  26. #ifdef __VISUALC__
  27. // "non dll-interface class 'std::basic_string<wxChar32>' used as base
  28. // interface for dll-interface class 'wxString'" -- this is OK in our case
  29. // (and warning is unavoidable anyhow)
  30. #pragma warning(push)
  31. #pragma warning(disable:4275)
  32. #endif
  33. class WXDLLIMPEXP_BASE wxUString: public std::basic_string<wxChar32>
  34. {
  35. public:
  36. wxUString() { }
  37. wxUString( const wxChar32 *str ) { assign(str); }
  38. wxUString( const wxScopedU32CharBuffer &buf ) { assign(buf); }
  39. wxUString( const char *str ) { assign(str); }
  40. wxUString( const wxScopedCharBuffer &buf ) { assign(buf); }
  41. wxUString( const char *str, const wxMBConv &conv ) { assign(str,conv); }
  42. wxUString( const wxScopedCharBuffer &buf, const wxMBConv &conv ) { assign(buf,conv); }
  43. wxUString( const wxChar16 *str ) { assign(str); }
  44. wxUString( const wxScopedU16CharBuffer &buf ) { assign(buf); }
  45. wxUString( const wxCStrData *cstr ) { assign(cstr); }
  46. wxUString( const wxString &str ) { assign(str); }
  47. wxUString( char ch ) { assign(ch); }
  48. wxUString( wxChar16 ch ) { assign(ch); }
  49. wxUString( wxChar32 ch ) { assign(ch); }
  50. wxUString( wxUniChar ch ) { assign(ch); }
  51. wxUString( wxUniCharRef ch ) { assign(ch); }
  52. wxUString( size_type n, char ch ) { assign(n,ch); }
  53. wxUString( size_type n, wxChar16 ch ) { assign(n,ch); }
  54. wxUString( size_type n, wxChar32 ch ) { assign(n,ch); }
  55. wxUString( size_type n, wxUniChar ch ) { assign(n,ch); }
  56. wxUString( size_type n, wxUniCharRef ch ) { assign(n,ch); }
  57. // static construction
  58. static wxUString FromAscii( const char *str, size_type n )
  59. {
  60. wxUString ret;
  61. ret.assignFromAscii( str, n );
  62. return ret;
  63. }
  64. static wxUString FromAscii( const char *str )
  65. {
  66. wxUString ret;
  67. ret.assignFromAscii( str );
  68. return ret;
  69. }
  70. static wxUString FromUTF8( const char *str, size_type n )
  71. {
  72. wxUString ret;
  73. ret.assignFromUTF8( str, n );
  74. return ret;
  75. }
  76. static wxUString FromUTF8( const char *str )
  77. {
  78. wxUString ret;
  79. ret.assignFromUTF8( str );
  80. return ret;
  81. }
  82. static wxUString FromUTF16( const wxChar16 *str, size_type n )
  83. {
  84. wxUString ret;
  85. ret.assignFromUTF16( str, n );
  86. return ret;
  87. }
  88. static wxUString FromUTF16( const wxChar16 *str )
  89. {
  90. wxUString ret;
  91. ret.assignFromUTF16( str );
  92. return ret;
  93. }
  94. // assign from encoding
  95. wxUString &assignFromAscii( const char *str );
  96. wxUString &assignFromAscii( const char *str, size_type n );
  97. wxUString &assignFromUTF8( const char *str );
  98. wxUString &assignFromUTF8( const char *str, size_type n );
  99. wxUString &assignFromUTF16( const wxChar16* str );
  100. wxUString &assignFromUTF16( const wxChar16* str, size_type n );
  101. wxUString &assignFromCString( const char* str );
  102. wxUString &assignFromCString( const char* str, const wxMBConv &conv );
  103. // conversions
  104. wxScopedCharBuffer utf8_str() const;
  105. wxScopedU16CharBuffer utf16_str() const;
  106. #if SIZEOF_WCHAR_T == 2
  107. wxScopedWCharBuffer wc_str() const
  108. {
  109. return utf16_str();
  110. }
  111. #else
  112. wchar_t *wc_str() const
  113. {
  114. return (wchar_t*) c_str();
  115. }
  116. #endif
  117. operator wxString() const
  118. {
  119. #if wxUSE_UNICODE_UTF8
  120. return wxString::FromUTF8( utf8_str() );
  121. #else
  122. #if SIZEOF_WCHAR_T == 2
  123. return wxString( utf16_str() );
  124. #else
  125. return wxString( c_str() );
  126. #endif
  127. #endif
  128. }
  129. #if wxUSE_UNICODE_UTF8
  130. wxScopedCharBuffer wx_str()
  131. {
  132. return utf8_str();
  133. }
  134. #else
  135. #if SIZEOF_WCHAR_T == 2
  136. wxScopedWCharBuffer wx_str()
  137. {
  138. return utf16_str();
  139. }
  140. #else
  141. const wchar_t* wx_str()
  142. {
  143. return c_str();
  144. }
  145. #endif
  146. #endif
  147. // assign
  148. wxUString &assign( const wxChar32* str )
  149. {
  150. std::basic_string<wxChar32> *base = this;
  151. return (wxUString &) base->assign( str );
  152. }
  153. wxUString &assign( const wxChar32* str, size_type n )
  154. {
  155. std::basic_string<wxChar32> *base = this;
  156. return (wxUString &) base->assign( str, n );
  157. }
  158. wxUString &assign( const wxUString &str )
  159. {
  160. std::basic_string<wxChar32> *base = this;
  161. return (wxUString &) base->assign( str );
  162. }
  163. wxUString &assign( const wxUString &str, size_type pos, size_type n )
  164. {
  165. std::basic_string<wxChar32> *base = this;
  166. return (wxUString &) base->assign( str, pos, n );
  167. }
  168. // FIXME-VC6: VC 6.0 stl does not support all types of assign functions
  169. #ifdef __VISUALC6__
  170. wxUString &assign( wxChar32 ch )
  171. {
  172. wxChar32 chh[1];
  173. chh[0] = ch;
  174. std::basic_string<wxChar32> *base = this;
  175. return (wxUString &)base->assign(chh);
  176. }
  177. wxUString &assign( size_type n, wxChar32 ch )
  178. {
  179. wxU32CharBuffer buffer(n);
  180. wxChar32 *p = buffer.data();
  181. size_type i;
  182. for (i = 0; i < n; i++)
  183. {
  184. *p = ch;
  185. p++;
  186. }
  187. std::basic_string<wxChar32> *base = this;
  188. return (wxUString &)base->assign(buffer.data());
  189. }
  190. #else
  191. wxUString &assign( wxChar32 ch )
  192. {
  193. std::basic_string<wxChar32> *base = this;
  194. return (wxUString &) base->assign( (size_type) 1, ch );
  195. }
  196. wxUString &assign( size_type n, wxChar32 ch )
  197. {
  198. std::basic_string<wxChar32> *base = this;
  199. return (wxUString &) base->assign( n, ch );
  200. }
  201. #endif // __VISUALC6__
  202. wxUString &assign( const wxScopedU32CharBuffer &buf )
  203. {
  204. return assign( buf.data() );
  205. }
  206. wxUString &assign( const char *str )
  207. {
  208. return assignFromCString( str );
  209. }
  210. wxUString &assign( const wxScopedCharBuffer &buf )
  211. {
  212. return assignFromCString( buf.data() );
  213. }
  214. wxUString &assign( const char *str, const wxMBConv &conv )
  215. {
  216. return assignFromCString( str, conv );
  217. }
  218. wxUString &assign( const wxScopedCharBuffer &buf, const wxMBConv &conv )
  219. {
  220. return assignFromCString( buf.data(), conv );
  221. }
  222. wxUString &assign( const wxChar16 *str )
  223. {
  224. return assignFromUTF16( str );
  225. }
  226. wxUString &assign( const wxScopedU16CharBuffer &buf )
  227. {
  228. return assignFromUTF16( buf.data() );
  229. }
  230. wxUString &assign( const wxCStrData *cstr )
  231. {
  232. #if SIZEOF_WCHAR_T == 2
  233. return assignFromUTF16( cstr->AsWChar() );
  234. #else
  235. return assign( cstr->AsWChar() );
  236. #endif
  237. }
  238. wxUString &assign( const wxString &str )
  239. {
  240. #if wxUSE_UNICODE_UTF8
  241. return assignFromUTF8( str.wx_str() );
  242. #else
  243. #if SIZEOF_WCHAR_T == 2
  244. return assignFromUTF16( str.wc_str() );
  245. #else
  246. return assign( str.wc_str() );
  247. #endif
  248. #endif
  249. }
  250. wxUString &assign( char ch )
  251. {
  252. char buf[2];
  253. buf[0] = ch;
  254. buf[1] = 0;
  255. return assignFromCString( buf );
  256. }
  257. wxUString &assign( size_type n, char ch )
  258. {
  259. wxCharBuffer buffer(n);
  260. char *p = buffer.data();
  261. size_type i;
  262. for (i = 0; i < n; i++)
  263. {
  264. *p = ch;
  265. p++;
  266. }
  267. return assignFromCString( buffer.data() );
  268. }
  269. wxUString &assign( wxChar16 ch )
  270. {
  271. wxChar16 buf[2];
  272. buf[0] = ch;
  273. buf[1] = 0;
  274. return assignFromUTF16( buf );
  275. }
  276. wxUString &assign( size_type n, wxChar16 ch )
  277. {
  278. wxU16CharBuffer buffer(n);
  279. wxChar16 *p = buffer.data();
  280. size_type i;
  281. for (i = 0; i < n; i++)
  282. {
  283. *p = ch;
  284. p++;
  285. }
  286. return assignFromUTF16( buffer.data() );
  287. }
  288. wxUString &assign( wxUniChar ch )
  289. {
  290. return assign( (wxChar32) ch.GetValue() );
  291. }
  292. wxUString &assign( size_type n, wxUniChar ch )
  293. {
  294. return assign( n, (wxChar32) ch.GetValue() );
  295. }
  296. wxUString &assign( wxUniCharRef ch )
  297. {
  298. return assign( (wxChar32) ch.GetValue() );
  299. }
  300. wxUString &assign( size_type n, wxUniCharRef ch )
  301. {
  302. return assign( n, (wxChar32) ch.GetValue() );
  303. }
  304. // append [STL overload]
  305. wxUString &append( const wxUString &s )
  306. {
  307. std::basic_string<wxChar32> *base = this;
  308. return (wxUString &) base->append( s );
  309. }
  310. wxUString &append( const wxUString &s, size_type pos, size_type n )
  311. {
  312. std::basic_string<wxChar32> *base = this;
  313. return (wxUString &) base->append( s, pos, n );
  314. }
  315. wxUString &append( const wxChar32* s )
  316. {
  317. std::basic_string<wxChar32> *base = this;
  318. return (wxUString &) base->append( s );
  319. }
  320. wxUString &append( const wxChar32* s, size_type n )
  321. {
  322. std::basic_string<wxChar32> *base = this;
  323. return (wxUString &) base->append( s, n );
  324. }
  325. // FIXME-VC6: VC 6.0 stl does not support all types of append functions
  326. #ifdef __VISUALC6__
  327. wxUString &append( size_type n, wxChar32 c )
  328. {
  329. wxU32CharBuffer buffer(n);
  330. wxChar32 *p = buffer.data();
  331. size_type i;
  332. for (i = 0; i < n; i++)
  333. {
  334. *p = c;
  335. p++;
  336. }
  337. std::basic_string<wxChar32> *base = this;
  338. return (wxUString &) base->append(buffer.data());
  339. }
  340. #else
  341. wxUString &append( size_type n, wxChar32 c )
  342. {
  343. std::basic_string<wxChar32> *base = this;
  344. return (wxUString &) base->append( n, c );
  345. }
  346. #endif // __VISUALC6__
  347. wxUString &append( wxChar32 c )
  348. {
  349. std::basic_string<wxChar32> *base = this;
  350. return (wxUString &) base->append( 1, c );
  351. }
  352. // append [wx overload]
  353. wxUString &append( const wxScopedU16CharBuffer &buf )
  354. {
  355. return append( buf.data() );
  356. }
  357. wxUString &append( const wxScopedU32CharBuffer &buf )
  358. {
  359. return append( buf.data() );
  360. }
  361. wxUString &append( const char *str )
  362. {
  363. return append( wxUString( str ) );
  364. }
  365. wxUString &append( const wxScopedCharBuffer &buf )
  366. {
  367. return append( wxUString( buf ) );
  368. }
  369. wxUString &append( const wxChar16 *str )
  370. {
  371. return append( wxUString( str ) );
  372. }
  373. wxUString &append( const wxString &str )
  374. {
  375. return append( wxUString( str ) );
  376. }
  377. wxUString &append( const wxCStrData *cstr )
  378. {
  379. return append( wxUString( cstr ) );
  380. }
  381. wxUString &append( char ch )
  382. {
  383. char buf[2];
  384. buf[0] = ch;
  385. buf[1] = 0;
  386. return append( buf );
  387. }
  388. wxUString &append( wxChar16 ch )
  389. {
  390. wxChar16 buf[2];
  391. buf[0] = ch;
  392. buf[1] = 0;
  393. return append( buf );
  394. }
  395. wxUString &append( wxUniChar ch )
  396. {
  397. return append( (size_type) 1, (wxChar32) ch.GetValue() );
  398. }
  399. wxUString &append( wxUniCharRef ch )
  400. {
  401. return append( (size_type) 1, (wxChar32) ch.GetValue() );
  402. }
  403. // insert [STL overloads]
  404. wxUString &insert( size_type pos, const wxUString &s )
  405. {
  406. std::basic_string<wxChar32> *base = this;
  407. return (wxUString &) base->insert( pos, s );
  408. }
  409. wxUString &insert( size_type pos, const wxUString &s, size_type pos1, size_type n )
  410. {
  411. std::basic_string<wxChar32> *base = this;
  412. return (wxUString &) base->insert( pos, s, pos1, n );
  413. }
  414. wxUString &insert( size_type pos, const wxChar32 *s )
  415. {
  416. std::basic_string<wxChar32> *base = this;
  417. return (wxUString &) base->insert( pos, s );
  418. }
  419. wxUString &insert( size_type pos, const wxChar32 *s, size_type n )
  420. {
  421. std::basic_string<wxChar32> *base = this;
  422. return (wxUString &) base->insert( pos, s, n );
  423. }
  424. wxUString &insert( size_type pos, size_type n, wxChar32 c )
  425. {
  426. std::basic_string<wxChar32> *base = this;
  427. return (wxUString &) base->insert( pos, n, c );
  428. }
  429. // insert [STL overloads]
  430. wxUString &insert( size_type n, const char *s )
  431. {
  432. return insert( n, wxUString( s ) );
  433. }
  434. wxUString &insert( size_type n, const wxChar16 *s )
  435. {
  436. return insert( n, wxUString( s ) );
  437. }
  438. wxUString &insert( size_type n, const wxScopedCharBuffer &buf )
  439. {
  440. return insert( n, wxUString( buf ) );
  441. }
  442. wxUString &insert( size_type n, const wxScopedU16CharBuffer &buf )
  443. {
  444. return insert( n, wxUString( buf ) );
  445. }
  446. wxUString &insert( size_type n, const wxScopedU32CharBuffer &buf )
  447. {
  448. return insert( n, buf.data() );
  449. }
  450. wxUString &insert( size_type n, const wxString &s )
  451. {
  452. return insert( n, wxUString( s ) );
  453. }
  454. wxUString &insert( size_type n, const wxCStrData *cstr )
  455. {
  456. return insert( n, wxUString( cstr ) );
  457. }
  458. wxUString &insert( size_type n, char ch )
  459. {
  460. char buf[2];
  461. buf[0] = ch;
  462. buf[1] = 0;
  463. return insert( n, buf );
  464. }
  465. wxUString &insert( size_type n, wchar_t ch )
  466. {
  467. wchar_t buf[2];
  468. buf[0] = ch;
  469. buf[1] = 0;
  470. return insert( n, buf );
  471. }
  472. // insert iterator
  473. iterator insert( iterator it, wxChar32 ch )
  474. {
  475. std::basic_string<wxChar32> *base = this;
  476. return base->insert( it, ch );
  477. }
  478. void insert(iterator it, const_iterator first, const_iterator last)
  479. {
  480. std::basic_string<wxChar32> *base = this;
  481. base->insert( it, first, last );
  482. }
  483. // operator =
  484. wxUString& operator=(const wxString& s)
  485. { return assign( s ); }
  486. wxUString& operator=(const wxCStrData* s)
  487. { return assign( s ); }
  488. wxUString& operator=(const char *s)
  489. { return assign( s ); }
  490. wxUString& operator=(const wxChar16 *s)
  491. { return assign( s ); }
  492. wxUString& operator=(const wxChar32 *s)
  493. { return assign( s ); }
  494. wxUString& operator=(const wxScopedCharBuffer &s)
  495. { return assign( s ); }
  496. wxUString& operator=(const wxScopedU16CharBuffer &s)
  497. { return assign( s ); }
  498. wxUString& operator=(const wxScopedU32CharBuffer &s)
  499. { return assign( s ); }
  500. wxUString& operator=(const char ch)
  501. { return assign( ch ); }
  502. wxUString& operator=(const wxChar16 ch)
  503. { return assign( ch ); }
  504. wxUString& operator=(const wxChar32 ch)
  505. { return assign( ch ); }
  506. wxUString& operator=(const wxUniChar ch)
  507. { return assign( ch ); }
  508. wxUString& operator=(const wxUniCharRef ch)
  509. { return assign( ch ); }
  510. // operator +=
  511. wxUString& operator+=(const wxUString& s)
  512. { return append( s ); }
  513. wxUString& operator+=(const wxString& s)
  514. { return append( s ); }
  515. wxUString& operator+=(const wxCStrData* s)
  516. { return append( s ); }
  517. wxUString& operator+=(const char *s)
  518. { return append( s ); }
  519. wxUString& operator+=(const wxChar16 *s)
  520. { return append( s ); }
  521. wxUString& operator+=(const wxChar32 *s)
  522. { return append( s ); }
  523. wxUString& operator+=(const wxScopedCharBuffer &s)
  524. { return append( s ); }
  525. wxUString& operator+=(const wxScopedU16CharBuffer &s)
  526. { return append( s ); }
  527. wxUString& operator+=(const wxScopedU32CharBuffer &s)
  528. { return append( s ); }
  529. wxUString& operator+=(const char ch)
  530. { return append( ch ); }
  531. wxUString& operator+=(const wxChar16 ch)
  532. { return append( ch ); }
  533. wxUString& operator+=(const wxChar32 ch)
  534. { return append( ch ); }
  535. wxUString& operator+=(const wxUniChar ch)
  536. { return append( ch ); }
  537. wxUString& operator+=(const wxUniCharRef ch)
  538. { return append( ch ); }
  539. };
  540. #ifdef __VISUALC__
  541. #pragma warning(pop)
  542. #endif
  543. inline wxUString operator+(const wxUString &s1, const wxUString &s2)
  544. { wxUString ret( s1 ); ret.append( s2 ); return ret; }
  545. inline wxUString operator+(const wxUString &s1, const char *s2)
  546. { return s1 + wxUString(s2); }
  547. inline wxUString operator+(const wxUString &s1, const wxString &s2)
  548. { return s1 + wxUString(s2); }
  549. inline wxUString operator+(const wxUString &s1, const wxCStrData *s2)
  550. { return s1 + wxUString(s2); }
  551. inline wxUString operator+(const wxUString &s1, const wxChar16* s2)
  552. { return s1 + wxUString(s2); }
  553. inline wxUString operator+(const wxUString &s1, const wxChar32 *s2)
  554. { return s1 + wxUString(s2); }
  555. inline wxUString operator+(const wxUString &s1, const wxScopedCharBuffer &s2)
  556. { return s1 + wxUString(s2); }
  557. inline wxUString operator+(const wxUString &s1, const wxScopedU16CharBuffer &s2)
  558. { return s1 + wxUString(s2); }
  559. inline wxUString operator+(const wxUString &s1, const wxScopedU32CharBuffer &s2)
  560. { return s1 + wxUString(s2); }
  561. inline wxUString operator+(const wxUString &s1, char s2)
  562. { return s1 + wxUString(s2); }
  563. inline wxUString operator+(const wxUString &s1, wxChar32 s2)
  564. { wxUString ret( s1 ); ret.append( s2 ); return ret; }
  565. inline wxUString operator+(const wxUString &s1, wxChar16 s2)
  566. { wxUString ret( s1 ); ret.append( (wxChar32) s2 ); return ret; }
  567. inline wxUString operator+(const wxUString &s1, wxUniChar s2)
  568. { wxUString ret( s1 ); ret.append( (wxChar32) s2.GetValue() ); return ret; }
  569. inline wxUString operator+(const wxUString &s1, wxUniCharRef s2)
  570. { wxUString ret( s1 ); ret.append( (wxChar32) s2.GetValue() ); return ret; }
  571. inline wxUString operator+(const char *s1, const wxUString &s2)
  572. { return wxUString(s1) + s2; }
  573. inline wxUString operator+(const wxString &s1, const wxUString &s2)
  574. { return wxUString(s1) + s2; }
  575. inline wxUString operator+(const wxCStrData *s1, const wxUString &s2)
  576. { return wxUString(s1) + s2; }
  577. inline wxUString operator+(const wxChar16* s1, const wxUString &s2)
  578. { return wxUString(s1) + s2; }
  579. inline wxUString operator+(const wxChar32 *s1, const wxUString &s2)
  580. { return wxUString(s1) + s2; }
  581. inline wxUString operator+(const wxScopedCharBuffer &s1, const wxUString &s2)
  582. { return wxUString(s1) + s2; }
  583. inline wxUString operator+(const wxScopedU16CharBuffer &s1, const wxUString &s2)
  584. { return wxUString(s1) + s2; }
  585. inline wxUString operator+(const wxScopedU32CharBuffer &s1, const wxUString &s2)
  586. { return wxUString(s1) + s2; }
  587. inline wxUString operator+(char s1, const wxUString &s2)
  588. { return wxUString(s1) + s2; }
  589. inline wxUString operator+(wxChar32 s1, const wxUString &s2 )
  590. { return wxUString(s1) + s2; }
  591. inline wxUString operator+(wxChar16 s1, const wxUString &s2)
  592. { return wxUString(s1) + s2; }
  593. inline wxUString operator+(wxUniChar s1, const wxUString &s2)
  594. { return wxUString(s1) + s2; }
  595. inline wxUString operator+(wxUniCharRef s1, const wxUString &s2)
  596. { return wxUString(s1) + s2; }
  597. inline bool operator==(const wxUString& s1, const wxUString& s2)
  598. { return s1.compare( s2 ) == 0; }
  599. inline bool operator!=(const wxUString& s1, const wxUString& s2)
  600. { return s1.compare( s2 ) != 0; }
  601. inline bool operator< (const wxUString& s1, const wxUString& s2)
  602. { return s1.compare( s2 ) < 0; }
  603. inline bool operator> (const wxUString& s1, const wxUString& s2)
  604. { return s1.compare( s2 ) > 0; }
  605. inline bool operator<=(const wxUString& s1, const wxUString& s2)
  606. { return s1.compare( s2 ) <= 0; }
  607. inline bool operator>=(const wxUString& s1, const wxUString& s2)
  608. { return s1.compare( s2 ) >= 0; }
  609. #define wxUSTRING_COMP_OPERATORS( T ) \
  610. inline bool operator==(const wxUString& s1, T s2) \
  611. { return s1.compare( wxUString(s2) ) == 0; } \
  612. inline bool operator!=(const wxUString& s1, T s2) \
  613. { return s1.compare( wxUString(s2) ) != 0; } \
  614. inline bool operator< (const wxUString& s1, T s2) \
  615. { return s1.compare( wxUString(s2) ) < 0; } \
  616. inline bool operator> (const wxUString& s1, T s2) \
  617. { return s1.compare( wxUString(s2) ) > 0; } \
  618. inline bool operator<=(const wxUString& s1, T s2) \
  619. { return s1.compare( wxUString(s2) ) <= 0; } \
  620. inline bool operator>=(const wxUString& s1, T s2) \
  621. { return s1.compare( wxUString(s2) ) >= 0; } \
  622. \
  623. inline bool operator==(T s2, const wxUString& s1) \
  624. { return s1.compare( wxUString(s2) ) == 0; } \
  625. inline bool operator!=(T s2, const wxUString& s1) \
  626. { return s1.compare( wxUString(s2) ) != 0; } \
  627. inline bool operator< (T s2, const wxUString& s1) \
  628. { return s1.compare( wxUString(s2) ) > 0; } \
  629. inline bool operator> (T s2, const wxUString& s1) \
  630. { return s1.compare( wxUString(s2) ) < 0; } \
  631. inline bool operator<=(T s2, const wxUString& s1) \
  632. { return s1.compare( wxUString(s2) ) >= 0; } \
  633. inline bool operator>=(T s2, const wxUString& s1) \
  634. { return s1.compare( wxUString(s2) ) <= 0; }
  635. wxUSTRING_COMP_OPERATORS( const wxString & )
  636. wxUSTRING_COMP_OPERATORS( const char * )
  637. wxUSTRING_COMP_OPERATORS( const wxChar16 * )
  638. wxUSTRING_COMP_OPERATORS( const wxChar32 * )
  639. wxUSTRING_COMP_OPERATORS( const wxScopedCharBuffer & )
  640. wxUSTRING_COMP_OPERATORS( const wxScopedU16CharBuffer & )
  641. wxUSTRING_COMP_OPERATORS( const wxScopedU32CharBuffer & )
  642. wxUSTRING_COMP_OPERATORS( const wxCStrData * )
  643. #endif // _WX_USTRING_H_