~ubuntu-branches/ubuntu/vivid/mygui/vivid

« back to all changes in this revision

Viewing changes to MyGUIEngine/include/MyGUI_UString.h

  • Committer: Package Import Robot
  • Author(s): Scott Howard, Bret Curtis, Scott Howard
  • Date: 2014-09-18 17:57:48 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20140918175748-dd8va78mvpw1jbes
Tags: 3.2.1-1
[ Bret Curtis ]
* Updated license for majority of files from LGPL to Expat (MIT)

[ Scott Howard ]
* New upstream release
* Updated patch to add build option for system GLEW libraries
* All patches accepted upstream except shared_libraries.patch
* Bumped SONAME due to dropped symbols, updated *.symbols and package
  names
* Updated license of debian/* to Expat with permission of all authors
* Don't install Doxygen autogenerated md5 and map files (thanks
  lintian)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Modified from OpenGUI under lenient license
2
 
// Original copyright details and licensing below:
3
 
// OpenGUI (http://opengui.sourceforge.net)
4
 
// This source code is released under the BSD License
5
 
 
6
 
// Permission is given to the MyGUI project to use the contents of file within its
7
 
// source and binary applications, as well as any derivative works, in accordance
8
 
// with the terms of any license under which MyGUI is or will be distributed.
9
 
//
10
 
// MyGUI may relicense its copy of this file, as well as any OpenGUI released updates
11
 
// to this file, under any terms that it deems fit, and is not required to maintain
12
 
// the original BSD licensing terms of this file, however OpenGUI retains the right
13
 
// to present its copy of this file under the terms of any license under which
14
 
// OpenGUI is distributed.
15
 
//
16
 
// MyGUI is not required to release to OpenGUI any future changes that it makes to
17
 
// this file, and understands and agrees that any such changes that are released
18
 
// back to OpenGUI will become available under the terms of any license under which
19
 
// OpenGUI is distributed.
20
 
//
21
 
// For brevity, this permission text may be removed from this file if desired.
22
 
// The original record kept within the SourceForge (http://sourceforge.net/) tracker
23
 
// is sufficient.
24
 
//
25
 
// - Eric Shorkey (zero/zeroskill) <opengui@rightbracket.com> [January 20th, 2007]
26
 
 
27
 
#ifndef __MYGUI_U_STRING_H__
28
 
#define __MYGUI_U_STRING_H__
29
 
 
30
 
 
31
 
#include "MyGUI_Prerequest.h"
32
 
#include "MyGUI_Types.h"
33
 
 
34
 
// these are explained later
35
 
#include <iterator>
36
 
#include <string>
37
 
#include <stdexcept>
38
 
 
39
 
#if MYGUI_COMPILER == MYGUI_COMPILER_MSVC
40
 
// disable: warning C4275: non dll-interface class '***' used as base for dll-interface clas '***'
41
 
#       pragma warning (disable : 4275)
42
 
#endif
43
 
 
44
 
// Workaround for VC7:
45
 
//      when build with /MD or /MDd, VC7 have both std::basic_string<unsigned short> and
46
 
// basic_string<__wchar_t> instantiated in msvcprt[d].lib/MSVCP71[D].dll, but the header
47
 
// files tells compiler that only one of them is over there (based on /Zc:wchar_t compile
48
 
// option). And since this file used both of them, causing compiler instantiating another
49
 
// one in user object code, which lead to duplicate symbols with msvcprt.lib/MSVCP71[D].dll.
50
 
//
51
 
#if MYGUI_COMPILER == MYGUI_COMPILER_MSVC && (1300 <= MYGUI_COMP_VER && MYGUI_COMP_VER <= 1310)
52
 
 
53
 
# if defined(_DLL_CPPLIB)
54
 
 
55
 
namespace std
56
 
{
57
 
    template class _CRTIMP2 basic_string<unsigned short, char_traits<unsigned short>,
58
 
            allocator<unsigned short> >;
59
 
 
60
 
    template class _CRTIMP2 basic_string<__wchar_t, char_traits<__wchar_t>,
61
 
            allocator<__wchar_t> >;
62
 
}
63
 
 
64
 
# endif // defined(_DLL_CPPLIB)
65
 
 
66
 
#endif  // MYGUI_COMPILER == MYGUI_COMPILER_MSVC && MYGUI_COMP_VER == 1300
67
 
 
68
 
 
69
 
namespace MyGUI
70
 
{
71
 
 
72
 
        /* READ THIS NOTICE BEFORE USING IN YOUR OWN APPLICATIONS
73
 
        =NOTICE=
74
 
        This class is not a complete Unicode solution. It purposefully does not
75
 
        provide certain functionality, such as proper lexical sorting for
76
 
        Unicode values. It does provide comparison operators for the sole purpose
77
 
        of using UString as an index with std::map and other operator< sorted
78
 
        containers, but it should NOT be relied upon for meaningful lexical
79
 
        operations, such as alphabetical sorts. If you need this type of
80
 
        functionality, look into using ICU instead (http://icu.sourceforge.net/).
81
 
 
82
 
        =REQUIREMENTS=
83
 
        There are a few requirements for proper operation. They are fairly small,
84
 
        and shouldn't restrict usage on any reasonable target.
85
 
        * Compiler must support unsigned 16-bit integer types
86
 
        * Compiler must support signed 32-bit integer types
87
 
        * wchar_t must be either UTF-16 or UTF-32 encoding, and specified as such
88
 
            using the WCHAR_UTF16 macro as outlined below.
89
 
        * You must include <iterator>, <string>, and <wchar>. Probably more, but
90
 
            these are the most obvious.
91
 
 
92
 
        =REQUIRED PREPROCESSOR MACROS=
93
 
        This class requires two preprocessor macros to be defined in order to
94
 
        work as advertised.
95
 
        INT32 - must be mapped to a signed 32 bit integer (ex. #define INT32 int)
96
 
        UINT16 - must be mapped to an unsigned 16 bit integer (ex. #define UINT32 unsigned short)
97
 
 
98
 
        Additionally, a third macro should be defined to control the evaluation of wchar_t:
99
 
        WCHAR_UTF16 - should be defined when wchar_t represents UTF-16 code points,
100
 
            such as in Windows. Otherwise it is assumed that wchar_t is a 32-bit
101
 
                integer representing UTF-32 code points.
102
 
        */
103
 
 
104
 
        // THIS IS A VERY BRIEF AUTO DETECTION. YOU MAY NEED TO TWEAK THIS
105
 
#ifdef __STDC_ISO_10646__
106
 
// for any compiler that provides this, wchar_t is guaranteed to hold any Unicode value with a single code point (32-bit or larger)
107
 
// so we can safely skip the rest of the testing
108
 
#else // #ifdef __STDC_ISO_10646__
109
 
#if defined( __WIN32__ ) || defined( _WIN32 )
110
 
#define WCHAR_UTF16 // All currently known Windows platforms utilize UTF-16 encoding in wchar_t
111
 
#else // #if defined( __WIN32__ ) || defined( _WIN32 )
112
 
#if MYGUI_COMPILER != MYGUI_COMPILER_GCCE
113
 
#if WCHAR_MAX <= 0xFFFF // this is a last resort fall back test; WCHAR_MAX is defined in <wchar.h>
114
 
#define WCHAR_UTF16 // best we can tell, wchar_t is not larger than 16-bit
115
 
#endif // #if WCHAR_MAX <= 0xFFFF
116
 
#endif
117
 
#endif // #if defined( __WIN32__ ) || defined( _WIN32 )
118
 
#endif // #ifdef __STDC_ISO_10646__
119
 
 
120
 
 
121
 
// MYGUI_IS_NATIVE_WCHAR_T means that wchar_t isn't a typedef of
122
 
// uint16_t or uint32_t.
123
 
#if MYGUI_COMPILER == MYGUI_COMPILER_MSVC
124
 
 
125
 
// Don't define wchar_t related functions since it'll duplicate
126
 
// with UString::code_point related functions when compile
127
 
// without /Zc:wchar_t, because in this case both of them are
128
 
// a typedef of uint16_t.
129
 
# if defined(_NATIVE_WCHAR_T_DEFINED)
130
 
#   define MYGUI_IS_NATIVE_WCHAR_T      1
131
 
# else
132
 
#   define MYGUI_IS_NATIVE_WCHAR_T      0
133
 
# endif
134
 
#elif MYGUI_PLATFORM == MYGUI_PLATFORM_SYMBIAN
135
 
#   define MYGUI_IS_NATIVE_WCHAR_T      0
136
 
#else   // MYGUI_COMPILER != MYGUI_COMPILER_MSVC
137
 
 
138
 
// Assumed wchar_t is natively for other compilers
139
 
#   define MYGUI_IS_NATIVE_WCHAR_T     1
140
 
 
141
 
#endif  // MYGUI_COMPILER == MYGUI_COMPILER_MSVC
142
 
 
143
 
        //! A UTF-16 string with implicit conversion to/from std::string and std::wstring
144
 
        /*! This class provides a complete 1 to 1 map of most std::string functions (at least to my
145
 
        knowledge). Implicit conversions allow this string class to work with all common C++ string
146
 
        formats, with specialty functions defined where implicit conversion would cause potential
147
 
        problems or is otherwise unavailable.
148
 
 
149
 
        Some additional functionality is present to assist in working with characters using the
150
 
        32-bit UTF-32 encoding. (Which is guaranteed to fit any Unicode character into a single
151
 
        code point.) \b Note: Reverse iterators do not have this functionality due to the
152
 
        ambiguity that surrounds working with UTF-16 in reverse. (Such as, where should an
153
 
        iterator point to represent the beginning of a surrogate pair?)
154
 
 
155
 
 
156
 
        \par Supported Input Types
157
 
        The supported string types for input, and their assumed encoding schemes, are:
158
 
        - std::string (UTF-8)
159
 
        - char* (UTF-8)
160
 
        - std::wstring (autodetected UTF-16 / UTF-32 based on compiler)
161
 
        - wchar_t* (autodetected UTF-16 / UTF-32 based on compiler)
162
 
 
163
 
 
164
 
        \see
165
 
        - For additional information on UTF-16 encoding: http://en.wikipedia.org/wiki/UTF-16
166
 
        - For additional information on UTF-8 encoding: http://en.wikipedia.org/wiki/UTF-8
167
 
        - For additional information on UTF-32 encoding: http://en.wikipedia.org/wiki/UTF-32
168
 
        */
