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