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