169
 
        class MYGUI_EXPORT UString {
170
 
                // constants used in UTF-8 conversions
171
 
                static const unsigned char _lead1 = 0xC0;      //110xxxxx
172
 
                static const unsigned char _lead1_mask = 0x1F; //00011111
173
 
                static const unsigned char _lead2 = 0xE0;      //1110xxxx
174
 
                static const unsigned char _lead2_mask = 0x0F; //00001111
175
 
                static const unsigned char _lead3 = 0xF0;      //11110xxx
176
 
                static const unsigned char _lead3_mask = 0x07; //00000111
177
 
                static const unsigned char _lead4 = 0xF8;      //111110xx
178
 
                static const unsigned char _lead4_mask = 0x03; //00000011
179
 
                static const unsigned char _lead5 = 0xFC;      //1111110x
180
 
                static const unsigned char _lead5_mask = 0x01; //00000001
181
 
                static const unsigned char _cont = 0x80;       //10xxxxxx
182
 
                static const unsigned char _cont_mask = 0x3F;  //00111111
183
 
 
184
 
        public:
185
 
                //! size type used to indicate string size and character positions within the string
186
 
                typedef size_t size_type;
187
 
                //! the usual constant representing: not found, no limit, etc
188
 
                static const size_type npos = static_cast<size_type>(~0);
189
 
 
190
 
                //! a single 32-bit Unicode character
191
 
                typedef uint32 unicode_char;
192
 
 
193
 
                //! a single UTF-16 code point
194
 
                typedef uint16 code_point;
195
 
 
196
 
                //! value type typedef for use in iterators
197
 
                typedef code_point value_type;
198
 
 
199
 
                typedef std::basic_string<code_point> dstring; // data string
200
 
 
201
 
                //! string type used for returning UTF-32 formatted data
202
 
                typedef std::basic_string<unicode_char> utf32string;
203
 
 
204
 
                //! This exception is used when invalid data streams are encountered
205
 
        class MYGUI_EXPORT invalid_data: public std::runtime_error { /* i don't know why the beautifier is freaking out on this line */
206
 
                public:
207
 
                        //! constructor takes a string message that can be later retrieved by the what() function
208
 
                        explicit invalid_data( const std::string& _Message ): std::runtime_error( _Message ) {
209
 
                                /* The thing is, Bob, it's not that I'm lazy, it's that I just don't care. */
210
 
                        }
211
 
                };
212
 
 
213
 
                //#########################################################################
214
 
                //! base iterator class for UString
215
 
        class MYGUI_EXPORT _base_iterator: public std::iterator<std::random_access_iterator_tag, value_type> { /* i don't know why the beautifier is freaking out on this line */
216
 
                        friend class UString;
217
 
                protected:
218
 
                        _base_iterator();
219
 
 
220
 
                        void _seekFwd( size_type c );
221
 
                        void _seekRev( size_type c );
222
 
                        void _become( const _base_iterator& i );
223
 
                        bool _test_begin() const;
224
 
                        bool _test_end() const;
225
 
                        size_type _get_index() const;
226
 
                        void _jump_to( size_type index );
227
 
 
228
 
                        unicode_char _getCharacter() const;
229
 
                        int _setCharacter( unicode_char uc );
230
 
 
231
 
                        void _moveNext();
232
 
                        void _movePrev();
233
 
 
234
 
                        dstring::iterator mIter;
235
 
                        UString* mString;
236
 
                };
237
 
 
238
 
                //#########################################################################
239
 
                // FORWARD ITERATORS
240
 
                //#########################################################################
241
 
                class _const_fwd_iterator; // forward declaration
242
 
 
243
 
                //! forward iterator for UString
244
 
        class MYGUI_EXPORT _fwd_iterator: public _base_iterator { /* i don't know why the beautifier is freaking out on this line */
245
 
                        friend class _const_fwd_iterator;
246
 
                public:
247
 
                        _fwd_iterator();
248
 
                        _fwd_iterator( const _fwd_iterator& i );
249
 
 
250
 
                        //! pre-increment
251
 
                        _fwd_iterator& operator++();
252
 
                        //! post-increment
253
 
                        _fwd_iterator operator++( int );
254
 
 
255
 
                        //! pre-decrement
256
 
                        _fwd_iterator& operator--();
257
 
                        //! post-decrement
258
 
                        _fwd_iterator operator--( int );
259
 
 
260
 
                        //! addition operator
261
 
                        _fwd_iterator operator+( difference_type n );
262
 
                        //! subtraction operator
263
 
                        _fwd_iterator operator-( difference_type n );
264
 
 
265
 
                        //! addition assignment operator
266
 
                        _fwd_iterator& operator+=( difference_type n );
267
 
                        //! subtraction assignment operator
268
 
                        _fwd_iterator& operator-=( difference_type n );
269
 
 
270
 
                        //! dereference operator
271
 
                        value_type& operator*() const;
272
 
 
273
 
                        //! dereference at offset operator
274
 
                        value_type& operator[]( difference_type n ) const;
275
 
 
276
 
                        //! advances to the next Unicode character, honoring surrogate pairs in the UTF-16 stream
277
 
                        _fwd_iterator& moveNext();
278
 
                        //! rewinds to the previous Unicode character, honoring surrogate pairs in the UTF-16 stream
279
 
                        _fwd_iterator& movePrev();
280
 
                        //! Returns the Unicode value of the character at the current position (decodes surrogate pairs if needed)
281
 
                        unicode_char getCharacter() const;
282
 
                        //! Sets the Unicode value of the character at the current position (adding a surrogate pair if needed); returns the amount of string length change caused by the operation
283
 
                        int setCharacter( unicode_char uc );
284
 
                };
285
 
 
286
 
 
287
 
 
288
 
                //#########################################################################
289
 
                //! const forward iterator for UString
290
 
        class MYGUI_EXPORT _const_fwd_iterator: public _base_iterator { /* i don't know why the beautifier is freaking out on this line */
291
 
                public:
292
 
                        _const_fwd_iterator();
293
 
                        _const_fwd_iterator( const _const_fwd_iterator& i );
294
 
                        _const_fwd_iterator( const _fwd_iterator& i );
295
 
 
296
 
                        //! pre-increment
297
 
                        _const_fwd_iterator& operator++();
298
 
                        //! post-increment
299
 
                        _const_fwd_iterator operator++( int );
300
 
 
301
 
                        //! pre-decrement
302
 
                        _const_fwd_iterator& operator--();
303
 
                        //! post-decrement
304
 
                        _const_fwd_iterator operator--( int );
305
 
 
306
 
                        //! addition operator
307
 
                        _const_fwd_iterator operator+( difference_type n );
308
 
                        //! subtraction operator
309
 
                        _const_fwd_iterator operator-( difference_type n );
310
 
 
311
 
                        //! addition assignment operator
312
 
                        _const_fwd_iterator& operator+=( difference_type n );
313
 
                        //! subtraction assignment operator
314
 
                        _const_fwd_iterator& operator-=( difference_type n );
315
 
 
316
 
                        //! dereference operator
317
 
                        const value_type& operator*() const;
318
 
 
319
 
                        //! dereference at offset operator
320
 
                        const value_type& operator[]( difference_type n ) const;
321
 
 
322
 
                        //! advances to the next Unicode character, honoring surrogate pairs in the UTF-16 stream
323
 
                        _const_fwd_iterator& moveNext();
324
 
                        //! rewinds to the previous Unicode character, honoring surrogate pairs in the UTF-16 stream
325
 
                        _const_fwd_iterator& movePrev();
326
 
                        //! Returns the Unicode value of the character at the current position (decodes surrogate pairs if needed)
327
 
                        unicode_char getCharacter() const;
328
 
 
329
 
                        //! difference operator
330
 
                        friend size_type operator-( const _const_fwd_iterator& left, const _const_fwd_iterator& right );
331
 
                        //! equality operator
332
 
                        friend bool operator==( const _const_fwd_iterator& left, const _const_fwd_iterator& right );
333
 
                        //! inequality operator
334
 
                        friend bool operator!=( const _const_fwd_iterator& left, const _const_fwd_iterator& right );
335
 
                        //! less than
336
 
                        friend bool operator<( const _const_fwd_iterator& left, const _const_fwd_iterator& right );
337
 
                        //! less than or equal
338
 
                        friend bool operator<=( const _const_fwd_iterator& left, const _const_fwd_iterator& right );
339
 
                        //! greater than
340
 
                        friend bool operator>( const _const_fwd_iterator& left, const _const_fwd_iterator& right );
341
 
                        //! greater than or equal
342
 
                        friend bool operator>=( const _const_fwd_iterator& left, const _const_fwd_iterator& right );
343
 
 
344
 
                };
345
 
 
346
 
                //#########################################################################
347
 
                // REVERSE ITERATORS
348
 
                //#########################################################################
349
 
                class _const_rev_iterator; // forward declaration
350
 
                //! forward iterator for UString
351
 
        class MYGUI_EXPORT _rev_iterator: public _base_iterator { /* i don't know why the beautifier is freaking out on this line */
352
 
                        friend class _const_rev_iterator;
353
 
                public:
354
 
                        _rev_iterator();
355
 
                        _rev_iterator( const _rev_iterator& i );
356
 
 
357
 
                        //! pre-increment
358
 
                        _rev_iterator& operator++();
359
 
                        //! post-increment
360
 
                        _rev_iterator operator++( int );
361
 
 
362
 
                        //! pre-decrement
363
 
                        _rev_iterator& operator--();
364
 
                        //! post-decrement
365
 
                        _rev_iterator operator--( int );
366
 
 
367
 
                        //! addition operator
368
 
                        _rev_iterator operator+( difference_type n );
369
 
                        //! subtraction operator
370
 
                        _rev_iterator operator-( difference_type n );
371
 
 
372
 
                        //! addition assignment operator
373
 
                        _rev_iterator& operator+=( difference_type n );
374
 
                        //! subtraction assignment operator
375
 
                        _rev_iterator& operator-=( difference_type n );
376
 
 
377
 
                        //! dereference operator
378
 
                        value_type& operator*() const;
379
 
 
380
 
                        //! dereference at offset operator
381
 
                        value_type& operator[]( difference_type n ) const;
382
 
                };
383
 
                //#########################################################################
384
 
                //! const reverse iterator for UString
385
 
        class MYGUI_EXPORT _const_rev_iterator: public _base_iterator { /* i don't know why the beautifier is freaking out on this line */
386
 
                public:
387
 
                        _const_rev_iterator();
388
 
                        _const_rev_iterator( const _const_rev_iterator& i );
389
 
                        _const_rev_iterator( const _rev_iterator& i );
390
 
                        //! pre-increment
391
 
                        _const_rev_iterator& operator++();
392
 
                        //! post-increment
393
 
                        _const_rev_iterator operator++( int );
394
 
 
395
 
                        //! pre-decrement
396
 
                        _const_rev_iterator& operator--();
397
 
                        //! post-decrement
398
 
                        _const_rev_iterator operator--( int );
399
 
 
400
 
                        //! addition operator
401
 
                        _const_rev_iterator operator+( difference_type n );
402
 
                        //! subtraction operator
403
 
                        _const_rev_iterator operator-( difference_type n );
404
 
 
405
 
                        //! addition assignment operator
406
 
                        _const_rev_iterator& operator+=( difference_type n );
407
 
                        //! subtraction assignment operator
408
 
                        _const_rev_iterator& operator-=( difference_type n );
409
 
 
410
 
                        //! dereference operator
411
 
                        const value_type& operator*() const;
412
 
 
413
 
                        //! dereference at offset operator
414
 
                        const value_type& operator[]( difference_type n ) const;
415
 
 
416
 
                        //! difference operator
417
 
                        friend size_type operator-( const _const_rev_iterator& left, const _const_rev_iterator& right );
418
 
                        //! equality operator
419
 
                        friend bool operator==( const _const_rev_iterator& left, const _const_rev_iterator& right );
420
 
                        //! inequality operator
421
 
                        friend bool operator!=( const _const_rev_iterator& left, const _const_rev_iterator& right );
422
 
                        //! less than
423
 
                        friend bool operator<( const _const_rev_iterator& left, const _const_rev_iterator& right );
424
 
                        //! less than or equal
425
 
                        friend bool operator<=( const _const_rev_iterator& left, const _const_rev_iterator& right );
426
 
                        //! greater than
427
 
                        friend bool operator>( const _const_rev_iterator& left, const _const_rev_iterator& right );
428
 
                        //! greater than or equal
429
 
                        friend bool operator>=( const _const_rev_iterator& left, const _const_rev_iterator& right );
430
 
                };
431
 
                //#########################################################################
432
 
 
433
 
                typedef _fwd_iterator iterator;                     //!< iterator
434
 
                typedef _rev_iterator reverse_iterator;             //!< reverse iterator
435
 
                typedef _const_fwd_iterator const_iterator;         //!< const iterator
436
 
                typedef _const_rev_iterator const_reverse_iterator; //!< const reverse iterator
437
 
 
438
 
 
439
 
                //!\name Constructors/Destructor
440
 
                //@{
441
 
                //! default constructor, creates an empty string
442
 
                UString();
443
 
                //! copy constructor
444
 
                UString( const UString& copy );
445
 
                //! \a length copies of \a ch
446
 
                UString( size_type length, const code_point& ch );
447
 
                //! duplicate of nul-terminated sequence \a str
448
 
                UString( const code_point* str );
449
 
                //! duplicate of \a str, \a length code points long
450
 
                UString( const code_point* str, size_type length );
451
 
                //! substring of \a str starting at \a index and \a length code points long
452
 
                UString( const UString& str, size_type index, size_type length );
453
 
#if MYGUI_IS_NATIVE_WCHAR_T
454
 
                //! duplicate of nul-terminated \c wchar_t array
455
 
                UString( const wchar_t* w_str );
456
 
                //! duplicate of \a w_str, \a length characters long
457
 
                UString( const wchar_t* w_str, size_type length );
458
 
#endif
459
 
                //! duplicate of \a wstr
460
 
                UString( const std::wstring& wstr );
461
 
                //! duplicate of nul-terminated C-string \a c_str (UTF-8 encoding)
462
 
                UString( const char* c_str );
463
 
                //! duplicate of \a c_str, \a length characters long (UTF-8 encoding)
464
 
                UString( const char* c_str, size_type length );
465
 
                //! duplicate of \a str (UTF-8 encoding)
466
 
                UString( const std::string& str );
467
 
 
468
 
                //! destructor
469
 
                ~UString();
470
 
                //@}
471
 
 
472
 
                //////////////////////////////////////////////////////////////////////////
473
 
 
474
 
                //!\name Utility functions
475
 
                //@{
476
 
                //! Returns the number of code points in the current string
477
 
                size_type size() const;
478
 
                //! Returns the number of code points in the current string
479
 
                size_type length() const;
480
 
                //! Returns the number of Unicode characters in the string
481
 
                /*! Executes in linear time. */
482
 
                size_type length_Characters() const;
483
 
                //! returns the maximum number of UTF-16 code points that the string can hold
484
 
                size_type max_size() const;
485
 
                //! sets the capacity of the string to at least \a size code points
486
 
                void reserve( size_type size );
487
 
                //! changes the size of the string to \a size, filling in any new area with \a val
488
 
                void resize( size_type num, const code_point& val = 0 );
489
 
                //! exchanges the elements of the current string with those of \a from
490
 
                void swap( UString& from );
491
 
                //! returns \c true if the string has no elements, \c false otherwise
492
 
                bool empty() const;
493
 
                //! returns a pointer to the first character in the current string
494
 
                const code_point* c_str() const;
495
 
                //! returns a pointer to the first character in the current string
496
 
                const code_point* data() const;
497
 
                //! returns the number of elements that the string can hold before it will need to allocate more space
498
 
                size_type capacity() const;
499
 
                //! deletes all of the elements in the string
500
 
                void clear();
501
 
                //! returns a substring of the current string, starting at \a index, and \a num characters long.
502
 
                /*! If \a num is omitted, it will default to \c UString::npos, and the substr() function will simply return the remainder of the string starting at \a index. */
503
 
                UString substr( size_type index, size_type num = npos ) const;
504
 
                //! appends \a val to the end of the string
505
 
                void push_back( unicode_char val );
506
 
#if MYGUI_IS_NATIVE_WCHAR_T
507
 
                //! appends \a val to the end of the string
508
 
                void push_back( wchar_t val );
509
 
#endif
510
 
                //! appends \a val to the end of the string
511
 
                /*! This can be used to push surrogate pair code points, you'll just need to push them
512
 
                one after the other. */
513
 
                void push_back( code_point val );
514
 
                //! appends \a val to the end of the string
515
 
                /*! Limited to characters under the 127 value barrier. */
516
 
                void push_back( char val );
517
 
                //! returns \c true if the given Unicode character \a ch is in this string
518
 
                bool inString( unicode_char ch ) const;
519
 
                //@}
520
 
 
521
 
                //////////////////////////////////////////////////////////////////////////
522
 
 
523
 
                //!\name Stream variations
524
 
                //@{
525
 
                //! returns the current string in UTF-8 form within a std::string
526
 
                const std::string& asUTF8() const;
527
 
                //! returns the current string in UTF-8 form as a nul-terminated char array
528
 
                const char* asUTF8_c_str() const;
529
 
                //! returns the current string in UTF-32 form within a utf32string
530
 
                const utf32string& asUTF32() const;
531
 
                //! returns the current string in UTF-32 form as a nul-terminated unicode_char array
532
 
                const unicode_char* asUTF32_c_str() const;
533
 
                //! returns the current string in the native form of std::wstring
534
 
                const std::wstring& asWStr() const;
535
 
                //! returns the current string in the native form of a nul-terminated wchar_t array
536
 
                const wchar_t* asWStr_c_str() const;
537
 
                //@}
538
 
 
539
 
                //////////////////////////////////////////////////////////////////////////
540
 
 
541
 
                //!\name Single Character Access
542
 
                //@{
543
 
                //! returns a reference to the element in the string at index \c loc
544
 
                code_point& at( size_type loc );
545
 
                //! returns a reference to the element in the string at index \c loc
546
 
                const code_point& at( size_type loc ) const;
547
 
                //! returns the data point \a loc evaluated as a UTF-32 value
548
 
                /*! This function will will only properly decode surrogate pairs when \a loc points to the index
549
 
                of a lead code point that is followed by a trailing code point. Evaluating the trailing code point
550
 
                itself, or pointing to a code point that is a sentinel value (part of a broken pair) will return
551
 
                the value of just that code point (not a valid Unicode value, but useful as a sentinel value). */
552
 
                unicode_char getChar( size_type loc ) const;
553
 
                //! sets the value of the character at \a loc to the Unicode value \a ch (UTF-32)
554
 
                /*! Providing sentinel values (values between U+D800-U+DFFF) are accepted, but you should be aware
555
 
                that you can also unwittingly create a valid surrogate pair if you don't pay attention to what you
556
 
                are doing. \note This operation may also lengthen the string if a surrogate pair is needed to
557
 
                represent the value given, but one is not available to replace; or alternatively shorten the string
558
 
                if an existing surrogate pair is replaced with a character that is representable without a surrogate
559
 
                pair. The return value will signify any lengthening or shortening performed, returning 0 if no change
560
 
                was made, -1 if the string was shortened, or 1 if the string was lengthened. Any single call can
561
 
                only change the string length by + or - 1. */
562
 
                int setChar( size_type loc, unicode_char ch );
563
 
                //@}
564
 
 
565
 
                //////////////////////////////////////////////////////////////////////////
566
 
 
567
 
                //!\name iterator acquisition
568
 
                //@{
569
 
                //! returns an iterator to the first element of the string
570
 
                iterator begin();
571
 
                //! returns an iterator to the first element of the string
572
 
                const_iterator begin() const;
573
 
                //! returns an iterator just past the end of the string
574
 
                iterator end();
575
 
                //! returns an iterator just past the end of the string
576
 
                const_iterator end() const;
577
 
                //! returns a reverse iterator to the last element of the string
578
 
                reverse_iterator rbegin();
579
 
                //! returns a reverse iterator to the last element of the string
580
 
                const_reverse_iterator rbegin() const;
581
 
                //! returns a reverse iterator just past the beginning of the string
582
 
                reverse_iterator rend();
583
 
                //! returns a reverse iterator just past the beginning of the string
584
 
                const_reverse_iterator rend() const;
585
 
                //@}
586
 
 
587
 
                //////////////////////////////////////////////////////////////////////////
588
 
 
589
 
                //!\name assign
590
 
                //@{
591
 
                //! gives the current string the values from \a start to \a end
592
 
                UString& assign( iterator start, iterator end );
593
 
                //! assign \a str to the current string
594
 
                UString& assign( const UString& str );
595
 
                //! assign the nul-terminated \a str to the current string
596
 
                UString& assign( const code_point* str );
597
 
                //! assign the first \a num characters of \a str to the current string
598
 
                UString& assign( const code_point* str, size_type num );
599
 
                //! assign \a len entries from \a str to the current string, starting at \a index
600
 
                UString& assign( const UString& str, size_type index, size_type len );
601
 
                //! assign \a num copies of \a ch to the current string
602
 
                UString& assign( size_type num, const code_point& ch );
603
 
                //! assign \a wstr to the current string (\a wstr is treated as a UTF-16 stream)
604
 
                UString& assign( const std::wstring& wstr );
605
 
#if MYGUI_IS_NATIVE_WCHAR_T
606
 
                //! assign \a w_str to the current string
607
 
                UString& assign( const wchar_t* w_str );
608
 
                //! assign the first \a num characters of \a w_str to the current string
609
 
                UString& assign( const wchar_t* w_str, size_type num );
610
 
#endif
611
 
                //! assign \a str to the current string (\a str is treated as a UTF-8 stream)
612
 
                UString& assign( const std::string& str );
613
 
                //! assign \a c_str to the current string (\a c_str is treated as a UTF-8 stream)
614
 
                UString& assign( const char* c_str );
615
 
                //! assign the first \a num characters of \a c_str to the current string (\a c_str is treated as a UTF-8 stream)
616
 
                UString& assign( const char* c_str, size_type num );
617
 
                //@}
618
 
 
619
 
                //////////////////////////////////////////////////////////////////////////
620
 
 
621
 
                //!\name append
622
 
                //@{
623
 
                //! appends \a str on to the end of the current string
624
 
                UString& append( const UString& str );
625
 
                //! appends \a str on to the end of the current string
626
 
                UString& append( const code_point* str );
627
 
                //! appends a substring of \a str starting at \a index that is \a len characters long on to the end of the current string
628
 
                UString& append( const UString& str, size_type index, size_type len );
629
 
                //! appends \a num characters of \a str on to the end of the current string
630
 
                UString& append( const code_point* str, size_type num );
631
 
                //! appends \a num repetitions of \a ch on to the end of the current string
632
 
                UString& append( size_type num, code_point ch );
633
 
                //! appends the sequence denoted by \a start and \a end on to the end of the current string
634
 
                UString& append( iterator start, iterator end );
635
 
#if MYGUI_IS_NATIVE_WCHAR_T
636
 
                //! appends \a num characters of \a str on to the end of the current string
637
 
                UString& append( const wchar_t* w_str, size_type num );
638
 
                //! appends \a num repetitions of \a ch on to the end of the current string
639
 
                UString& append( size_type num, wchar_t ch );
640
 
#endif
641
 
                //! appends \a num characters of \a str on to the end of the current string  (UTF-8 encoding)
642
 
                UString& append( const char* c_str, size_type num );
643
 
                //! appends \a num repetitions of \a ch on to the end of the current string (Unicode values less than 128)
644
 
                UString& append( size_type num, char ch );
645
 
                //! appends \a num repetitions of \a ch on to the end of the current string (Full Unicode spectrum)
646
 
                UString& append( size_type num, unicode_char ch );
647
 
                //@}
648
 
 
649
 
                //////////////////////////////////////////////////////////////////////////
650
 
 
651
 
                //!\name insert
652
 
                //@{
653
 
                //! inserts \a ch before the code point denoted by \a i
654
 
                iterator insert( iterator i, const code_point& ch );
655
 
                //! inserts \a str into the current string, at location \a index
656
 
                UString& insert( size_type index, const UString& str );
657
 
                //! inserts \a str into the current string, at location \a index
658
 
                UString& insert( size_type index, const code_point* str ) {
659
 
                        mData.insert( index, str );
660
 
                        return *this;
661
 
                }
662
 
                //! inserts a substring of \a str (starting at \a index2 and \a num code points long) into the current string, at location \a index1
663
 
                UString& insert( size_type index1, const UString& str, size_type index2, size_type num );
664
 
                //! inserts the code points denoted by \a start and \a end into the current string, before the code point specified by \a i
665
 
                void insert( iterator i, iterator start, iterator end );
666
 
                //! inserts \a num code points of \a str into the current string, at location \a index
667
 
                UString& insert( size_type index, const code_point* str, size_type num );
668
 
#if MYGUI_IS_NATIVE_WCHAR_T
669
 
                //! inserts \a num code points of \a str into the current string, at location \a index
670
 
                UString& insert( size_type index, const wchar_t* w_str, size_type num );
671
 
#endif
672
 
                //! inserts \a num code points of \a str into the current string, at location \a index
673
 
                UString& insert( size_type index, const char* c_str, size_type num );
674
 
                //! inserts \a num copies of \a ch into the current string, at location \a index
675
 
                UString& insert( size_type index, size_type num, code_point ch );
676
 
#if MYGUI_IS_NATIVE_WCHAR_T
677
 
                //! inserts \a num copies of \a ch into the current string, at location \a index
678
 
                UString& insert( size_type index, size_type num, wchar_t ch );
679
 
#endif
680
 
                //! inserts \a num copies of \a ch into the current string, at location \a index
681
 
                UString& insert( size_type index, size_type num, char ch );
682
 
                //! inserts \a num copies of \a ch into the current string, at location \a index
683
 
                UString& insert( size_type index, size_type num, unicode_char ch );
684
 
                //! inserts \a num copies of \a ch into the current string, before the code point denoted by \a i
685
 
                void insert( iterator i, size_type num, const code_point& ch );
686
 
#if MYGUI_IS_NATIVE_WCHAR_T
687
 
                //! inserts \a num copies of \a ch into the current string, before the code point denoted by \a i
688
 
                void insert( iterator i, size_type num, const wchar_t& ch );
689
 
#endif
690
 
                //! inserts \a num copies of \a ch into the current string, before the code point denoted by \a i
691
 
                void insert( iterator i, size_type num, const char& ch );
692
 
                //! inserts \a num copies of \a ch into the current string, before the code point denoted by \a i
693
 
                void insert( iterator i, size_type num, const unicode_char& ch );
694
 
                //@}
695
 
 
696
 
                //////////////////////////////////////////////////////////////////////////
697
 
 
698
 
                //!\name erase
699
 
                //@{
700
 
                //! removes the code point pointed to by \a loc, returning an iterator to the next character
701
 
                iterator erase( iterator loc );
702
 
                //! removes the code points between \a start and \a end (including the one at \a start but not the one at \a end), returning an iterator to the code point after the last code point removed
703
 
                iterator erase( iterator start, iterator end );
704
 
                //! removes \a num code points from the current string, starting at \a index
705
 
                UString& erase( size_type index = 0, size_type num = npos );
706
 
                //@}
707
 
 
708
 
                //////////////////////////////////////////////////////////////////////////
709
 
 
710
 
                //!\name replace
711
 
                //@{
712
 
                //! replaces up to \a num1 code points of the current string (starting at \a index1) with \a str
713
 
                UString& replace( size_type index1, size_type num1, const UString& str );
714
 
                //! replaces up to \a num1 code points of the current string (starting at \a index1) with up to \a num2 code points from \a str
715
 
                UString& replace( size_type index1, size_type num1, const UString& str, size_type num2 );
716
 
                //! replaces up to \a num1 code points of the current string (starting at \a index1) with up to \a num2 code points from \a str beginning at \a index2
717
 
                UString& replace( size_type index1, size_type num1, const UString& str, size_type index2, size_type num2 );
718
 
                //! replaces code points in the current string from \a start to \a end with \a num code points from \a str
719
 
                UString& replace( iterator start, iterator end, const UString& str, size_type num = npos );
720
 
                //! replaces up to \a num1 code points in the current string (beginning at \a index) with \c num2 copies of \c ch
721
 
                UString& replace( size_type index, size_type num1, size_type num2, code_point ch );
722
 
                //! replaces the code points in the current string from \a start to \a end with \a num copies of \a ch
723
 
                UString& replace( iterator start, iterator end, size_type num, code_point ch );
724
 
                //@}
725
 
 
726
 
                //////////////////////////////////////////////////////////////////////////
727
 
 
728
 
                //!\name compare
729
 
                //@{
730
 
                //! compare \a str to the current string
731
 
                int compare( const UString& str ) const;
732
 
                //! compare \a str to the current string
733
 
                int compare( const code_point* str ) const;
734
 
                //! compare \a str to a substring of the current string, starting at \a index for \a length characters
735
 
                int compare( size_type index, size_type length, const UString& str ) const;
736
 
                //! compare a substring of \a str to a substring of the current string, where \a index2 and \a length2 refer to \a str and \a index and \a length refer to the current string
737
 
                int compare( size_type index, size_type length, const UString& str, size_type index2, size_type length2 ) const;
738
 
                //! compare a substring of \a str to a substring of the current string, where the substring of \a str begins at zero and is \a length2 characters long, and the substring of the current string begins at \a index and is \a length  characters long
739
 
                int compare( size_type index, size_type length, const code_point* str, size_type length2 ) const;
740
 
#if MYGUI_IS_NATIVE_WCHAR_T
741
 
                //! compare a substring of \a str to a substring of the current string, where the substring of \a str begins at zero and is \a length2 elements long, and the substring of the current string begins at \a index and is \a length characters long
742
 
                int compare( size_type index, size_type length, const wchar_t* w_str, size_type length2 ) const;
743
 
#endif
744
 
                //! compare a substring of \a str to a substring of the current string, where the substring of \a str begins at zero and is \a length2 <b>UTF-8 code points</b> long, and the substring of the current string begins at \a index and is \a length characters long
745
 
                int compare( size_type index, size_type length, const char* c_str, size_type length2 ) const;
746
 
                //@}
747
 
 
748
 
                //////////////////////////////////////////////////////////////////////////
749
 
 
750
 
                //!\name find & rfind
751
 
                //@{
752
 
                //! returns the index of the first occurrence of \a str within the current string, starting at \a index; returns \c UString::npos if nothing is found
753
 
                /*! \a str is a UTF-16 encoded string, but through implicit casting can also be a UTF-8 encoded string (const char* or std::string) */
754
 
                size_type find( const UString& str, size_type index = 0 ) const;
755
 
                //! returns the index of the first occurrence of \a str within the current string and within \a length code points, starting at \a index; returns \c UString::npos if nothing is found
756
 
                /*! \a cp_str is a UTF-16 encoded string */
757
 
                size_type find( const code_point* cp_str, size_type index, size_type length ) const;
758
 
                //! returns the index of the first occurrence of \a str within the current string and within \a length code points, starting at \a index; returns \c UString::npos if nothing is found
759
 
                /*! \a cp_str is a UTF-8 encoded string */
760
 
                size_type find( const char* c_str, size_type index, size_type length ) const;
761
 
#if MYGUI_IS_NATIVE_WCHAR_T
762
 
                //! returns the index of the first occurrence of \a str within the current string and within \a length code points, starting at \a index; returns \c UString::npos if nothing is found
763
 
                /*! \a cp_str is a UTF-16 encoded string */
764
 
                size_type find( const wchar_t* w_str, size_type index, size_type length ) const;
765
 
#endif
766
 
                //! returns the index of the first occurrence \a ch within the current string, starting at \a index; returns \c UString::npos if nothing is found
767
 
                /*! \a ch is only capable of representing Unicode values up to U+007F (127) */
768
 
                size_type find( char ch, size_type index = 0 ) const;
769
 
                //! returns the index of the first occurrence \a ch within the current string, starting at \a index; returns \c UString::npos if nothing is found
770
 
                /*! \a ch is only capable of representing Unicode values up to U+FFFF (65535) */
771
 
                size_type find( code_point ch, size_type index = 0 ) const;
772
 
#if MYGUI_IS_NATIVE_WCHAR_T
773
 
                //! returns the index of the first occurrence \a ch within the current string, starting at \a index; returns \c UString::npos if nothing is found
774
 
                /*! \a ch is only capable of representing Unicode values up to U+FFFF (65535) */
775
 
                size_type find( wchar_t ch, size_type index = 0 ) const;
776
 
#endif
777
 
                //! returns the index of the first occurrence \a ch within the current string, starting at \a index; returns \c UString::npos if nothing is found
778
 
                /*! \a ch can fully represent any Unicode character */
779
 
                size_type find( unicode_char ch, size_type index = 0 ) const;
780
 
 
781
 
                //! returns the location of the first occurrence of \a str in the current string, doing a reverse search from \a index; returns \c UString::npos if nothing is found
782
 
                size_type rfind( const UString& str, size_type index = 0 ) const;
783
 
                //! returns the location of the first occurrence of \a str in the current string, doing a reverse search from \a index, searching at most \a num characters; returns \c UString::npos if nothing is found
784
 
                size_type rfind( const code_point* cp_str, size_type index, size_type num ) const;
785
 
                //! returns the location of the first occurrence of \a str in the current string, doing a reverse search from \a index, searching at most \a num characters; returns \c UString::npos if nothing is found
786
 
                size_type rfind( const char* c_str, size_type index, size_type num ) const;
787
 
#if MYGUI_IS_NATIVE_WCHAR_T
788
 
                //! returns the location of the first occurrence of \a str in the current string, doing a reverse search from \a index, searching at most \a num characters; returns \c UString::npos if nothing is found
789
 
                size_type rfind( const wchar_t* w_str, size_type index, size_type num ) const;
790
 
#endif
791
 
                //! returns the location of the first occurrence of \a ch in the current string, doing a reverse search from \a index; returns \c UString::npos if nothing is found
792
 
                size_type rfind( char ch, size_type index = 0 ) const;
793
 
                //! returns the location of the first occurrence of \a ch in the current string, doing a reverse search from \a index; returns \c UString::npos if nothing is found
794
 
                size_type rfind( code_point ch, size_type index ) const;
795
 
#if MYGUI_IS_NATIVE_WCHAR_T
796
 
                //! returns the location of the first occurrence of \a ch in the current string, doing a reverse search from \a index; returns \c UString::npos if nothing is found
797
 
                size_type rfind( wchar_t ch, size_type index = 0 ) const;
798
 
#endif
799
 
                //! returns the location of the first occurrence of \a ch in the current string, doing a reverse search from \a index; returns \c UString::npos if nothing is found
800
 
                size_type rfind( unicode_char ch, size_type index = 0 ) const;
801
 
                //@}
802
 
 
803
 
                //////////////////////////////////////////////////////////////////////////
804
 
 
805
 
                //!\name find_first/last_(not)_of
806
 
                //@{
807
 
                //! Returns the index of the first character within the current string that matches \b any character in \a str, beginning the search at \a index and searching at most \a num characters; returns \c UString::npos if nothing is found
808
 
                size_type find_first_of( const UString &str, size_type index = 0, size_type num = npos ) const;
809
 
                //! returns the index of the first occurrence of \a ch in the current string, starting the search at \a index; returns \c UString::npos if nothing is found
810
 
                size_type find_first_of( code_point ch, size_type index = 0 ) const;
811
 
                //! returns the index of the first occurrence of \a ch in the current string, starting the search at \a index; returns \c UString::npos if nothing is found
812
 
                size_type find_first_of( char ch, size_type index = 0 ) const;
813
 
#if MYGUI_IS_NATIVE_WCHAR_T
814
 
                //! returns the index of the first occurrence of \a ch in the current string, starting the search at \a index; returns \c UString::npos if nothing is found
815
 
                size_type find_first_of( wchar_t ch, size_type index = 0 ) const;
816
 
#endif
817
 
                //! returns the index of the first occurrence of \a ch in the current string, starting the search at \a index; returns \c UString::npos if nothing is found
818
 
                size_type find_first_of( unicode_char ch, size_type index = 0 ) const;
819
 
 
820
 
                //! returns the index of the first character within the current string that does not match any character in \a str, beginning the search at \a index and searching at most \a num characters; returns \c UString::npos if nothing is found
821
 
                size_type find_first_not_of( const UString& str, size_type index = 0, size_type num = npos ) const;
822
 
                //! returns the index of the first character within the current string that does not match \a ch, starting the search at \a index; returns \c UString::npos if nothing is found
823
 
                size_type find_first_not_of( code_point ch, size_type index = 0 ) const;
824
 
                //! returns the index of the first character within the current string that does not match \a ch, starting the search at \a index; returns \c UString::npos if nothing is found
825
 
                size_type find_first_not_of( char ch, size_type index = 0 ) const;
826
 
#if MYGUI_IS_NATIVE_WCHAR_T
827
 
                //! returns the index of the first character within the current string that does not match \a ch, starting the search at \a index; returns \c UString::npos if nothing is found
828
 
                size_type find_first_not_of( wchar_t ch, size_type index = 0 ) const;
829
 
#endif
830
 
                //! returns the index of the first character within the current string that does not match \a ch, starting the search at \a index; returns \c UString::npos if nothing is found
831
 
                size_type find_first_not_of( unicode_char ch, size_type index = 0 ) const;
832
 
 
833
 
                //! returns the index of the first character within the current string that matches any character in \a str, doing a reverse search from \a index and searching at most \a num characters; returns \c UString::npos if nothing is found
834
 
                size_type find_last_of( const UString& str, size_type index = npos, size_type num = npos ) const;
835
 
                //! returns the index of the first occurrence of \a ch in the current string, doing a reverse search from \a index; returns \c UString::npos if nothing is found
836
 
                size_type find_last_of( code_point ch, size_type index = npos ) const;
837
 
                //! returns the index of the first occurrence of \a ch in the current string, doing a reverse search from \a index; returns \c UString::npos if nothing is found
838
 
                size_type find_last_of( char ch, size_type index = npos ) const {
839
 
                        return find_last_of( static_cast<code_point>( ch ), index );
840
 
                }
841
 
#if MYGUI_IS_NATIVE_WCHAR_T
842
 
                //! returns the index of the first occurrence of \a ch in the current string, doing a reverse search from \a index; returns \c UString::npos if nothing is found
843
 
                size_type find_last_of( wchar_t ch, size_type index = npos ) const;
844
 
#endif
845
 
                //! returns the index of the first occurrence of \a ch in the current string, doing a reverse search from \a index; returns \c UString::npos if nothing is found
846
 
                size_type find_last_of( unicode_char ch, size_type index = npos ) const;
847
 
 
848
 
                //! returns the index of the last character within the current string that does not match any character in \a str, doing a reverse search from \a index; returns \c UString::npos if nothing is found
849
 
                size_type find_last_not_of( const UString& str, size_type index = npos, size_type num = npos ) const;
850
 
                //! returns the index of the last occurrence of a character that does not match \a ch in the current string, doing a reverse search from \a index; returns \c UString::npos if nothing is found
851
 
                size_type find_last_not_of( code_point ch, size_type index = npos ) const;
852
 
                //! returns the index of the last occurrence of a character that does not match \a ch in the current string, doing a reverse search from \a index; returns \c UString::npos if nothing is found
853
 
                size_type find_last_not_of( char ch, size_type index = npos ) const;
854
 
#if MYGUI_IS_NATIVE_WCHAR_T
855
 
                //! returns the index of the last occurrence of a character that does not match \a ch in the current string, doing a reverse search from \a index; returns \c UString::npos if nothing is found
856
 
                size_type find_last_not_of( wchar_t ch, size_type index = npos ) const;
857
 
#endif
858
 
                //! returns the index of the last occurrence of a character that does not match \a ch in the current string, doing a reverse search from \a index; returns \c UString::npos if nothing is found
859
 
                size_type find_last_not_of( unicode_char ch, size_type index = npos ) const;
860
 
                //@}
861
 
 
862
 
                //////////////////////////////////////////////////////////////////////////
863
 
 
864
 
                //!\name Operators
865
 
                //@{
866
 
                //! less than operator
867
 
                bool operator<( const UString& right ) const;
868
 
                //! less than or equal operator
869
 
                bool operator<=( const UString& right ) const;
870
 
                //! greater than operator
871
 
                bool operator>( const UString& right ) const;
872
 
                //! greater than or equal operator
873
 
                bool operator>=( const UString& right ) const;
874
 
                //! equality operator
875
 
                bool operator==( const UString& right ) const;
876
 
                //! inequality operator
877
 
                bool operator!=( const UString& right ) const;
878
 
                //! assignment operator, implicitly casts all compatible types
879
 
                UString& operator=( const UString& s );
880
 
                //! assignment operator
881
 
                UString& operator=( code_point ch );
882
 
                //! assignment operator
883
 
                UString& operator=( char ch );
884
 
#if MYGUI_IS_NATIVE_WCHAR_T
885
 
                //! assignment operator
886
 
                UString& operator=( wchar_t ch );
887
 
#endif
888
 
                //! assignment operator
889
 
                UString& operator=( unicode_char ch );
890
 
                //! code point dereference operator
891
 
                code_point& operator[]( size_type index );
892
 
                //! code point dereference operator
893
 
                const code_point& operator[]( size_type index ) const;
894
 
                //@}
895
 
 
896
 
                //////////////////////////////////////////////////////////////////////////
897
 
 
898
 
                //!\name Implicit Cast Operators
899
 
                //@{
900
 
                //! implicit cast to std::string
901
 
                operator std::string() const;
902
 
                //! implicit cast to std::wstring
903
 
                operator std::wstring() const;
904
 
                //@}
905
 
 
906
 
                //////////////////////////////////////////////////////////////////////////
907
 
 
908
 
                //!\name UTF-16 character encoding/decoding
909
 
                //@{
910
 
                //! returns \c true if \a cp does not match the signature for the lead of follow code point of a surrogate pair in a UTF-16 sequence
911
 
                static bool _utf16_independent_char( code_point cp );
912
 
                //! returns \c true if \a cp matches the signature of a surrogate pair lead character
913
 
                static bool _utf16_surrogate_lead( code_point cp );
914
 
                //! returns \c true if \a cp matches the signature of a surrogate pair following character
915
 
                static bool _utf16_surrogate_follow( code_point cp );
916
 
                //! estimates the number of UTF-16 code points in the sequence starting with \a cp
917
 
                static size_t _utf16_char_length( code_point cp );
918
 
                //! returns the number of UTF-16 code points needed to represent the given UTF-32 character \a cp
919
 
                static size_t _utf16_char_length( unicode_char uc );
920
 
                //! converts the given UTF-16 character buffer \a in_cp to a single UTF-32 Unicode character \a out_uc, returns the number of code points used to create the output character (2 for surrogate pairs, otherwise 1)
921
 
                /*! This function does it's best to prevent error conditions, verifying complete
922
 
                surrogate pairs before applying the algorithm. In the event that half of a pair
923
 
                is found it will happily generate a value in the 0xD800 - 0xDFFF range, which is
924
 
                normally an invalid Unicode value but we preserve them for use as sentinel values. */
925
 
                static size_t _utf16_to_utf32( const code_point in_cp[2], unicode_char& out_uc );
926
 
                //! writes the given UTF-32 \a uc_in to the buffer location \a out_cp using UTF-16 encoding, returns the number of code points used to encode the input (always 1 or 2)
927
 
                /*! This function, like its counterpart, will happily create invalid UTF-16 surrogate pairs. These
928
 
                invalid entries will be created for any value of \c in_uc that falls in the range U+D800 - U+DFFF.
929
 
                These are generally useful as sentinel values to represent various program specific conditions.
930
 
                \note This function will also pass through any single UTF-16 code point without modification,
931
 
                making it a safe method of ensuring a stream that is unknown UTF-32 or UTF-16 is truly UTF-16.*/
932
 
                static size_t _utf32_to_utf16( const unicode_char& in_uc, code_point out_cp[2] );
933
 
                //@}
934
 
 
935
 
                //////////////////////////////////////////////////////////////////////////
936
 
 
937
 
                //!\name UTF-8 character encoding/decoding
938
 
                //@{
939
 
                //! returns \c true if \a cp is the beginning of a UTF-8 sequence
940
 
                static bool _utf8_start_char( unsigned char cp );
941
 
                //! estimates the number of UTF-8 code points in the sequence starting with \a cp
942
 
                static size_t _utf8_char_length( unsigned char cp );
943
 
                //! returns the number of UTF-8 code points needed to represent the given UTF-32 character \a cp
944
 
                static size_t _utf8_char_length( unicode_char uc );
945
 
 
946
 
                //! converts the given UTF-8 character buffer to a single UTF-32 Unicode character, returns the number of bytes used to create the output character (maximum of 6)
947
 
                static size_t _utf8_to_utf32( const unsigned char in_cp[6], unicode_char& out_uc );
948
 
                //! writes the given UTF-32 \a uc_in to the buffer location \a out_cp using UTF-8 encoding, returns the number of bytes used to encode the input
949
 
                static size_t _utf32_to_utf8( const unicode_char& in_uc, unsigned char out_cp[6] );
950
 
 
951
 
                //! verifies a UTF-8 stream, returning the total number of Unicode characters found
952
 
                static size_type _verifyUTF8( const unsigned char* c_str );
953
 
                //! verifies a UTF-8 stream, returning the total number of Unicode characters found
954
 
                static size_type _verifyUTF8( const std::string& str );
955
 
                //@}
956
 
 
957
 
        private:
958
 
                //template<class ITER_TYPE> friend class _iterator;
959
 
                dstring mData;
960
 
 
961
 
                //! buffer data type identifier
962
 
                enum BufferType {
963
 
                        bt_none,
964
 
                        bt_string,
965
 
                        bt_wstring,
966
 
                        bt_utf32string
967
 
                };
968
 
 
969
 
                //! common constructor operations
970
 
                void _init();
971
 
 
972
 
                ///////////////////////////////////////////////////////////////////////
973
 
                // Scratch buffer
974
 
                //! auto cleans the scratch buffer using the proper delete for the stored type
975
 
                void _cleanBuffer() const;
976
 
 
977
 
                //! create a std::string in the scratch buffer area
978
 
                void _getBufferStr() const;
979
 
                //! create a std::wstring in the scratch buffer area
980
 
                void _getBufferWStr() const;
981
 
                //! create a utf32string in the scratch buffer area
982
 
                void _getBufferUTF32Str() const;
983
 
 
984
 
                void _load_buffer_UTF8() const;
985
 
                void _load_buffer_WStr() const;
986
 
                void _load_buffer_UTF32() const;
987
 
 
988
 
                mutable BufferType m_bufferType; // identifies the data type held in m_buffer
989
 
                mutable size_t m_bufferSize; // size of the CString buffer
990
 
 
991
 
                // multi-purpose buffer used everywhere we need a throw-away buffer
992
 
                union {
993
 
                        mutable void* mVoidBuffer;
994
 
                        mutable std::string* mStrBuffer;
995
 
                        mutable std::wstring* mWStrBuffer;
996
 
                        mutable utf32string* mUTF32StrBuffer;
997
 
                }
998
 
                m_buffer;
999
 
        };
