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