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