1000
 
 
1001
 
        //! string addition operator \relates UString
1002
 
        inline UString operator+( const UString& s1, const UString& s2 ) {
1003
 
                return UString( s1 ).append( s2 );
1004
 
        }
1005
 
        //! string addition operator \relates UString
1006
 
        inline UString operator+( const UString& s1, UString::code_point c ) {
1007
 
                return UString( s1 ).append( 1, c );
1008
 
        }
1009
 
        //! string addition operator \relates UString
1010
 
        inline UString operator+( const UString& s1, UString::unicode_char c ) {
1011
 
                return UString( s1 ).append( 1, c );
1012
 
        }
1013
 
        //! string addition operator \relates UString
1014
 
        inline UString operator+( const UString& s1, char c ) {
1015
 
                return UString( s1 ).append( 1, c );
1016
 
        }
1017
 
#if MYGUI_IS_NATIVE_WCHAR_T
1018
 
        //! string addition operator \relates UString
1019
 
        inline UString operator+( const UString& s1, wchar_t c ) {
1020
 
                return UString( s1 ).append( 1, c );
1021
 
        }
1022
 
#endif
1023
 
        //! string addition operator \relates UString
1024
 
        inline UString operator+( UString::code_point c, const UString& s2 ) {
1025
 
                return UString().append( 1, c ).append( s2 );
1026
 
        }
