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