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