1027
 
        //! string addition operator \relates UString
1028
 
        inline UString operator+( UString::unicode_char c, const UString& s2 ) {
1029
 
                return UString().append( 1, c ).append( s2 );
1030
 
        }
1031
 
        //! string addition operator \relates UString
1032
 
        inline UString operator+( char c, const UString& s2 ) {
1033
 
                return UString().append( 1, c ).append( s2 );
1034
 
        }
1035
 
#if MYGUI_IS_NATIVE_WCHAR_T
1036
 
        //! string addition operator \relates UString
1037
 
        inline UString operator+( wchar_t c, const UString& s2 ) {
1038
 
                return UString().append( 1, c ).append( s2 );
1039
 
        }
1040
 
#endif
1041
 
 
1042
 
        // (const) forward iterator common operators
1043
 
        inline UString::size_type operator-( const UString::_const_fwd_iterator& left, const UString::_const_fwd_iterator& right ) {
1044
 
                return ( left.mIter - right.mIter );
1045
 
        }
1046
 
        inline bool operator==( const UString::_const_fwd_iterator& left, const UString::_const_fwd_iterator& right ) {
1047
 
                return left.mIter == right.mIter;
1048
 
        }
1049
 
        inline bool operator!=( const UString::_const_fwd_iterator& left, const UString::_const_fwd_iterator& right ) {
1050
 
                return left.mIter != right.mIter;
1051
 
        }
1052
 
        inline bool operator<( const UString::_const_fwd_iterator& left, const UString::_const_fwd_iterator& right ) {
1053
 
                return left.mIter < right.mIter;
1054
 
        }
1055
 
        inline bool operator<=( const UString::_const_fwd_iterator& left, const UString::_const_fwd_iterator& right ) {
1056
 
                return left.mIter <= right.mIter;
1057
 
        }
1058
 
        inline bool operator>( const UString::_const_fwd_iterator& left, const UString::_const_fwd_iterator& right ) {
1059
 
                return left.mIter > right.mIter;
1060
 
        }
1061
 
        inline bool operator>=( const UString::_const_fwd_iterator& left, const UString::_const_fwd_iterator& right ) {
1062
 
                return left.mIter >= right.mIter;
1063
 
        }
1064
 
 
1065
 
        // (const) reverse iterator common operators
1066
 
        // NB: many of these operations are evaluated in reverse because this is a reverse iterator wrapping a forward iterator
1067
 
        inline UString::size_type operator-( const UString::_const_rev_iterator& left, const UString::_const_rev_iterator& right ) {
1068
 
                return ( right.mIter - left.mIter );
1069
 
        }
1070
 
        inline bool operator==( const UString::_const_rev_iterator& left, const UString::_const_rev_iterator& right ) {
1071
 
                return left.mIter == right.mIter;
1072
 
        }
1073
 
        inline bool operator!=( const UString::_const_rev_iterator& left, const UString::_const_rev_iterator& right ) {
1074
 
                return left.mIter != right.mIter;
1075
 
        }
1076
 
        inline bool operator<( const UString::_const_rev_iterator& left, const UString::_const_rev_iterator& right ) {
1077
 
                return right.mIter < left.mIter;
1078
 
        }
1079
 
        inline bool operator<=( const UString::_const_rev_iterator& left, const UString::_const_rev_iterator& right ) {
1080
 
                return right.mIter <= left.mIter;
1081
 
        }
1082
 
        inline bool operator>( const UString::_const_rev_iterator& left, const UString::_const_rev_iterator& right ) {
1083
 
                return right.mIter > left.mIter;
1084
 
        }
1085
 
        inline bool operator>=( const UString::_const_rev_iterator& left, const UString::_const_rev_iterator& right ) {
1086
 
                return right.mIter >= left.mIter;
1087
 
        }
1088
 
 
1089
 
        //! std::ostream write operator \relates UString
1090
 
        inline std::ostream& operator << ( std::ostream& os, const UString& s ) {
1091
 
                return os << s.asUTF8();
1092
 
        }
1093
 
 
1094
 
        //! std::wostream write operator \relates UString
