]>
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 | #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 | // FIXME-VC6: VC 6.0 stl does not support all types of assign functions | |
204 | #ifdef __VISUALC6__ | |
205 | wxUString &assign( wxChar32 ch ) | |
206 | { | |
207 | wxChar32 chh[1]; | |
208 | chh[0] = ch; | |
209 | std::basic_string<wxChar32> *base = this; | |
210 | return (wxUString &)base->assign(chh); | |
211 | } | |
212 | ||
213 | wxUString &assign( size_type n, wxChar32 ch ) | |
214 | { | |
215 | wxU32CharBuffer buffer(n); | |
216 | wxChar32 *p = buffer.data(); | |
217 | size_type i; | |
218 | for (i = 0; i < n; i++) | |
219 | { | |
220 | *p = ch; | |
221 | p++; | |
222 | } | |
223 | ||
224 | std::basic_string<wxChar32> *base = this; | |
225 | return (wxUString &)base->assign(buffer.data()); | |
226 | } | |
227 | #else | |
228 | wxUString &assign( wxChar32 ch ) | |
229 | { | |
230 | std::basic_string<wxChar32> *base = this; | |
231 | return (wxUString &) base->assign( (size_type) 1, ch ); | |
232 | } | |
233 | ||
234 | wxUString &assign( size_type n, wxChar32 ch ) | |
235 | { | |
236 | std::basic_string<wxChar32> *base = this; | |
237 | return (wxUString &) base->assign( n, ch ); | |
238 | } | |
239 | #endif // __VISUALC6__ | |
240 | ||
241 | wxUString &assign( const wxScopedU32CharBuffer &buf ) | |
242 | { | |
243 | return assign( buf.data() ); | |
244 | } | |
245 | ||
246 | wxUString &assign( const char *str ) | |
247 | { | |
248 | return assignFromCString( str ); | |
249 | } | |
250 | ||
251 | wxUString &assign( const wxScopedCharBuffer &buf ) | |
252 | { | |
253 | return assignFromCString( buf.data() ); | |
254 | } | |
255 | ||
256 | wxUString &assign( const char *str, const wxMBConv &conv ) | |
257 | { | |
258 | return assignFromCString( str, conv ); | |
259 | } | |
260 | ||
261 | wxUString &assign( const wxScopedCharBuffer &buf, const wxMBConv &conv ) | |
262 | { | |
263 | return assignFromCString( buf.data(), conv ); | |
264 | } | |
265 | ||
266 | wxUString &assign( const wxChar16 *str ) | |
267 | { | |
268 | return assignFromUTF16( str ); | |
269 | } | |
270 | ||
271 | wxUString &assign( const wxScopedU16CharBuffer &buf ) | |
272 | { | |
273 | return assignFromUTF16( buf.data() ); | |
274 | } | |
275 | ||
276 | wxUString &assign( const wxCStrData *cstr ) | |
277 | { | |
278 | #if SIZEOF_WCHAR_T == 2 | |
279 | return assignFromUTF16( cstr->AsWChar() ); | |
280 | #else | |
281 | return assign( cstr->AsWChar() ); | |
282 | #endif | |
283 | } | |
284 | ||
285 | wxUString &assign( const wxString &str ) | |
286 | { | |
287 | #if wxUSE_UNICODE_UTF8 | |
288 | return assignFromUTF8( str.wx_str() ); | |
289 | #else | |
290 | #if SIZEOF_WCHAR_T == 2 | |
291 | return assignFromUTF16( str.wc_str() ); | |
292 | #else | |
293 | return assign( str.wc_str() ); | |
294 | #endif | |
295 | #endif | |
296 | } | |
297 | ||
298 | wxUString &assign( char ch ) | |
299 | { | |
300 | char buf[2]; | |
301 | buf[0] = ch; | |
302 | buf[1] = 0; | |
303 | return assignFromCString( buf ); | |
304 | } | |
305 | ||
306 | wxUString &assign( size_type n, char ch ) | |
307 | { | |
308 | wxCharBuffer buffer(n); | |
309 | char *p = buffer.data(); | |
310 | size_type i; | |
311 | for (i = 0; i < n; i++) | |
312 | { | |
313 | *p = ch; | |
314 | p++; | |
315 | } | |
316 | return assignFromCString( buffer.data() ); | |
317 | } | |
318 | ||
319 | wxUString &assign( wxChar16 ch ) | |
320 | { | |
321 | wxChar16 buf[2]; | |
322 | buf[0] = ch; | |
323 | buf[1] = 0; | |
324 | return assignFromUTF16( buf ); | |
325 | } | |
326 | ||
327 | wxUString &assign( size_type n, wxChar16 ch ) | |
328 | { | |
329 | wxU16CharBuffer buffer(n); | |
330 | wxChar16 *p = buffer.data(); | |
331 | size_type i; | |
332 | for (i = 0; i < n; i++) | |
333 | { | |
334 | *p = ch; | |
335 | p++; | |
336 | } | |
337 | return assignFromUTF16( buffer.data() ); | |
338 | } | |
339 | ||
340 | wxUString &assign( wxUniChar ch ) | |
341 | { | |
342 | return assign( (wxChar32) ch.GetValue() ); | |
343 | } | |
344 | ||
345 | wxUString &assign( size_type n, wxUniChar ch ) | |
346 | { | |
347 | return assign( n, (wxChar32) ch.GetValue() ); | |
348 | } | |
349 | ||
350 | wxUString &assign( wxUniCharRef ch ) | |
351 | { | |
352 | return assign( (wxChar32) ch.GetValue() ); | |
353 | } | |
354 | ||
355 | wxUString &assign( size_type n, wxUniCharRef ch ) | |
356 | { | |
357 | return assign( n, (wxChar32) ch.GetValue() ); | |
358 | } | |
359 | ||
360 | // append [STL overload] | |
361 | ||
362 | wxUString &append( const wxUString &s ) | |
363 | { | |
364 | std::basic_string<wxChar32> *base = this; | |
365 | return (wxUString &) base->append( s ); | |
366 | } | |
367 | ||
368 | wxUString &append( const wxUString &s, size_type pos, size_type n ) | |
369 | { | |
370 | std::basic_string<wxChar32> *base = this; | |
371 | return (wxUString &) base->append( s, pos, n ); | |
372 | } | |
373 | ||
374 | wxUString &append( const wxChar32* s ) | |
375 | { | |
376 | std::basic_string<wxChar32> *base = this; | |
377 | return (wxUString &) base->append( s ); | |
378 | } | |
379 | ||
380 | wxUString &append( const wxChar32* s, size_type n ) | |
381 | { | |
382 | std::basic_string<wxChar32> *base = this; | |
383 | return (wxUString &) base->append( s, n ); | |
384 | } | |
385 | ||
386 | // FIXME-VC6: VC 6.0 stl does not support all types of append functions | |
387 | #ifdef __VISUALC6__ | |
388 | wxUString &append( size_type n, wxChar32 c ) | |
389 | { | |
390 | wxU32CharBuffer buffer(n); | |
391 | wxChar32 *p = buffer.data(); | |
392 | size_type i; | |
393 | for (i = 0; i < n; i++) | |
394 | { | |
395 | *p = c; | |
396 | p++; | |
397 | } | |
398 | ||
399 | std::basic_string<wxChar32> *base = this; | |
400 | return (wxUString &) base->append(buffer.data()); | |
401 | } | |
402 | #else | |
403 | wxUString &append( size_type n, wxChar32 c ) | |
404 | { | |
405 | std::basic_string<wxChar32> *base = this; | |
406 | return (wxUString &) base->append( n, c ); | |
407 | } | |
408 | #endif // __VISUALC6__ | |
409 | ||
410 | wxUString &append( wxChar32 c ) | |
411 | { | |
412 | std::basic_string<wxChar32> *base = this; | |
413 | return (wxUString &) base->append( 1, c ); | |
414 | } | |
415 | ||
416 | // append [wx overload] | |
417 | ||
418 | wxUString &append( const wxScopedU16CharBuffer &buf ) | |
419 | { | |
420 | return append( buf.data() ); | |
421 | } | |
422 | ||
423 | wxUString &append( const wxScopedU32CharBuffer &buf ) | |
424 | { | |
425 | return append( buf.data() ); | |
426 | } | |
427 | ||
428 | wxUString &append( const char *str ) | |
429 | { | |
430 | return append( wxUString( str ) ); | |
431 | } | |
432 | ||
433 | wxUString &append( const wxScopedCharBuffer &buf ) | |
434 | { | |
435 | return append( wxUString( buf ) ); | |
436 | } | |
437 | ||
438 | wxUString &append( const wxChar16 *str ) | |
439 | { | |
440 | return append( wxUString( str ) ); | |
441 | } | |
442 | ||
443 | wxUString &append( const wxString &str ) | |
444 | { | |
445 | return append( wxUString( str ) ); | |
446 | } | |
447 | ||
448 | wxUString &append( const wxCStrData *cstr ) | |
449 | { | |
450 | return append( wxUString( cstr ) ); | |
451 | } | |
452 | ||
453 | wxUString &append( char ch ) | |
454 | { | |
455 | char buf[2]; | |
456 | buf[0] = ch; | |
457 | buf[1] = 0; | |
458 | return append( buf ); | |
459 | } | |
460 | ||
461 | wxUString &append( wxChar16 ch ) | |
462 | { | |
463 | wxChar16 buf[2]; | |
464 | buf[0] = ch; | |
465 | buf[1] = 0; | |
466 | return append( buf ); | |
467 | } | |
468 | ||
469 | wxUString &append( wxUniChar ch ) | |
470 | { | |
471 | return append( (size_type) 1, (wxChar32) ch.GetValue() ); | |
472 | } | |
473 | ||
474 | wxUString &append( wxUniCharRef ch ) | |
475 | { | |
476 | return append( (size_type) 1, (wxChar32) ch.GetValue() ); | |
477 | } | |
478 | ||
479 | ||
480 | // insert [STL overloads] | |
481 | ||
482 | wxUString &insert( size_type pos, const wxUString &s ) | |
483 | { | |
484 | std::basic_string<wxChar32> *base = this; | |
485 | return (wxUString &) base->insert( pos, s ); | |
486 | } | |
487 | ||
488 | wxUString &insert( size_type pos, const wxUString &s, size_type pos1, size_type n ) | |
489 | { | |
490 | std::basic_string<wxChar32> *base = this; | |
491 | return (wxUString &) base->insert( pos, s, pos1, n ); | |
492 | } | |
493 | ||
494 | wxUString &insert( size_type pos, const wxChar32 *s ) | |
495 | { | |
496 | std::basic_string<wxChar32> *base = this; | |
497 | return (wxUString &) base->insert( pos, s ); | |
498 | } | |
499 | ||
500 | wxUString &insert( size_type pos, const wxChar32 *s, size_type n ) | |
501 | { | |
502 | std::basic_string<wxChar32> *base = this; | |
503 | return (wxUString &) base->insert( pos, s, n ); | |
504 | } | |
505 | ||
506 | wxUString &insert( size_type pos, size_type n, wxChar32 c ) | |
507 | { | |
508 | std::basic_string<wxChar32> *base = this; | |
509 | return (wxUString &) base->insert( pos, n, c ); | |
510 | } | |
511 | ||
512 | ||
513 | // insert [STL overloads] | |
514 | ||
515 | wxUString &insert( size_type n, const char *s ) | |
516 | { | |
517 | return insert( n, wxUString( s ) ); | |
518 | } | |
519 | ||
520 | wxUString &insert( size_type n, const wxChar16 *s ) | |
521 | { | |
522 | return insert( n, wxUString( s ) ); | |
523 | } | |
524 | ||
525 | wxUString &insert( size_type n, const wxScopedCharBuffer &buf ) | |
526 | { | |
527 | return insert( n, wxUString( buf ) ); | |
528 | } | |
529 | ||
530 | wxUString &insert( size_type n, const wxScopedU16CharBuffer &buf ) | |
531 | { | |
532 | return insert( n, wxUString( buf ) ); | |
533 | } | |
534 | ||
535 | wxUString &insert( size_type n, const wxScopedU32CharBuffer &buf ) | |
536 | { | |
537 | return insert( n, buf.data() ); | |
538 | } | |
539 | ||
540 | wxUString &insert( size_type n, const wxString &s ) | |
541 | { | |
542 | return insert( n, wxUString( s ) ); | |
543 | } | |
544 | ||
545 | wxUString &insert( size_type n, const wxCStrData *cstr ) | |
546 | { | |
547 | return insert( n, wxUString( cstr ) ); | |
548 | } | |
549 | ||
550 | wxUString &insert( size_type n, char ch ) | |
551 | { | |
552 | char buf[2]; | |
553 | buf[0] = ch; | |
554 | buf[1] = 0; | |
555 | return insert( n, buf ); | |
556 | } | |
557 | ||
558 | wxUString &insert( size_type n, wchar_t ch ) | |
559 | { | |
560 | wchar_t buf[2]; | |
561 | buf[0] = ch; | |
562 | buf[1] = 0; | |
563 | return insert( n, buf ); | |
564 | } | |
565 | ||
566 | // insert iterator | |
567 | ||
568 | iterator insert( iterator it, wxChar32 ch ) | |
569 | { | |
570 | std::basic_string<wxChar32> *base = this; | |
571 | return base->insert( it, ch ); | |
572 | } | |
573 | ||
574 | void insert(iterator it, const_iterator first, const_iterator last) | |
575 | { | |
576 | std::basic_string<wxChar32> *base = this; | |
577 | base->insert( it, first, last ); | |
578 | } | |
579 | ||
580 | ||
581 | // operator = | |
582 | wxUString& operator=(const wxUString& s) | |
583 | { return assign( s ); } | |
584 | wxUString& operator=(const wxString& s) | |
585 | { return assign( s ); } | |
586 | wxUString& operator=(const wxCStrData* s) | |
587 | { return assign( s ); } | |
588 | wxUString& operator=(const char *s) | |
589 | { return assign( s ); } | |
590 | wxUString& operator=(const wxChar16 *s) | |
591 | { return assign( s ); } | |
592 | wxUString& operator=(const wxChar32 *s) | |
593 | { return assign( s ); } | |
594 | wxUString& operator=(const wxScopedCharBuffer &s) | |
595 | { return assign( s ); } | |
596 | wxUString& operator=(const wxScopedU16CharBuffer &s) | |
597 | { return assign( s ); } | |
598 | wxUString& operator=(const wxScopedU32CharBuffer &s) | |
599 | { return assign( s ); } | |
600 | wxUString& operator=(const char ch) | |
601 | { return assign( ch ); } | |
602 | wxUString& operator=(const wxChar16 ch) | |
603 | { return assign( ch ); } | |
604 | wxUString& operator=(const wxChar32 ch) | |
605 | { return assign( ch ); } | |
606 | wxUString& operator=(const wxUniChar ch) | |
607 | { return assign( ch ); } | |
608 | wxUString& operator=(const wxUniCharRef ch) | |
609 | { return assign( ch ); } | |
610 | ||
611 | // operator += | |
612 | wxUString& operator+=(const wxUString& s) | |
613 | { return append( s ); } | |
614 | wxUString& operator+=(const wxString& s) | |
615 | { return append( s ); } | |
616 | wxUString& operator+=(const wxCStrData* s) | |
617 | { return append( s ); } | |
618 | wxUString& operator+=(const char *s) | |
619 | { return append( s ); } | |
620 | wxUString& operator+=(const wxChar16 *s) | |
621 | { return append( s ); } | |
622 | wxUString& operator+=(const wxChar32 *s) | |
623 | { return append( s ); } | |
624 | wxUString& operator+=(const wxScopedCharBuffer &s) | |
625 | { return append( s ); } | |
626 | wxUString& operator+=(const wxScopedU16CharBuffer &s) | |
627 | { return append( s ); } | |
628 | wxUString& operator+=(const wxScopedU32CharBuffer &s) | |
629 | { return append( s ); } | |
630 | wxUString& operator+=(const char ch) | |
631 | { return append( ch ); } | |
632 | wxUString& operator+=(const wxChar16 ch) | |
633 | { return append( ch ); } | |
634 | wxUString& operator+=(const wxChar32 ch) | |
635 | { return append( ch ); } | |
636 | wxUString& operator+=(const wxUniChar ch) | |
637 | { return append( ch ); } | |
638 | wxUString& operator+=(const wxUniCharRef ch) | |
639 | { return append( ch ); } | |
640 | ||
641 | }; | |
642 | ||
643 | #ifdef __VISUALC__ | |
644 | #pragma warning(pop) | |
645 | #endif | |
646 | ||
647 | inline wxUString operator+(const wxUString &s1, const wxUString &s2) | |
648 | { wxUString ret( s1 ); ret.append( s2 ); return ret; } | |
649 | inline wxUString operator+(const wxUString &s1, const char *s2) | |
650 | { return s1 + wxUString(s2); } | |
651 | inline wxUString operator+(const wxUString &s1, const wxString &s2) | |
652 | { return s1 + wxUString(s2); } | |
653 | inline wxUString operator+(const wxUString &s1, const wxCStrData *s2) | |
654 | { return s1 + wxUString(s2); } | |
655 | inline wxUString operator+(const wxUString &s1, const wxChar16* s2) | |
656 | { return s1 + wxUString(s2); } | |
657 | inline wxUString operator+(const wxUString &s1, const wxChar32 *s2) | |
658 | { return s1 + wxUString(s2); } | |
659 | inline wxUString operator+(const wxUString &s1, const wxScopedCharBuffer &s2) | |
660 | { return s1 + wxUString(s2); } | |
661 | inline wxUString operator+(const wxUString &s1, const wxScopedU16CharBuffer &s2) | |
662 | { return s1 + wxUString(s2); } | |
663 | inline wxUString operator+(const wxUString &s1, const wxScopedU32CharBuffer &s2) | |
664 | { return s1 + wxUString(s2); } | |
665 | inline wxUString operator+(const wxUString &s1, char s2) | |
666 | { return s1 + wxUString(s2); } | |
667 | inline wxUString operator+(const wxUString &s1, wxChar32 s2) | |
668 | { wxUString ret( s1 ); ret.append( s2 ); return ret; } | |
669 | inline wxUString operator+(const wxUString &s1, wxChar16 s2) | |
670 | { wxUString ret( s1 ); ret.append( (wxChar32) s2 ); return ret; } | |
671 | inline wxUString operator+(const wxUString &s1, wxUniChar s2) | |
672 | { wxUString ret( s1 ); ret.append( (wxChar32) s2.GetValue() ); return ret; } | |
673 | inline wxUString operator+(const wxUString &s1, wxUniCharRef s2) | |
674 | { wxUString ret( s1 ); ret.append( (wxChar32) s2.GetValue() ); return ret; } | |
675 | ||
676 | inline wxUString operator+(const char *s1, const wxUString &s2) | |
677 | { return wxUString(s1) + s2; } | |
678 | inline wxUString operator+(const wxString &s1, const wxUString &s2) | |
679 | { return wxUString(s1) + s2; } | |
680 | inline wxUString operator+(const wxCStrData *s1, const wxUString &s2) | |
681 | { return wxUString(s1) + s2; } | |
682 | inline wxUString operator+(const wxChar16* s1, const wxUString &s2) | |
683 | { return wxUString(s1) + s2; } | |
684 | inline wxUString operator+(const wxChar32 *s1, const wxUString &s2) | |
685 | { return wxUString(s1) + s2; } | |
686 | inline wxUString operator+(const wxScopedCharBuffer &s1, const wxUString &s2) | |
687 | { return wxUString(s1) + s2; } | |
688 | inline wxUString operator+(const wxScopedU16CharBuffer &s1, const wxUString &s2) | |
689 | { return wxUString(s1) + s2; } | |
690 | inline wxUString operator+(const wxScopedU32CharBuffer &s1, const wxUString &s2) | |
691 | { return wxUString(s1) + s2; } | |
692 | inline wxUString operator+(char s1, const wxUString &s2) | |
693 | { return wxUString(s1) + s2; } | |
694 | inline wxUString operator+(wxChar32 s1, const wxUString &s2 ) | |
695 | { return wxUString(s1) + s2; } | |
696 | inline wxUString operator+(wxChar16 s1, const wxUString &s2) | |
697 | { return wxUString(s1) + s2; } | |
698 | inline wxUString operator+(wxUniChar s1, const wxUString &s2) | |
699 | { return wxUString(s1) + s2; } | |
700 | inline wxUString operator+(wxUniCharRef s1, const wxUString &s2) | |
701 | { return wxUString(s1) + s2; } | |
702 | ||
703 | ||
704 | inline bool operator==(const wxUString& s1, const wxUString& s2) | |
705 | { return s1.compare( s2 ) == 0; } | |
706 | inline bool operator!=(const wxUString& s1, const wxUString& s2) | |
707 | { return s1.compare( s2 ) != 0; } | |
708 | inline bool operator< (const wxUString& s1, const wxUString& s2) | |
709 | { return s1.compare( s2 ) < 0; } | |
710 | inline bool operator> (const wxUString& s1, const wxUString& s2) | |
711 | { return s1.compare( s2 ) > 0; } | |
712 | inline bool operator<=(const wxUString& s1, const wxUString& s2) | |
713 | { return s1.compare( s2 ) <= 0; } | |
714 | inline bool operator>=(const wxUString& s1, const wxUString& s2) | |
715 | { return s1.compare( s2 ) >= 0; } | |
716 | ||
717 | #define wxUSTRING_COMP_OPERATORS( T ) \ | |
718 | inline bool operator==(const wxUString& s1, T s2) \ | |
719 | { return s1.compare( wxUString(s2) ) == 0; } \ | |
720 | inline bool operator!=(const wxUString& s1, T s2) \ | |
721 | { return s1.compare( wxUString(s2) ) != 0; } \ | |
722 | inline bool operator< (const wxUString& s1, T s2) \ | |
723 | { return s1.compare( wxUString(s2) ) < 0; } \ | |
724 | inline bool operator> (const wxUString& s1, T s2) \ | |
725 | { return s1.compare( wxUString(s2) ) > 0; } \ | |
726 | inline bool operator<=(const wxUString& s1, T s2) \ | |
727 | { return s1.compare( wxUString(s2) ) <= 0; } \ | |
728 | inline bool operator>=(const wxUString& s1, T s2) \ | |
729 | { return s1.compare( wxUString(s2) ) >= 0; } \ | |
730 | \ | |
731 | inline bool operator==(T s2, const wxUString& s1) \ | |
732 | { return s1.compare( wxUString(s2) ) == 0; } \ | |
733 | inline bool operator!=(T s2, const wxUString& s1) \ | |
734 | { return s1.compare( wxUString(s2) ) != 0; } \ | |
735 | inline bool operator< (T s2, const wxUString& s1) \ | |
736 | { return s1.compare( wxUString(s2) ) > 0; } \ | |
737 | inline bool operator> (T s2, const wxUString& s1) \ | |
738 | { return s1.compare( wxUString(s2) ) < 0; } \ | |
739 | inline bool operator<=(T s2, const wxUString& s1) \ | |
740 | { return s1.compare( wxUString(s2) ) >= 0; } \ | |
741 | inline bool operator>=(T s2, const wxUString& s1) \ | |
742 | { return s1.compare( wxUString(s2) ) <= 0; } | |
743 | ||
744 | wxUSTRING_COMP_OPERATORS( const wxString & ) | |
745 | wxUSTRING_COMP_OPERATORS( const char * ) | |
746 | wxUSTRING_COMP_OPERATORS( const wxChar16 * ) | |
747 | wxUSTRING_COMP_OPERATORS( const wxChar32 * ) | |
748 | wxUSTRING_COMP_OPERATORS( const wxScopedCharBuffer & ) | |
749 | wxUSTRING_COMP_OPERATORS( const wxScopedU16CharBuffer & ) | |
750 | wxUSTRING_COMP_OPERATORS( const wxScopedU32CharBuffer & ) | |
751 | wxUSTRING_COMP_OPERATORS( const wxCStrData * ) | |
752 | ||
753 | #endif // _WX_USTRING_H_ |