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