1095
 
        inline std::wostream& operator << ( std::wostream& os, const UString& s ) {
1096
 
                return os << s.asWStr();
1097
 
        }
1098
 
 
1099
 
} // namespace MyGUI
1100
 
 
1101
 
#if MYGUI_COMPILER == MYGUI_COMPILER_MSVC
1102
 
#       pragma warning (default : 4275)
1103
 
#endif
1104
 
 
1105
 
#endif  // __MYGUI_U_STRING_H__
 
1
// Modified from OpenGUI under lenient license
 
2
// Original copyright details and licensing below:
 
3
// OpenGUI (http://opengui.sourceforge.net)
 
4
// This source code is released under the BSD License
 
5
 
 
6
// Permission is given to the MyGUI project to use the contents of file within its
 
7
// source and binary applications, as well as any derivative works, in accordance
 
8
// with the terms of any license under which MyGUI is or will be distributed.
 
9
//
 
10
// MyGUI may relicense its copy of this file, as well as any OpenGUI released updates
 
11
// to this file, under any terms that it deems fit, and is not required to maintain
 
12
// the original BSD licensing terms of this file, however OpenGUI retains the right
 
13
// to present its copy of this file under the terms of any license under which
 
14
// OpenGUI is distributed.
 
15
//
 
16
// MyGUI is not required to release to OpenGUI any future changes that it makes to
 
17
// this file, and understands and agrees that any such changes that are released
 
18
// back to OpenGUI will become available under the terms of any license under which
 
19
// OpenGUI is distributed.
 
20
//
 
21
// For brevity, this permission text may be removed from this file if desired.
 
22
// The original record kept within the SourceForge (http://sourceforge.net/) tracker
 
23
// is sufficient.
 
24
//
 
25
// - Eric Shorkey (zero/zeroskill) <opengui@rightbracket.com> [January 20th, 2007]
 
26
 
 
27
#ifndef __MYGUI_U_STRING_H__
 
28
#define __MYGUI_U_STRING_H__
 
29
 
 
30
 
 
31
#include "MyGUI_Prerequest.h"
 
32
#include "MyGUI_Types.h"
 
33
 
 
34
// these are explained later
 
35
#include <iterator>
 
36
#include <string>
 
37
#include <stdexcept>
 
38
 
 
39
#if MYGUI_COMPILER == MYGUI_COMPILER_MSVC
 
40
// disable: warning C4275: non dll-interface class '***' used as base for dll-interface clas '***'
 
41
#       pragma warning (push)
 
42
#       pragma warning (disable : 4275)
 
43
#endif
 
44
 
 
45
// Workaround for VC7:
 
46
//      when build with /MD or /MDd, VC7 have both std::basic_string<unsigned short> and
 
47
// basic_string<__wchar_t> instantiated in msvcprt[d].lib/MSVCP71[D].dll, but the header
 
48
// files tells compiler that only one of them is over there (based on /Zc:wchar_t compile
 
49
// option). And since this file used both of them, causing compiler instantiating another
 
50
// one in user object code, which lead to duplicate symbols with msvcprt.lib/MSVCP71[D].dll.
 
51
//
 
52
#if MYGUI_COMPILER == MYGUI_COMPILER_MSVC && (1300 <= MYGUI_COMP_VER && MYGUI_COMP_VER <= 1310)
 
53
 
 
54
# if defined(_DLL_CPPLIB)
 
55
 
 
56
namespace std
 
57
{
 
58
    template class _CRTIMP2 basic_string<unsigned short, char_traits<unsigned short>,
 
59
            allocator<unsigned short> >;
 
60
 
 
61
    template class _CRTIMP2 basic_string<__wchar_t, char_traits<__wchar_t>,
 
62
            allocator<__wchar_t> >;
 
63
}
 
64
 
 
65
# endif // defined(_DLL_CPPLIB)
 
66
 
 
67
#endif  // MYGUI_COMPILER == MYGUI_COMPILER_MSVC && MYGUI_COMP_VER == 1300
 
68
 
 
69
 
 
70
namespace MyGUI
 
71
{
 
72
 
 
73
        /* READ THIS NOTICE BEFORE USING IN YOUR OWN APPLICATIONS
 
74
        =NOTICE=
 
75
        This class is not a complete Unicode solution. It purposefully does not
 
76
        provide certain functionality, such as proper lexical sorting for
 
77
        Unicode values. It does provide comparison operators for the sole purpose
 
78
        of using UString as an index with std::map and other operator< sorted
 
79
        containers, but it should NOT be relied upon for meaningful lexical
 
80
        operations, such as alphabetical sorts. If you need this type of
 
81
        functionality, look into using ICU instead (http://icu.sourceforge.net/).
 
82
 
 
83
        =REQUIREMENTS=
 
84
        There are a few requirements for proper operation. They are fairly small,
 
85
        and shouldn't restrict usage on any reasonable target.
 
86
        * Compiler must support unsigned 16-bit integer types
 
87
        * Compiler must support signed 32-bit integer types
 
88
        * wchar_t must be either UTF-16 or UTF-32 encoding, and specified as such
 
89
            using the WCHAR_UTF16 macro as outlined below.
 
90
        * You must include <iterator>, <string>, and <wchar>. Probably more, but
 
91
            these are the most obvious.
 
92
 
 
93
        =REQUIRED PREPROCESSOR MACROS=
 
94
        This class requires two preprocessor macros to be defined in order to
 
95
        work as advertised.
 
96
        INT32 - must be mapped to a signed 32 bit integer (ex. #define INT32 int)
 
97
        UINT16 - must be mapped to an unsigned 16 bit integer (ex. #define UINT32 unsigned short)
 
98
 
 
99
        Additionally, a third macro should be defined to control the evaluation of wchar_t:
 
100
        WCHAR_UTF16 - should be defined when wchar_t represents UTF-16 code points,
 
101
            such as in Windows. Otherwise it is assumed that wchar_t is a 32-bit
 
102
                integer representing UTF-32 code points.
 
103
        */
 
104
 
 
105
        // THIS IS A VERY BRIEF AUTO DETECTION. YOU MAY NEED TO TWEAK THIS
 
106
#ifdef __STDC_ISO_10646__
 
107
// for any compiler that provides this, wchar_t is guaranteed to hold any Unicode value with a single code point (32-bit or larger)
 
108
// so we can safely skip the rest of the testing
 
109
#else // #ifdef __STDC_ISO_10646__
 
110
#if defined( __WIN32__ ) || defined( _WIN32 )
 
111
#define WCHAR_UTF16 // All currently known Windows platforms utilize UTF-16 encoding in wchar_t
 
112
#else // #if defined( __WIN32__ ) || defined( _WIN32 )
 
113
#if MYGUI_COMPILER != MYGUI_COMPILER_GCCE
 
114
#if WCHAR_MAX <= 0xFFFF // this is a last resort fall back test; WCHAR_MAX is defined in <wchar.h>
 
115
#define WCHAR_UTF16 // best we can tell, wchar_t is not larger than 16-bit
 
116
#endif // #if WCHAR_MAX <= 0xFFFF
 
117
#endif
 
118
#endif // #if defined( __WIN32__ ) || defined( _WIN32 )
 
119
#endif // #ifdef __STDC_ISO_10646__
 
120
 
 
121
 
 
122
// MYGUI_IS_NATIVE_WCHAR_T means that wchar_t isn't a typedef of
 
123
// uint16_t or uint32_t.
 
124
#if MYGUI_COMPILER == MYGUI_COMPILER_MSVC
 
125
 
 
126
// Don't define wchar_t related functions since it'll duplicate
 
127
// with UString::code_point related functions when compile
 
128
// without /Zc:wchar_t, because in this case both of them are
 
129
// a typedef of uint16_t.
 
130
# if defined(_NATIVE_WCHAR_T_DEFINED)
 
131
#   define MYGUI_IS_NATIVE_WCHAR_T      1
 
132
# else
 
133
#   define MYGUI_IS_NATIVE_WCHAR_T      0
 
134
# endif
 
135
#elif MYGUI_PLATFORM == MYGUI_PLATFORM_SYMBIAN
 
136
#   define MYGUI_IS_NATIVE_WCHAR_T      0
 
137
#else   // MYGUI_COMPILER != MYGUI_COMPILER_MSVC
 
138
 
 
139
// Assumed wchar_t is natively for other compilers
 
140
#   define MYGUI_IS_NATIVE_WCHAR_T     1
 
141
 
 
142
#endif  // MYGUI_COMPILER == MYGUI_COMPILER_MSVC
 
143
 
 
144
        //! A UTF-16 string with implicit conversion to/from std::string and std::wstring
 
145
        /*! This class provides a complete 1 to 1 map of most std::string functions (at least to my
 
146
        knowledge). Implicit conversions allow this string class to work with all common C++ string
 
147
        formats, with specialty functions defined where implicit conversion would cause potential
 
148
        problems or is otherwise unavailable.
 
149
 
 
150
        Some additional functionality is present to assist in working with characters using the
 
151
        32-bit UTF-32 encoding. (Which is guaranteed to fit any Unicode character into a single
 
152
        code point.) \b Note: Reverse iterators do not have this functionality due to the
 
153
        ambiguity that surrounds working with UTF-16 in reverse. (Such as, where should an
 
154
        iterator point to represent the beginning of a surrogate pair?)
 
155
 
 
156
 
 
157
        \par Supported Input Types
 
158
        The supported string types for input, and their assumed encoding schemes, are:
 
159
        - std::string (UTF-8)
 
160
        - char* (UTF-8)
 
161
        - std::wstring (autodetected UTF-16 / UTF-32 based on compiler)
 
162
        - wchar_t* (autodetected UTF-16 / UTF-32 based on compiler)
 
163
 
 
164
 
 
165
        \see
 
166
        - For additional information on UTF-16 encoding: http://en.wikipedia.org/wiki/UTF-16
 
167
        - For additional information on UTF-8 encoding: http://en.wikipedia.org/wiki/UTF-8
 
168
        - For additional information on UTF-32 encoding: http://en.wikipedia.org/wiki/UTF-32
 
169
        */
 
170
        class MYGUI_EXPORT UString {
 
171
                // constants used in UTF-8 conversions
 
172
                static const unsigned char _lead1 = 0xC0;      //110xxxxx
 
173
                static const unsigned char _lead1_mask = 0x1F; //00011111
 
174
                static const unsigned char _lead2 = 0xE0;      //1110xxxx
 
175
                static const unsigned char _lead2_mask = 0x0F; //00001111
 
176
                static const unsigned char _lead3 = 0xF0;      //11110xxx
 
177
                static const unsigned char _lead3_mask = 0x07; //00000111
 
178
                static const unsigned char _lead4 = 0xF8;      //111110xx
 
179
                static const unsigned char _lead4_mask = 0x03; //00000011
 
180
                static const unsigned char _lead5 = 0xFC;      //1111110x
 
181
                static const unsigned char _lead5_mask = 0x01; //00000001
 
182
                static const unsigned char _cont = 0x80;       //10xxxxxx
 
183
                static const unsigned char _cont_mask = 0x3F;  //00111111
 
184
 
 
185
        public:
 
186
                //! size type used to indicate string size and character positions within the string
 
187
                typedef size_t size_type;
 
188
                //! the usual constant representing: not found, no limit, etc
 
189
                static const size_type npos = static_cast<size_type>(~0);
 
190
 
 
191
                //! a single 32-bit Unicode character
 
192
                typedef uint32 unicode_char;
 
193
 
 
194
                //! a single UTF-16 code point
 
195
                typedef uint16 code_point;
 
196
 
 
197
                //! value type typedef for use in iterators
 
198
                typedef code_point value_type;
 
199
 
 
200
                typedef std::basic_string<code_point> dstring; // data string
 
201
 
 
202
                //! string type used for returning UTF-32 formatted data
 
203
                typedef std::basic_string<unicode_char> utf32string;
 
204
 
 
205
                //! This exception is used when invalid data streams are encountered
 
206
        class MYGUI_EXPORT invalid_data: public std::runtime_error { /* i don't know why the beautifier is freaking out on this line */
 
207
                public:
 
208
                        //! constructor takes a string message that can be later retrieved by the what() function
 
209
                        explicit invalid_data( const std::string& _Message ): std::runtime_error( _Message ) {
 
210
                                /* The thing is, Bob, it's not that I'm lazy, it's that I just don't care. */
 
211
                        }
 
212
                };
 
213
 
 
214
                //#########################################################################
 
215
                //! base iterator class for UString
 
216
        class MYGUI_EXPORT _base_iterator: public std::iterator<std::random_access_iterator_tag, value_type> { /* i don't know why the beautifier is freaking out on this line */
 
217
                        friend class UString;
 
218
                protected:
 
219
                        _base_iterator();
 
220
 
 
221
                        void _seekFwd( size_type c );
 
222
                        void _seekRev( size_type c );
 
223
                        void _become( const _base_iterator& i );
 
224
                        bool _test_begin() const;
 
225
                        bool _test_end() const;
 
226
                        size_type _get_index() const;
 
227
                        void _jump_to( size_type index );
 
228
 
 
229
                        unicode_char _getCharacter() const;
 
230
                        int _setCharacter( unicode_char uc );
 
231
 
 
232
                        void _moveNext();
 
233
                        void _movePrev();
 
234
 
 
235
                        dstring::iterator mIter;
 
236
                        UString* mString;
 
237
                };
 
238
 
 
239
                //#########################################################################
 
240
                // FORWARD ITERATORS
 
241
                //#########################################################################
 
242
                class _const_fwd_iterator; // forward declaration
 
243
 
 
244
                //! forward iterator for UString
 
245
        class MYGUI_EXPORT _fwd_iterator: public _base_iterator { /* i don't know why the beautifier is freaking out on this line */
 
246
                        friend class _const_fwd_iterator;
 
247
                public:
 
248
                        _fwd_iterator();
 
249
                        _fwd_iterator( const _fwd_iterator& i );
 
250
 
 
251
                        //! pre-increment
 
252
                        _fwd_iterator& operator++();
 
253
                        //! post-increment
 
254
                        _fwd_iterator operator++( int );
 
255
 
 
256
                        //! pre-decrement
 
257
                        _fwd_iterator& operator--();
 
258
                        //! post-decrement
 
259
                        _fwd_iterator operator--( int );
 
260
 
 
261
                        //! addition operator
 
262
                        _fwd_iterator operator+( difference_type n );
 
263
                        //! subtraction operator
 
264
                        _fwd_iterator operator-( difference_type n );
 
265
 
 
266
                        //! addition assignment operator
 
267
                        _fwd_iterator& operator+=( difference_type n );
 
268
                        //! subtraction assignment operator
 
269
                        _fwd_iterator& operator-=( difference_type n );
 
270
 
 
271
                        //! dereference operator
 
272
                        value_type& operator*() const;
 
273
 
 
274
                        //! dereference at offset operator
 
275
                        value_type& operator[]( difference_type n ) const;
 
276
 
 
277
                        //! advances to the next Unicode character, honoring surrogate pairs in the UTF-16 stream
 
278
                        _fwd_iterator& moveNext();
 
279
                        //! rewinds to the previous Unicode character, honoring surrogate pairs in the UTF-16 stream
 
280
                        _fwd_iterator& movePrev();
 
281
                        //! Returns the Unicode value of the character at the current position (decodes surrogate pairs if needed)
 
282
                        unicode_char getCharacter() const;
 
283
                        //! Sets the Unicode value of the character at the current position (adding a surrogate pair if needed); returns the amount of string length change caused by the operation
 
284
                        int setCharacter( unicode_char uc );
 
285
                };
 
286
 
 
287
 
 
288
 
 
289
                //#########################################################################
 
290
                //! const forward iterator for UString
 
291
        class MYGUI_EXPORT _const_fwd_iterator: public _base_iterator { /* i don't know why the beautifier is freaking out on this line */
 
292
                public:
 
293
                        _const_fwd_iterator();
 
294
                        _const_fwd_iterator( const _const_fwd_iterator& i );
 
295
                        _const_fwd_iterator( const _fwd_iterator& i );
 
296
 
 
297
                        //! pre-increment
 
298
                        _const_fwd_iterator& operator++();
 
299
                        //! post-increment
 
300
                        _const_fwd_iterator operator++( int );
 
301
 
 
302
                        //! pre-decrement
 
303
                        _const_fwd_iterator& operator--();
 
304
                        //! post-decrement
 
305
                        _const_fwd_iterator operator--( int );
 
306
 
 
307
                        //! addition operator
 
308
                        _const_fwd_iterator operator+( difference_type n );
 
309
                        //! subtraction operator
 
310
                        _const_fwd_iterator operator-( difference_type n );
 
311
 
 
312
                        //! addition assignment operator
 
313
                        _const_fwd_iterator& operator+=( difference_type n );
 
314
                        //! subtraction assignment operator
 
315
                        _const_fwd_iterator& operator-=( difference_type n );
 
316
 
 
317
                        //! dereference operator
 
318
                        const value_type& operator*() const;
 
319
 
 
320
                        //! dereference at offset operator
 
321
                        const value_type& operator[]( difference_type n ) const;
 
322
 
 
323
                        //! advances to the next Unicode character, honoring surrogate pairs in the UTF-16 stream
 
324
                        _const_fwd_iterator& moveNext();
 
325
                        //! rewinds to the previous Unicode character, honoring surrogate pairs in the UTF-16 stream
 
326
                        _const_fwd_iterator& movePrev();
 
327
                        //! Returns the Unicode value of the character at the current position (decodes surrogate pairs if needed)
 
328
                        unicode_char getCharacter() const;
 
329
 
 
330
                        //! difference operator
 
331
                        friend size_type operator-( const _const_fwd_iterator& left, const _const_fwd_iterator& right );
 
332
                        //! equality operator
 
333
                        friend bool operator==( const _const_fwd_iterator& left, const _const_fwd_iterator& right );
 
334
                        //! inequality operator
 
335
                        friend bool operator!=( const _const_fwd_iterator& left, const _const_fwd_iterator& right );
 
336
                        //! less than
 
337
                        friend bool operator<( const _const_fwd_iterator& left, const _const_fwd_iterator& right );
 
338
                        //! less than or equal
 
339
                        friend bool operator<=( const _const_fwd_iterator& left, const _const_fwd_iterator& right );
 
340
                        //! greater than
 
341
                        friend bool operator>( const _const_fwd_iterator& left, const _const_fwd_iterator& right );
 
342
                        //! greater than or equal
 
343
                        friend bool operator>=( const _const_fwd_iterator& left, const _const_fwd_iterator& right );
 
344
 
 
345
                };
 
346
 
 
347
                //#########################################################################
 
348
                // REVERSE ITERATORS
 
349
                //#########################################################################
 
350
                class _const_rev_iterator; // forward declaration
 
351
                //! forward iterator for UString
 
352
        class MYGUI_EXPORT _rev_iterator: public _base_iterator { /* i don't know why the beautifier is freaking out on this line */
 
353
                        friend class _const_rev_iterator;
 
354
                public:
 
355
                        _rev_iterator();
 
356
                        _rev_iterator( const _rev_iterator& i );
 
357
 
 
358
                        //! pre-increment
 
359
                        _rev_iterator& operator++();
 
360
                        //! post-increment
 
361
                        _rev_iterator operator++( int );
 
362
 
 
363
                        //! pre-decrement
 
364
                        _rev_iterator& operator--();
 
365
                        //! post-decrement
 
366
                        _rev_iterator operator--( int );
 
367
 
 
368
                        //! addition operator
 
369
                        _rev_iterator operator+( difference_type n );
 
370
                        //! subtraction operator
 
371
                        _rev_iterator operator-( difference_type n );
 
372
 
 
373
                        //! addition assignment operator
 
374
                        _rev_iterator& operator+=( difference_type n );
 
375
                        //! subtraction assignment operator
 
376
                        _rev_iterator& operator-=( difference_type n );
 
377
 
 
378
                        //! dereference operator
 
379
                        value_type& operator*() const;
 
380
 
 
381
                        //! dereference at offset operator
 
382
                        value_type& operator[]( difference_type n ) const;
 
383
                };
 
384
                //#########################################################################
 
385
                //! const reverse iterator for UString
 
386
        class MYGUI_EXPORT _const_rev_iterator: public _base_iterator { /* i don't know why the beautifier is freaking out on this line */
 
387
                public:
 
388
                        _const_rev_iterator();
 
389
                        _const_rev_iterator( const _const_rev_iterator& i );
 
390
                        _const_rev_iterator( const _rev_iterator& i );
 
391
                        //! pre-increment
 
392
                        _const_rev_iterator& operator++();
 
393
                        //! post-increment
 
394
                        _const_rev_iterator operator++( int );
 
395
 
 
396
                        //! pre-decrement
 
397
                        _const_rev_iterator& operator--();
 
398
                        //! post-decrement
 
399
                        _const_rev_iterator operator--( int );
 
400
 
 
401
                        //! addition operator
 
402
                        _const_rev_iterator operator+( difference_type n );
 
403
                        //! subtraction operator
 
404
                        _const_rev_iterator operator-( difference_type n );
 
405
 
 
406
                        //! addition assignment operator
 
407
                        _const_rev_iterator& operator+=( difference_type n );
 
408
                        //! subtraction assignment operator
 
409
                        _const_rev_iterator& operator-=( difference_type n );
 
410
 
 
411
                        //! dereference operator
 
412
                        const value_type& operator*() const;
 
413
 
 
414
                        //! dereference at offset operator
 
415
                        const value_type& operator[]( difference_type n ) const;
 
416
 
 
417
                        //! difference operator
 
418
                        friend size_type operator-( const _const_rev_iterator& left, const _const_rev_iterator& right );
 
419
                        //! equality operator
 
420
                        friend bool operator==( const _const_rev_iterator& left, const _const_rev_iterator& right );
 
421
                        //! inequality operator
 
422
                        friend bool operator!=( const _const_rev_iterator& left, const _const_rev_iterator& right );
 
423
                        //! less than
 
424
                        friend bool operator<( const _const_rev_iterator& left, const _const_rev_iterator& right );
 
425
                        //! less than or equal
 
426
                        friend bool operator<=( const _const_rev_iterator& left, const _const_rev_iterator& right );
 
427
                        //! greater than
 
428
                        friend bool operator>( const _const_rev_iterator& left, const _const_rev_iterator& right );
 
429
                        //! greater than or equal
 
430
                        friend bool operator>=( const _const_rev_iterator& left, const _const_rev_iterator& right );
 
431
                };
 
432
                //#########################################################################
 
433
 
 
434
                typedef _fwd_iterator iterator;                     //!< iterator
 
435
                typedef _rev_iterator reverse_iterator;             //!< reverse iterator
 
436
                typedef _const_fwd_iterator const_iterator;         //!< const iterator
 
437
                typedef _const_rev_iterator const_reverse_iterator; //!< const reverse iterator
 
438
 
 
439
 
 
440
                //!\name Constructors/Destructor
 
441
                //@{
 
442
                //! default constructor, creates an empty string
 
443
                UString();
 
444
                //! copy constructor
 
445
                UString( const UString& copy );
 
446
                //! \a length copies of \a ch
 
447
                UString( size_type length, const code_point& ch );
 
448
                //! duplicate of nul-terminated sequence \a str
 
449
                UString( const code_point* str );
 
450
                //! duplicate of \a str, \a length code points long
 
451
                UString( const code_point* str, size_type length );
 
452
                //! substring of \a str starting at \a index and \a length code points long
 
453
                UString( const UString& str, size_type index, size_type length );
 
454
#if MYGUI_IS_NATIVE_WCHAR_T
 
455
                //! duplicate of nul-terminated \c wchar_t array
 
456
                UString( const wchar_t* w_str );
 
457
                //! duplicate of \a w_str, \a length characters long
 
458
                UString( const wchar_t* w_str, size_type length );
 
459
#endif
 
460
                //! duplicate of \a wstr
 
461
                UString( const std::wstring& wstr );
 
462
                //! duplicate of nul-terminated C-string \a c_str (UTF-8 encoding)
 
463
                UString( const char* c_str );
 
464
                //! duplicate of \a c_str, \a length characters long (UTF-8 encoding)
 
465
                UString( const char* c_str, size_type length );
 
466
                //! duplicate of \a str (UTF-8 encoding)
 
467
                UString( const std::string& str );
 
468
 
 
469
                //! destructor
 
470
                ~UString();
 
471
                //@}
 
472
 
 
473
                //////////////////////////////////////////////////////////////////////////
 
474
 
 
475
                //!\name Utility functions
 
476
                //@{
 
477
                //! Returns the number of code points in the current string
 
478
                size_type size() const;
 
479
                //! Returns the number of code points in the current string
 
480
                size_type length() const;
 
481
                //! Returns the number of Unicode characters in the string
 
482
                /*! Executes in linear time. */
 
483
                size_type length_Characters() const;
 
484
                //! returns the maximum number of UTF-16 code points that the string can hold
 
485
                size_type max_size() const;
 
486
                //! sets the capacity of the string to at least \a size code points
 
487
                void reserve( size_type size );
 
488
                //! changes the size of the string to \a size, filling in any new area with \a val
 
489
                void resize( size_type num, const code_point& val = 0 );
 
490
                //! exchanges the elements of the current string with those of \a from
 
491
                void swap( UString& from );
 
492
                //! returns \c true if the string has no elements, \c false otherwise
 
493
                bool empty() const;
 
494
                //! returns a pointer to the first character in the current string
 
495
                const code_point* c_str() const;
 
496
                //! returns a pointer to the first character in the current string
 
497
                const code_point* data() const;
 
498
                //! returns the number of elements that the string can hold before it will need to allocate more space
 
499
                size_type capacity() const;
 
500
                //! deletes all of the elements in the string
 
501
                void clear();
 
502
                //! returns a substring of the current string, starting at \a index, and \a num characters long.
 
503
                /*! If \a num is omitted, it will default to \c UString::npos, and the substr() function will simply return the remainder of the string starting at \a index. */
 
504
                UString substr( size_type index, size_type num = npos ) const;
 
505
                //! appends \a val to the end of the string
 
506
                void push_back( unicode_char val );
 
507
#if MYGUI_IS_NATIVE_WCHAR_T
 
508
                //! appends \a val to the end of the string
 
509
                void push_back( wchar_t val );
 
510
#endif
 
511
                //! appends \a val to the end of the string
 
512
                /*! This can be used to push surrogate pair code points, you'll just need to push them
 
513
                one after the other. */
 
514
                void push_back( code_point val );
 
515
                //! appends \a val to the end of the string
 
516
                /*! Limited to characters under the 127 value barrier. */
 
517
                void push_back( char val );
 
518
                //! returns \c true if the given Unicode character \a ch is in this string
 
519
                bool inString( unicode_char ch ) const;
 
520
                //@}
 
521
 
 
522
                //////////////////////////////////////////////////////////////////////////
 
523
 
 
524
                //!\name Stream variations
 
525
                //@{
 
526
                //! returns the current string in UTF-8 form within a std::string
 
527
                const std::string& asUTF8() const;
 
528
                //! returns the current string in UTF-8 form as a nul-terminated char array
 
529
                const char* asUTF8_c_str() const;
 
530
                //! returns the current string in UTF-32 form within a utf32string
 
531
                const utf32string& asUTF32() const;
 
532
                //! returns the current string in UTF-32 form as a nul-terminated unicode_char array
 
533
                const unicode_char* asUTF32_c_str() const;
 
534
                //! returns the current string in the native form of std::wstring
 
535
                const std::wstring& asWStr() const;
 
536
                //! returns the current string in the native form of a nul-terminated wchar_t array
 
537
                const wchar_t* asWStr_c_str() const;
 
538
                //@}
 
539
 
 
540
                //////////////////////////////////////////////////////////////////////////
 
541
 
 
542
                //!\name Single Character Access
 
543
                //@{
 
544
                //! returns a reference to the element in the string at index \c loc
 
545
                code_point& at( size_type loc );
 
546
                //! returns a reference to the element in the string at index \c loc
 
547
                const code_point& at( size_type loc ) const;
 
548
                //! returns the data point \a loc evaluated as a UTF-32 value
 
549
                /*! This function will will only properly decode surrogate pairs when \a loc points to the index
 
550
                of a lead code point that is followed by a trailing code point. Evaluating the trailing code point
 
551
                itself, or pointing to a code point that is a sentinel value (part of a broken pair) will return
 
552
                the value of just that code point (not a valid Unicode value, but useful as a sentinel value). */
 
553
                unicode_char getChar( size_type loc ) const;
 
554
                //! sets the value of the character at \a loc to the Unicode value \a ch (UTF-32)
 
555
                /*! Providing sentinel values (values between U+D800-U+DFFF) are accepted, but you should be aware
 
556
                that you can also unwittingly create a valid surrogate pair if you don't pay attention to what you
 
557
                are doing. \note This operation may also lengthen the string if a surrogate pair is needed to
 
558
                represent the value given, but one is not available to replace; or alternatively shorten the string
 
559
                if an existing surrogate pair is replaced with a character that is representable without a surrogate
 
560
                pair. The return value will signify any lengthening or shortening performed, returning 0 if no change
 
561
                was made, -1 if the string was shortened, or 1 if the string was lengthened. Any single call can
 
562
                only change the string length by + or - 1. */
 
563
                int setChar( size_type loc, unicode_char ch );
 
564
                //@}
 
565
 
 
566
                //////////////////////////////////////////////////////////////////////////
 
567
 
 
568
                //!\name iterator acquisition
 
569
                //@{
 
570
                //! returns an iterator to the first element of the string
 
571
                iterator begin();
 
572
                //! returns an iterator to the first element of the string
 
573
                const_iterator begin() const;
 
574
                //! returns an iterator just past the end of the string
 
575
                iterator end();
 
576
                //! returns an iterator just past the end of the string
 
577
                const_iterator end() const;
 
578
                //! returns a reverse iterator to the last element of the string
 
579
                reverse_iterator rbegin();
 
580
                //! returns a reverse iterator to the last element of the string
 
581
                const_reverse_iterator rbegin() const;
 
582
                //! returns a reverse iterator just past the beginning of the string
 
583
                reverse_iterator rend();
 
584
                //! returns a reverse iterator just past the beginning of the string
 
585
                const_reverse_iterator rend() const;
 
586
                //@}
 
587
 
 
588
                //////////////////////////////////////////////////////////////////////////
 
589
 
 
590
                //!\name assign
 
591
                //@{
 
592
                //! gives the current string the values from \a start to \a end
 
593
                UString& assign( iterator start, iterator end );
 
594
                //! assign \a str to the current string
 
595
                UString& assign( const UString& str );
 
596
                //! assign the nul-terminated \a str to the current string
 
597
                UString& assign( const code_point* str );
 
598
                //! assign the first \a num characters of \a str to the current string
 
599
                UString& assign( const code_point* str, size_type num );
 
600
                //! assign \a len entries from \a str to the current string, starting at \a index
 
601
                UString& assign( const UString& str, size_type index, size_type len );
 
602
                //! assign \a num copies of \a ch to the current string
 
603
                UString& assign( size_type num, const code_point& ch );
 
604
                //! assign \a wstr to the current string (\a wstr is treated as a UTF-16 stream)
 
605
                UString& assign( const std::wstring& wstr );
 
606
#if MYGUI_IS_NATIVE_WCHAR_T
 
607
                //! assign \a w_str to the current string
 
608
                UString& assign( const wchar_t* w_str );
 
609
                //! assign the first \a num characters of \a w_str to the current string
 
610
                UString& assign( const wchar_t* w_str, size_type num );
 
611
#endif
 
612
                //! assign \a str to the current string (\a str is treated as a UTF-8 stream)
 
613
                UString& assign( const std::string& str );
 
614
                //! assign \a c_str to the current string (\a c_str is treated as a UTF-8 stream)
 
615
                UString& assign( const char* c_str );
 
616
                //! assign the first \a num characters of \a c_str to the current string (\a c_str is treated as a UTF-8 stream)
 
617
                UString& assign( const char* c_str, size_type num );
 
618
                //@}
 
619
 
 
620
                //////////////////////////////////////////////////////////////////////////
 
621
 
 
622
                //!\name append
 
623
                //@{
 
624
                //! appends \a str on to the end of the current string
 
625
                UString& append( const UString& str );
 
626
                //! appends \a str on to the end of the current string
 
627
                UString& append( const code_point* str );
 
628
                //! appends a substring of \a str starting at \a index that is \a len characters long on to the end of the current string
 
629
                UString& append( const UString& str, size_type index, size_type len );
 
630
                //! appends \a num characters of \a str on to the end of the current string
 
631
                UString& append( const code_point* str, size_type num );
 
632
                //! appends \a num repetitions of \a ch on to the end of the current string
 
633
                UString& append( size_type num, code_point ch );
 
634
                //! appends the sequence denoted by \a start and \a end on to the end of the current string
 
635
                UString& append( iterator start, iterator end );
 
636
#if MYGUI_IS_NATIVE_WCHAR_T
 
637
                //! appends \a num characters of \a str on to the end of the current string
 
638
                UString& append( const wchar_t* w_str, size_type num );
 
639
                //! appends \a num repetitions of \a ch on to the end of the current string
 
640
                UString& append( size_type num, wchar_t ch );
 
641
#endif
 
642
                //! appends \a num characters of \a str on to the end of the current string  (UTF-8 encoding)
 
643
                UString& append( const char* c_str, size_type num );
 
644
                //! appends \a num repetitions of \a ch on to the end of the current string (Unicode values less than 128)
 
645
                UString& append( size_type num, char ch );
 
646
                //! appends \a num repetitions of \a ch on to the end of the current string (Full Unicode spectrum)
 
647
                UString& append( size_type num, unicode_char ch );
 
648
                //@}
 
649
 
 
650
                //////////////////////////////////////////////////////////////////////////
 
651
 
 
652
                //!\name insert
 
653
                //@{
 
654
                //! inserts \a ch before the code point denoted by \a i
 
655
                iterator insert( iterator i, const code_point& ch );
 
656
                //! inserts \a str into the current string, at location \a index
 
657
                UString& insert( size_type index, const UString& str );
 
658
                //! inserts \a str into the current string, at location \a index
 
659
                UString& insert( size_type index, const code_point* str ) {
 
660
                        mData.insert( index, str );
 
661
                        return *this;
 
662
                }
 
663
                //! inserts a substring of \a str (starting at \a index2 and \a num code points long) into the current string, at location \a index1
 
664
                UString& insert( size_type index1, const UString& str, size_type index2, size_type num );
 
665
                //! inserts the code points denoted by \a start and \a end into the current string, before the code point specified by \a i
 
666
                void insert( iterator i, iterator start, iterator end );
 
667
                //! inserts \a num code points of \a str into the current string, at location \a index
 
668
                UString& insert( size_type index, const code_point* str, size_type num );
 
669
#if MYGUI_IS_NATIVE_WCHAR_T
 
670
                //! inserts \a num code points of \a str into the current string, at location \a index
 
671
                UString& insert( size_type index, const wchar_t* w_str, size_type num );
 
672
#endif
 
673
                //! inserts \a num code points of \a str into the current string, at location \a index
 
674
                UString& insert( size_type index, const char* c_str, size_type num );
 
675
                //! inserts \a num copies of \a ch into the current string, at location \a index
 
676
                UString& insert( size_type index, size_type num, code_point ch );
 
677
#if MYGUI_IS_NATIVE_WCHAR_T
 
678
                //! inserts \a num copies of \a ch into the current string, at location \a index
 
679
                UString& insert( size_type index, size_type num, wchar_t ch );
 
680
#endif
 
681
                //! inserts \a num copies of \a ch into the current string, at location \a index
 
682
                UString& insert( size_type index, size_type num, char ch );
 
683
                //! inserts \a num copies of \a ch into the current string, at location \a index
 
684
                UString& insert( size_type index, size_type num, unicode_char ch );
 
685
                //! inserts \a num copies of \a ch into the current string, before the code point denoted by \a i
 
686
                void insert( iterator i, size_type num, const code_point& ch );
 
687
#if MYGUI_IS_NATIVE_WCHAR_T
 
688
                //! inserts \a num copies of \a ch into the current string, before the code point denoted by \a i
 
689
                void insert( iterator i, size_type num, const wchar_t& ch );
 
690
#endif
 
691
                //! inserts \a num copies of \a ch into the current string, before the code point denoted by \a i
 
692
                void insert( iterator i, size_type num, const char& ch );
 
693
                //! inserts \a num copies of \a ch into the current string, before the code point denoted by \a i
 
694
                void insert( iterator i, size_type num, const unicode_char& ch );
 
695
                //@}
 
696
 
 
697
                //////////////////////////////////////////////////////////////////////////
 
698
 
 
699
                //!\name erase
 
700
                //@{
 
701
                //! removes the code point pointed to by \a loc, returning an iterator to the next character
 
702
                iterator erase( iterator loc );
 
703
                //! removes the code points between \a start and \a end (including the one at \a start but not the one at \a end), returning an iterator to the code point after the last code point removed
 
704
                iterator erase( iterator start, iterator end );
 
705
                //! removes \a num code points from the current string, starting at \a index
 
706
                UString& erase( size_type index = 0, size_type num = npos );
 
707
                //@}
 
708
 
 
709
                //////////////////////////////////////////////////////////////////////////
 
710
 
 
711
                //!\name replace
 
712
                //@{
 
713
                //! replaces up to \a num1 code points of the current string (starting at \a index1) with \a str
 
714
                UString& replace( size_type index1, size_type num1, const UString& str );
 
715
                //! replaces up to \a num1 code points of the current string (starting at \a index1) with up to \a num2 code points from \a str
 
716
                UString& replace( size_type index1, size_type num1, const UString& str, size_type num2 );
 
717
                //! replaces up to \a num1 code points of the current string (starting at \a index1) with up to \a num2 code points from \a str beginning at \a index2
 
718
                UString& replace( size_type index1, size_type num1, const UString& str, size_type index2, size_type num2 );
 
719
                //! replaces code points in the current string from \a start to \a end with \a num code points from \a str
 
720
                UString& replace( iterator start, iterator end, const UString& str, size_type num = npos );
 
721
                //! replaces up to \a num1 code points in the current string (beginning at \a index) with \c num2 copies of \c ch
 
722
                UString& replace( size_type index, size_type num1, size_type num2, code_point ch );
 
723
                //! replaces the code points in the current string from \a start to \a end with \a num copies of \a ch
 
724
                UString& replace( iterator start, iterator end, size_type num, code_point ch );
 
725
                //@}
 
726
 
 
727
                //////////////////////////////////////////////////////////////////////////
 
728
 
 
729
                //!\name compare
 
730
                //@{
 
731
                //! compare \a str to the current string
 
732
                int compare( const UString& str ) const;
 
733
                //! compare \a str to the current string
 
734
                int compare( const code_point* str ) const;
 
735
                //! compare \a str to a substring of the current string, starting at \a index for \a length characters
 
736
                int compare( size_type index, size_type length, const UString& str ) const;
 
737
                //! compare a substring of \a str to a substring of the current string, where \a index2 and \a length2 refer to \a str and \a index and \a length refer to the current string
 
738
                int compare( size_type index, size_type length, const UString& str, size_type index2, size_type length2 ) const;
 
739
                //! compare a substring of \a str to a substring of the current string, where the substring of \a str begins at zero and is \a length2 characters long, and the substring of the current string begins at \a index and is \a length  characters long
 
740
                int compare( size_type index, size_type length, const code_point* str, size_type length2 ) const;
 
741
#if MYGUI_IS_NATIVE_WCHAR_T
 
742
                //! compare a substring of \a str to a substring of the current string, where the substring of \a str begins at zero and is \a length2 elements long, and the substring of the current string begins at \a index and is \a length characters long
 
743
                int compare( size_type index, size_type length, const wchar_t* w_str, size_type length2 ) const;
 
744
#endif
 
745
                //! compare a substring of \a str to a substring of the current string, where the substring of \a str begins at zero and is \a length2 <b>UTF-8 code points</b> long, and the substring of the current string begins at \a index and is \a length characters long
 
746
                int compare( size_type index, size_type length, const char* c_str, size_type length2 ) const;
 
747
                //@}
 
748
 
 
749
                //////////////////////////////////////////////////////////////////////////
 
750
 
 
751
                //!\name find & rfind
 
752
                //@{
 
753
                //! returns the index of the first occurrence of \a str within the current string, starting at \a index; returns \c UString::npos if nothing is found
 
754
                /*! \a str is a UTF-16 encoded string, but through implicit casting can also be a UTF-8 encoded string (const char* or std::string) */
 
755
                size_type find( const UString& str, size_type index = 0 ) const;
 
756
                //! returns the index of the first occurrence of \a str within the current string and within \a length code points, starting at \a index; returns \c UString::npos if nothing is found
 
757
                /*! \a cp_str is a UTF-16 encoded string */
 
758
                size_type find( const code_point* cp_str, size_type index, size_type length ) const;
 
759
                //! returns the index of the first occurrence of \a str within the current string and within \a length code points, starting at \a index; returns \c UString::npos if nothing is found
 
760
                /*! \a cp_str is a UTF-8 encoded string */
 
761
                size_type find( const char* c_str, size_type index, size_type length ) const;
 
762
#if MYGUI_IS_NATIVE_WCHAR_T
 
763
                //! returns the index of the first occurrence of \a str within the current string and within \a length code points, starting at \a index; returns \c UString::npos if nothing is found
 
764
                /*! \a cp_str is a UTF-16 encoded string */
 
765
                size_type find( const wchar_t* w_str, size_type index, size_type length ) const;
 
766
#endif
 
767
                //! returns the index of the first occurrence \a ch within the current string, starting at \a index; returns \c UString::npos if nothing is found
 
768
                /*! \a ch is only capable of representing Unicode values up to U+007F (127) */
 
769
                size_type find( char ch, size_type index = 0 ) const;
 
770
                //! returns the index of the first occurrence \a ch within the current string, starting at \a index; returns \c UString::npos if nothing is found
 
771
                /*! \a ch is only capable of representing Unicode values up to U+FFFF (65535) */
 
772
                size_type find( code_point ch, size_type index = 0 ) const;
 
773
#if MYGUI_IS_NATIVE_WCHAR_T
 
774
                //! returns the index of the first occurrence \a ch within the current string, starting at \a index; returns \c UString::npos if nothing is found
 
775
                /*! \a ch is only capable of representing Unicode values up to U+FFFF (65535) */
 
776
                size_type find( wchar_t ch, size_type index = 0 ) const;
 
777
#endif
 
778
                //! returns the index of the first occurrence \a ch within the current string, starting at \a index; returns \c UString::npos if nothing is found
 
779
                /*! \a ch can fully represent any Unicode character */
 
780
                size_type find( unicode_char ch, size_type index = 0 ) const;
 
781
 
 
782
                //! returns the location of the first occurrence of \a str in the current string, doing a reverse search from \a index; returns \c UString::npos if nothing is found
 
783
                size_type rfind( const UString& str, size_type index = 0 ) const;
 
784
                //! returns the location of the first occurrence of \a str in the current string, doing a reverse search from \a index, searching at most \a num characters; returns \c UString::npos if nothing is found
 
785
                size_type rfind( const code_point* cp_str, size_type index, size_type num ) const;
 
786
                //! returns the location of the first occurrence of \a str in the current string, doing a reverse search from \a index, searching at most \a num characters; returns \c UString::npos if nothing is found
 
787
                size_type rfind( const char* c_str, size_type index, size_type num ) const;
 
788
#if MYGUI_IS_NATIVE_WCHAR_T
 
789
                //! returns the location of the first occurrence of \a str in the current string, doing a reverse search from \a index, searching at most \a num characters; returns \c UString::npos if nothing is found
 
790
                size_type rfind( const wchar_t* w_str, size_type index, size_type num ) const;
 
791
#endif
 
792
                //! returns the location of the first occurrence of \a ch in the current string, doing a reverse search from \a index; returns \c UString::npos if nothing is found
 
793
                size_type rfind( char ch, size_type index = 0 ) const;
 
794
                //! returns the location of the first occurrence of \a ch in the current string, doing a reverse search from \a index; returns \c UString::npos if nothing is found
 
795
                size_type rfind( code_point ch, size_type index ) const;
 
796
#if MYGUI_IS_NATIVE_WCHAR_T
 
797
                //! returns the location of the first occurrence of \a ch in the current string, doing a reverse search from \a index; returns \c UString::npos if nothing is found
 
798
                size_type rfind( wchar_t ch, size_type index = 0 ) const;
 
799
#endif
 
800
                //! returns the location of the first occurrence of \a ch in the current string, doing a reverse search from \a index; returns \c UString::npos if nothing is found
 
801
                size_type rfind( unicode_char ch, size_type index = 0 ) const;
 
802
                //@}
 
803
 
 
804
                //////////////////////////////////////////////////////////////////////////
 
805
 
 
806
                //!\name find_first/last_(not)_of
 
807
                //@{
 
808
                //! Returns the index of the first character within the current string that matches \b any character in \a str, beginning the search at \a index and searching at most \a num characters; returns \c UString::npos if nothing is found
 
809
                size_type find_first_of( const UString &str, size_type index = 0, size_type num = npos ) const;
 
810
                //! returns the index of the first occurrence of \a ch in the current string, starting the search at \a index; returns \c UString::npos if nothing is found
 
811
                size_type find_first_of( code_point ch, size_type index = 0 ) const;
 
812
                //! returns the index of the first occurrence of \a ch in the current string, starting the search at \a index; returns \c UString::npos if nothing is found
 
813
                size_type find_first_of( char ch, size_type index = 0 ) const;
 
814
#if MYGUI_IS_NATIVE_WCHAR_T
 
815
                //! returns the index of the first occurrence of \a ch in the current string, starting the search at \a index; returns \c UString::npos if nothing is found
 
816
                size_type find_first_of( wchar_t ch, size_type index = 0 ) const;
 
817
#endif
 
818
                //! returns the index of the first occurrence of \a ch in the current string, starting the search at \a index; returns \c UString::npos if nothing is found
 
819
                size_type find_first_of( unicode_char ch, size_type index = 0 ) const;
 
820
 
 
821
                //! returns the index of the first character within the current string that does not match any character in \a str, beginning the search at \a index and searching at most \a num characters; returns \c UString::npos if nothing is found
 
822
                size_type find_first_not_of( const UString& str, size_type index = 0, size_type num = npos ) const;
 
823
                //! returns the index of the first character within the current string that does not match \a ch, starting the search at \a index; returns \c UString::npos if nothing is found
 
824
                size_type find_first_not_of( code_point ch, size_type index = 0 ) const;
 
825
                //! returns the index of the first character within the current string that does not match \a ch, starting the search at \a index; returns \c UString::npos if nothing is found
 
826
                size_type find_first_not_of( char ch, size_type index = 0 ) const;
 
827
#if MYGUI_IS_NATIVE_WCHAR_T
 
828
                //! returns the index of the first character within the current string that does not match \a ch, starting the search at \a index; returns \c UString::npos if nothing is found
 
829
                size_type find_first_not_of( wchar_t ch, size_type index = 0 ) const;
 
830
#endif
 
831
                //! returns the index of the first character within the current string that does not match \a ch, starting the search at \a index; returns \c UString::npos if nothing is found
 
832
                size_type find_first_not_of( unicode_char ch, size_type index = 0 ) const;
 
833
 
 
834
                //! returns the index of the first character within the current string that matches any character in \a str, doing a reverse search from \a index and searching at most \a num characters; returns \c UString::npos if nothing is found
 
835
                size_type find_last_of( const UString& str, size_type index = npos, size_type num = npos ) const;
 
836
                //! returns the index of the first occurrence of \a ch in the current string, doing a reverse search from \a index; returns \c UString::npos if nothing is found
 
837
                size_type find_last_of( code_point ch, size_type index = npos ) const;
 
838
                //! returns the index of the first occurrence of \a ch in the current string, doing a reverse search from \a index; returns \c UString::npos if nothing is found
 
839
                size_type find_last_of( char ch, size_type index = npos ) const {
 
840
                        return find_last_of( static_cast<code_point>( ch ), index );
 
841
                }
 
842
#if MYGUI_IS_NATIVE_WCHAR_T
 
843
                //! returns the index of the first occurrence of \a ch in the current string, doing a reverse search from \a index; returns \c UString::npos if nothing is found
 
844
                size_type find_last_of( wchar_t ch, size_type index = npos ) const;
 
845
#endif
 
846
                //! returns the index of the first occurrence of \a ch in the current string, doing a reverse search from \a index; returns \c UString::npos if nothing is found
 
847
                size_type find_last_of( unicode_char ch, size_type index = npos ) const;
 
848
 
 
849
                //! returns the index of the last character within the current string that does not match any character in \a str, doing a reverse search from \a index; returns \c UString::npos if nothing is found
 
850
                size_type find_last_not_of( const UString& str, size_type index = npos, size_type num = npos ) const;
 
851
                //! returns the index of the last occurrence of a character that does not match \a ch in the current string, doing a reverse search from \a index; returns \c UString::npos if nothing is found
 
852
                size_type find_last_not_of( code_point ch, size_type index = npos ) const;
 
853
                //! returns the index of the last occurrence of a character that does not match \a ch in the current string, doing a reverse search from \a index; returns \c UString::npos if nothing is found
 
854
                size_type find_last_not_of( char ch, size_type index = npos ) const;
 
855
#if MYGUI_IS_NATIVE_WCHAR_T
 
856
                //! returns the index of the last occurrence of a character that does not match \a ch in the current string, doing a reverse search from \a index; returns \c UString::npos if nothing is found
 
857
                size_type find_last_not_of( wchar_t ch, size_type index = npos ) const;
 
858
#endif
 
859
                //! returns the index of the last occurrence of a character that does not match \a ch in the current string, doing a reverse search from \a index; returns \c UString::npos if nothing is found
 
860
                size_type find_last_not_of( unicode_char ch, size_type index = npos ) const;
 
861
                //@}
 
862
 
 
863
                //////////////////////////////////////////////////////////////////////////
 
864
 
 
865
                //!\name Operators
 
866
                //@{
 
867
                //! less than operator
 
868
                bool operator<( const UString& right ) const;
 
869
                //! less than or equal operator
 
870
                bool operator<=( const UString& right ) const;
 
871
                //! greater than operator
 
872
                bool operator>( const UString& right ) const;
 
873
                //! greater than or equal operator
 
874
                bool operator>=( const UString& right ) const;
 
875
                //! equality operator
 
876
                bool operator==( const UString& right ) const;
 
877
                //! inequality operator
 
878
                bool operator!=( const UString& right ) const;
 
879
                //! assignment operator, implicitly casts all compatible types
 
880
                UString& operator=( const UString& s );
 
881
                //! assignment operator
 
882
                UString& operator=( code_point ch );
 
883
                //! assignment operator
 
884
                UString& operator=( char ch );
 
885
#if MYGUI_IS_NATIVE_WCHAR_T
 
886
                //! assignment operator
 
887
                UString& operator=( wchar_t ch );
 
888
#endif
 
889
                //! assignment operator
 
890
                UString& operator=( unicode_char ch );
 
891
                //! code point dereference operator
 
892
                code_point& operator[]( size_type index );
 
893
                //! code point dereference operator
 
894
                const code_point& operator[]( size_type index ) const;
 
895
                //@}
 
896
 
 
897
                //////////////////////////////////////////////////////////////////////////
 
898
 
 
899
                //!\name Implicit Cast Operators
 
900
                //@{
 
901
                //! implicit cast to std::string
 
902
                operator std::string() const;
 
903
                //! implicit cast to std::wstring
 
904
                operator std::wstring() const;
 
905
                //@}
 
906
 
 
907
                //////////////////////////////////////////////////////////////////////////
 
908
 
 
909
                //!\name UTF-16 character encoding/decoding
 
910
                //@{
 
911
                //! returns \c true if \a cp does not match the signature for the lead of follow code point of a surrogate pair in a UTF-16 sequence
 
912
                static bool _utf16_independent_char( code_point cp );
 
913
                //! returns \c true if \a cp matches the signature of a surrogate pair lead character
 
914
                static bool _utf16_surrogate_lead( code_point cp );
 
915
                //! returns \c true if \a cp matches the signature of a surrogate pair following character
 
916
                static bool _utf16_surrogate_follow( code_point cp );
 
917
                //! estimates the number of UTF-16 code points in the sequence starting with \a cp
 
918
                static size_t _utf16_char_length( code_point cp );
 
919
                //! returns the number of UTF-16 code points needed to represent the given UTF-32 character \a cp
 
920
                static size_t _utf16_char_length( unicode_char uc );
 
921
                //! converts the given UTF-16 character buffer \a in_cp to a single UTF-32 Unicode character \a out_uc, returns the number of code points used to create the output character (2 for surrogate pairs, otherwise 1)
 
922
                /*! This function does it's best to prevent error conditions, verifying complete
 
923
                surrogate pairs before applying the algorithm. In the event that half of a pair
 
924
                is found it will happily generate a value in the 0xD800 - 0xDFFF range, which is
 
925
                normally an invalid Unicode value but we preserve them for use as sentinel values. */
 
926
                static size_t _utf16_to_utf32( const code_point in_cp[2], unicode_char& out_uc );
 
927
                //! writes the given UTF-32 \a uc_in to the buffer location \a out_cp using UTF-16 encoding, returns the number of code points used to encode the input (always 1 or 2)
 
928
                /*! This function, like its counterpart, will happily create invalid UTF-16 surrogate pairs. These
 
929
                invalid entries will be created for any value of \c in_uc that falls in the range U+D800 - U+DFFF.
 
930
                These are generally useful as sentinel values to represent various program specific conditions.
 
931
                \note This function will also pass through any single UTF-16 code point without modification,
 
932
                making it a safe method of ensuring a stream that is unknown UTF-32 or UTF-16 is truly UTF-16.*/
 
933
                static size_t _utf32_to_utf16( const unicode_char& in_uc, code_point out_cp[2] );
 
934
                //@}
 
935
 
 
936
                //////////////////////////////////////////////////////////////////////////
 
937
 
 
938
                //!\name UTF-8 character encoding/decoding
 
939
                //@{
 
940
                //! returns \c true if \a cp is the beginning of a UTF-8 sequence
 
941
                static bool _utf8_start_char( unsigned char cp );
 
942
                //! estimates the number of UTF-8 code points in the sequence starting with \a cp
 
943
                static size_t _utf8_char_length( unsigned char cp );
 
944
                //! returns the number of UTF-8 code points needed to represent the given UTF-32 character \a cp
 
945
                static size_t _utf8_char_length( unicode_char uc );
 
946
 
 
947
                //! converts the given UTF-8 character buffer to a single UTF-32 Unicode character, returns the number of bytes used to create the output character (maximum of 6)
 
948
                static size_t _utf8_to_utf32( const unsigned char in_cp[6], unicode_char& out_uc );
 
949
                //! writes the given UTF-32 \a uc_in to the buffer location \a out_cp using UTF-8 encoding, returns the number of bytes used to encode the input
 
950
                static size_t _utf32_to_utf8( const unicode_char& in_uc, unsigned char out_cp[6] );
 
951
 
 
952
                //! verifies a UTF-8 stream, returning the total number of Unicode characters found
 
953
                static size_type _verifyUTF8( const unsigned char* c_str );
 
954
                //! verifies a UTF-8 stream, returning the total number of Unicode characters found
 
955
                static size_type _verifyUTF8( const std::string& str );
 
956
                //@}
 
957
 
 
958
        private:
 
959
                //template<class ITER_TYPE> friend class _iterator;
 
960
                dstring mData;
 
961
 
 
962
                //! buffer data type identifier
 
963
                enum BufferType {
 
964
                        bt_none,
 
965
                        bt_string,
 
966
                        bt_wstring,
 
967
                        bt_utf32string
 
968
                };
 
969
 
 
970
                //! common constructor operations
 
971
                void _init();
 
972
 
 
973
                ///////////////////////////////////////////////////////////////////////
 
974
                // Scratch buffer
 
975
                //! auto cleans the scratch buffer using the proper delete for the stored type
 
976
                void _cleanBuffer() const;
 
977
 
 
978
                //! create a std::string in the scratch buffer area
 
979
                void _getBufferStr() const;
 
980
                //! create a std::wstring in the scratch buffer area
 
981
                void _getBufferWStr() const;
 
982
                //! create a utf32string in the scratch buffer area
 
983
                void _getBufferUTF32Str() const;
 
984
 
 
985
                void _load_buffer_UTF8() const;
 
986
                void _load_buffer_WStr() const;
 
987
                void _load_buffer_UTF32() const;
 
988
 
 
989
                mutable BufferType m_bufferType; // identifies the data type held in m_buffer
 
990
                mutable size_t m_bufferSize; // size of the CString buffer
 
991
 
 
992
                // multi-purpose buffer used everywhere we need a throw-away buffer
 
993
                union {
 
994
                        mutable void* mVoidBuffer;
 
995
                        mutable std::string* mStrBuffer;
 
996
                        mutable std::wstring* mWStrBuffer;
 
997
                        mutable utf32string* mUTF32StrBuffer;
 
998
                }
 
999
                m_buffer;
 
1000
        };
 
1001
 
 
1002
        //! string addition operator \relates UString
 
1003
        inline UString operator+( const UString& s1, const UString& s2 ) {
 
1004
                return UString( s1 ).append( s2 );
 
1005
        }
 
1006
        //! string addition operator \relates UString
 
1007
        inline UString operator+( const UString& s1, UString::code_point c ) {
 
1008
                return UString( s1 ).append( 1, c );
 
1009
        }
 
1010
        //! string addition operator \relates UString
 
1011
        inline UString operator+( const UString& s1, UString::unicode_char c ) {
 
1012
                return UString( s1 ).append( 1, c );
 
1013
        }
 
1014
        //! string addition operator \relates UString
 
1015
        inline UString operator+( const UString& s1, char c ) {
 
1016
                return UString( s1 ).append( 1, c );
 
1017
        }
 
1018
#if MYGUI_IS_NATIVE_WCHAR_T
 
1019
        //! string addition operator \relates UString
 
1020
        inline UString operator+( const UString& s1, wchar_t c ) {
 
1021
                return UString( s1 ).append( 1, c );
 
1022
        }
 
1023
#endif
 
1024
        //! string addition operator \relates UString
 
1025
        inline UString operator+( UString::code_point c, const UString& s2 ) {
 
1026
                return UString().append( 1, c ).append( s2 );
 
1027
        }
 
1028
        //! string addition operator \relates UString
 
1029
        inline UString operator+( UString::unicode_char c, const UString& s2 ) {
 
1030
                return UString().append( 1, c ).append( s2 );
 
1031
        }
 
1032
        //! string addition operator \relates UString
 
1033
        inline UString operator+( char c, const UString& s2 ) {
 
1034
                return UString().append( 1, c ).append( s2 );
 
1035
        }
 
1036
#if MYGUI_IS_NATIVE_WCHAR_T
 
1037
        //! string addition operator \relates UString
 
1038
        inline UString operator+( wchar_t c, const UString& s2 ) {
 
1039
                return UString().append( 1, c ).append( s2 );
 
1040
        }
 
1041
#endif
 
1042
 
 
1043
        // (const) forward iterator common operators
 
1044
        inline UString::size_type operator-( const UString::_const_fwd_iterator& left, const UString::_const_fwd_iterator& right ) {
 
1045
                return ( left.mIter - right.mIter );
 
1046
        }
 
1047
        inline bool operator==( const UString::_const_fwd_iterator& left, const UString::_const_fwd_iterator& right ) {
 
1048
                return left.mIter == right.mIter;
 
1049
        }
 
1050
        inline bool operator!=( const UString::_const_fwd_iterator& left, const UString::_const_fwd_iterator& right ) {
 
1051
                return left.mIter != right.mIter;
 
1052
        }
 
1053
        inline bool operator<( const UString::_const_fwd_iterator& left, const UString::_const_fwd_iterator& right ) {
 
1054
                return left.mIter < right.mIter;
 
1055
        }
 
1056
        inline bool operator<=( const UString::_const_fwd_iterator& left, const UString::_const_fwd_iterator& right ) {
 
1057
                return left.mIter <= right.mIter;
 
1058
        }
 
1059
        inline bool operator>( const UString::_const_fwd_iterator& left, const UString::_const_fwd_iterator& right ) {
 
1060
                return left.mIter > right.mIter;
 
1061
        }
 
1062
        inline bool operator>=( const UString::_const_fwd_iterator& left, const UString::_const_fwd_iterator& right ) {
 
1063
                return left.mIter >= right.mIter;
 
1064
        }
 
1065
 
 
1066
        // (const) reverse iterator common operators
 
1067
        // NB: many of these operations are evaluated in reverse because this is a reverse iterator wrapping a forward iterator
 
1068
        inline UString::size_type operator-( const UString::_const_rev_iterator& left, const UString::_const_rev_iterator& right ) {
 
1069
                return ( right.mIter - left.mIter );
 
1070
        }
 
1071
        inline bool operator==( const UString::_const_rev_iterator& left, const UString::_const_rev_iterator& right ) {
 
1072
                return left.mIter == right.mIter;
 
1073
        }
 
1074
        inline bool operator!=( const UString::_const_rev_iterator& left, const UString::_const_rev_iterator& right ) {
 
1075
                return left.mIter != right.mIter;
 
1076
        }
 
1077
        inline bool operator<( const UString::_const_rev_iterator& left, const UString::_const_rev_iterator& right ) {
 
1078
                return right.mIter < left.mIter;
 
1079
        }
 
1080
        inline bool operator<=( const UString::_const_rev_iterator& left, const UString::_const_rev_iterator& right ) {
 
1081
                return right.mIter <= left.mIter;
 
1082
        }
 
1083
        inline bool operator>( const UString::_const_rev_iterator& left, const UString::_const_rev_iterator& right ) {
 
1084
                return right.mIter > left.mIter;
 
1085
        }
 
1086
        inline bool operator>=( const UString::_const_rev_iterator& left, const UString::_const_rev_iterator& right ) {
 
1087
                return right.mIter >= left.mIter;
 
1088
        }
 
1089
 
 
1090
        //! std::ostream write operator \relates UString
 
1091
        inline std::ostream& operator << ( std::ostream& os, const UString& s ) {
 
1092
                return os << s.asUTF8();
 
1093
        }
 
1094
 
 
1095
        //! std::wostream write operator \relates UString
 
1096
        inline std::wostream& operator << ( std::wostream& os, const UString& s ) {
 
1097
                return os << s.asWStr();
 
1098
        }
 
1099
 
 
1100
} // namespace MyGUI
 
1101
 
 
1102
#if MYGUI_COMPILER == MYGUI_COMPILER_MSVC
 
1103
#       pragma warning (pop)
 
1104
#endif
 
1105
 
 
1106
#endif  // __MYGUI_U_STRING_H__