00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef __MYGUI_U_STRING_H__
00028 #define __MYGUI_U_STRING_H__
00029
00030
00031 #include "MyGUI_Prerequest.h"
00032 #include "MyGUI_Types.h"
00033
00034
00035 #include <iterator>
00036 #include <string>
00037 #include <stdexcept>
00038
00039
00040
00041
00042
00043
00044
00045
00046 #if MYGUI_COMPILER == MYGUI_COMPILER_MSVC && (1300 <= MYGUI_COMP_VER && MYGUI_COMP_VER <= 1310)
00047
00048 # if defined(_DLL_CPPLIB)
00049
00050 namespace std
00051 {
00052 template class _CRTIMP2 basic_string<unsigned short, char_traits<unsigned short>,
00053 allocator<unsigned short> >;
00054
00055 template class _CRTIMP2 basic_string<__wchar_t, char_traits<__wchar_t>,
00056 allocator<__wchar_t> >;
00057 }
00058
00059 # endif // defined(_DLL_CPPLIB)
00060
00061 #endif // MYGUI_COMPILER == MYGUI_COMPILER_MSVC && MYGUI_COMP_VER == 1300
00062
00063
00064 namespace MyGUI
00065 {
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100 #ifdef __STDC_ISO_10646__
00101
00102
00103 #else // #ifdef __STDC_ISO_10646__
00104 #if defined( __WIN32__ ) || defined( _WIN32 )
00105 #define WCHAR_UTF16 // All currently known Windows platforms utilize UTF-16 encoding in wchar_t
00106 #else // #if defined( __WIN32__ ) || defined( _WIN32 )
00107 #if MYGUI_COMPILER != MYGUI_COMPILER_GCCE
00108 #if WCHAR_MAX <= 0xFFFF // this is a last resort fall back test; WCHAR_MAX is defined in <wchar.h>
00109 #define WCHAR_UTF16 // best we can tell, wchar_t is not larger than 16-bit
00110 #endif // #if WCHAR_MAX <= 0xFFFF
00111 #endif
00112 #endif // #if defined( __WIN32__ ) || defined( _WIN32 )
00113 #endif // #ifdef __STDC_ISO_10646__
00114
00115
00116
00117
00118 #if MYGUI_COMPILER == MYGUI_COMPILER_MSVC
00119
00120
00121
00122
00123
00124 # if defined(_NATIVE_WCHAR_T_DEFINED)
00125 # define MYGUI_IS_NATIVE_WCHAR_T 1
00126 # else
00127 # define MYGUI_IS_NATIVE_WCHAR_T 0
00128 # endif
00129 #elif MYGUI_PLATFORM == MYGUI_PLATFORM_SYMBIAN
00130 # define MYGUI_IS_NATIVE_WCHAR_T 0
00131 #else // MYGUI_COMPILER != MYGUI_COMPILER_MSVC
00132
00133
00134 # define MYGUI_IS_NATIVE_WCHAR_T 1
00135
00136 #endif // MYGUI_COMPILER == MYGUI_COMPILER_MSVC
00137
00139
00164 class MYGUI_EXPORT UString {
00165
00166 static const unsigned char _lead1 = 0xC0;
00167 static const unsigned char _lead1_mask = 0x1F;
00168 static const unsigned char _lead2 = 0xE0;
00169 static const unsigned char _lead2_mask = 0x0F;
00170 static const unsigned char _lead3 = 0xF0;
00171 static const unsigned char _lead3_mask = 0x07;
00172 static const unsigned char _lead4 = 0xF8;
00173 static const unsigned char _lead4_mask = 0x03;
00174 static const unsigned char _lead5 = 0xFC;
00175 static const unsigned char _lead5_mask = 0x01;
00176 static const unsigned char _cont = 0x80;
00177 static const unsigned char _cont_mask = 0x3F;
00178
00179 public:
00181 typedef size_t size_type;
00183 static const size_type npos = static_cast<size_type>(~0);
00184
00186 typedef uint32 unicode_char;
00187
00189 typedef uint16 code_point;
00190
00192 typedef code_point value_type;
00193
00194 typedef std::basic_string<code_point> dstring;
00195
00197 typedef std::basic_string<unicode_char> utf32string;
00198
00200 class MYGUI_EXPORT invalid_data: public std::runtime_error {
00201 public:
00203 explicit invalid_data( const std::string& _Message ): std::runtime_error( _Message ) {
00204
00205 }
00206 };
00207
00208
00210 class MYGUI_EXPORT _base_iterator: public std::iterator<std::random_access_iterator_tag, value_type> {
00211 friend class UString;
00212 protected:
00213 _base_iterator();
00214
00215 void _seekFwd( size_type c );
00216 void _seekRev( size_type c );
00217 void _become( const _base_iterator& i );
00218 bool _test_begin() const;
00219 bool _test_end() const;
00220 size_type _get_index() const;
00221 void _jump_to( size_type index );
00222
00223 unicode_char _getCharacter() const;
00224 int _setCharacter( unicode_char uc );
00225
00226 void _moveNext();
00227 void _movePrev();
00228
00229 dstring::iterator mIter;
00230 UString* mString;
00231 };
00232
00233
00234
00235
00236 class _const_fwd_iterator;
00237
00239 class MYGUI_EXPORT _fwd_iterator: public _base_iterator {
00240 friend class _const_fwd_iterator;
00241 public:
00242 _fwd_iterator();
00243 _fwd_iterator( const _fwd_iterator& i );
00244
00246 _fwd_iterator& operator++();
00248 _fwd_iterator operator++( int );
00249
00251 _fwd_iterator& operator--();
00253 _fwd_iterator operator--( int );
00254
00256 _fwd_iterator operator+( difference_type n );
00258 _fwd_iterator operator-( difference_type n );
00259
00261 _fwd_iterator& operator+=( difference_type n );
00263 _fwd_iterator& operator-=( difference_type n );
00264
00266 value_type& operator*() const;
00267
00269 value_type& operator[]( difference_type n ) const;
00270
00272 _fwd_iterator& moveNext();
00274 _fwd_iterator& movePrev();
00276 unicode_char getCharacter() const;
00278 int setCharacter( unicode_char uc );
00279 };
00280
00281
00282
00283
00285 class MYGUI_EXPORT _const_fwd_iterator: public _base_iterator {
00286 public:
00287 _const_fwd_iterator();
00288 _const_fwd_iterator( const _const_fwd_iterator& i );
00289 _const_fwd_iterator( const _fwd_iterator& i );
00290
00292 _const_fwd_iterator& operator++();
00294 _const_fwd_iterator operator++( int );
00295
00297 _const_fwd_iterator& operator--();
00299 _const_fwd_iterator operator--( int );
00300
00302 _const_fwd_iterator operator+( difference_type n );
00304 _const_fwd_iterator operator-( difference_type n );
00305
00307 _const_fwd_iterator& operator+=( difference_type n );
00309 _const_fwd_iterator& operator-=( difference_type n );
00310
00312 const value_type& operator*() const;
00313
00315 const value_type& operator[]( difference_type n ) const;
00316
00318 _const_fwd_iterator& moveNext();
00320 _const_fwd_iterator& movePrev();
00322 unicode_char getCharacter() const;
00323
00325 friend size_type operator-( const _const_fwd_iterator& left, const _const_fwd_iterator& right );
00327 friend bool operator==( const _const_fwd_iterator& left, const _const_fwd_iterator& right );
00329 friend bool operator!=( const _const_fwd_iterator& left, const _const_fwd_iterator& right );
00331 friend bool operator<( const _const_fwd_iterator& left, const _const_fwd_iterator& right );
00333 friend bool operator<=( const _const_fwd_iterator& left, const _const_fwd_iterator& right );
00335 friend bool operator>( const _const_fwd_iterator& left, const _const_fwd_iterator& right );
00337 friend bool operator>=( const _const_fwd_iterator& left, const _const_fwd_iterator& right );
00338
00339 };
00340
00341
00342
00343
00344 class _const_rev_iterator;
00346 class MYGUI_EXPORT _rev_iterator: public _base_iterator {
00347 friend class _const_rev_iterator;
00348 public:
00349 _rev_iterator();
00350 _rev_iterator( const _rev_iterator& i );
00351
00353 _rev_iterator& operator++();
00355 _rev_iterator operator++( int );
00356
00358 _rev_iterator& operator--();
00360 _rev_iterator operator--( int );
00361
00363 _rev_iterator operator+( difference_type n );
00365 _rev_iterator operator-( difference_type n );
00366
00368 _rev_iterator& operator+=( difference_type n );
00370 _rev_iterator& operator-=( difference_type n );
00371
00373 value_type& operator*() const;
00374
00376 value_type& operator[]( difference_type n ) const;
00377 };
00378
00380 class MYGUI_EXPORT _const_rev_iterator: public _base_iterator {
00381 public:
00382 _const_rev_iterator();
00383 _const_rev_iterator( const _const_rev_iterator& i );
00384 _const_rev_iterator( const _rev_iterator& i );
00386 _const_rev_iterator& operator++();
00388 _const_rev_iterator operator++( int );
00389
00391 _const_rev_iterator& operator--();
00393 _const_rev_iterator operator--( int );
00394
00396 _const_rev_iterator operator+( difference_type n );
00398 _const_rev_iterator operator-( difference_type n );
00399
00401 _const_rev_iterator& operator+=( difference_type n );
00403 _const_rev_iterator& operator-=( difference_type n );
00404
00406 const value_type& operator*() const;
00407
00409 const value_type& operator[]( difference_type n ) const;
00410
00412 friend size_type operator-( const _const_rev_iterator& left, const _const_rev_iterator& right );
00414 friend bool operator==( const _const_rev_iterator& left, const _const_rev_iterator& right );
00416 friend bool operator!=( const _const_rev_iterator& left, const _const_rev_iterator& right );
00418 friend bool operator<( const _const_rev_iterator& left, const _const_rev_iterator& right );
00420 friend bool operator<=( const _const_rev_iterator& left, const _const_rev_iterator& right );
00422 friend bool operator>( const _const_rev_iterator& left, const _const_rev_iterator& right );
00424 friend bool operator>=( const _const_rev_iterator& left, const _const_rev_iterator& right );
00425 };
00426
00427
00428 typedef _fwd_iterator iterator;
00429 typedef _rev_iterator reverse_iterator;
00430 typedef _const_fwd_iterator const_iterator;
00431 typedef _const_rev_iterator const_reverse_iterator;
00432
00433
00435
00436
00437 UString();
00439 UString( const UString& copy );
00441 UString( size_type length, const code_point& ch );
00443 UString( const code_point* str );
00445 UString( const code_point* str, size_type length );
00447 UString( const UString& str, size_type index, size_type length );
00448 #if MYGUI_IS_NATIVE_WCHAR_T
00450 UString( const wchar_t* w_str );
00452 UString( const wchar_t* w_str, size_type length );
00453 #endif
00455 UString( const std::wstring& wstr );
00457 UString( const char* c_str );
00459 UString( const char* c_str, size_type length );
00461 UString( const std::string& str );
00462
00464 ~UString();
00466
00468
00470
00471
00472 size_type size() const;
00474 size_type length() const;
00476
00477 size_type length_Characters() const;
00479 size_type max_size() const;
00481 void reserve( size_type size );
00483 void resize( size_type num, const code_point& val = 0 );
00485 void swap( UString& from );
00487 bool empty() const;
00489 const code_point* c_str() const;
00491 const code_point* data() const;
00493 size_type capacity() const;
00495 void clear();
00497
00498 UString substr( size_type index, size_type num = npos ) const;
00500 void push_back( unicode_char val );
00501 #if MYGUI_IS_NATIVE_WCHAR_T
00503 void push_back( wchar_t val );
00504 #endif
00506
00508 void push_back( code_point val );
00510
00511 void push_back( char val );
00513 bool inString( unicode_char ch ) const;
00514
00515
00517
00519
00520
00521 const std::string& asUTF8() const;
00523 const char* asUTF8_c_str() const;
00525 const utf32string& asUTF32() const;
00527 const unicode_char* asUTF32_c_str() const;
00529 const std::wstring& asWStr() const;
00531 const wchar_t* asWStr_c_str() const;
00533
00535
00537
00538
00539 code_point& at( size_type loc );
00541 const code_point& at( size_type loc ) const;
00543
00547 unicode_char getChar( size_type loc ) const;
00549
00557 int setChar( size_type loc, unicode_char ch );
00559
00561
00563
00564
00565 iterator begin();
00567 const_iterator begin() const;
00569 iterator end();
00571 const_iterator end() const;
00573 reverse_iterator rbegin();
00575 const_reverse_iterator rbegin() const;
00577 reverse_iterator rend();
00579 const_reverse_iterator rend() const;
00581
00583
00585
00586
00587 UString& assign( iterator start, iterator end );
00589 UString& assign( const UString& str );
00591 UString& assign( const code_point* str );
00593 UString& assign( const code_point* str, size_type num );
00595 UString& assign( const UString& str, size_type index, size_type len );
00597 UString& assign( size_type num, const code_point& ch );
00599 UString& assign( const std::wstring& wstr );
00600 #if MYGUI_IS_NATIVE_WCHAR_T
00602 UString& assign( const wchar_t* w_str );
00604 UString& assign( const wchar_t* w_str, size_type num );
00605 #endif
00607 UString& assign( const std::string& str );
00609 UString& assign( const char* c_str );
00611 UString& assign( const char* c_str, size_type num );
00612
00613
00615
00617
00618
00619 UString& append( const UString& str );
00621 UString& append( const code_point* str );
00623 UString& append( const UString& str, size_type index, size_type len );
00625 UString& append( const code_point* str, size_type num );
00627 UString& append( size_type num, code_point ch );
00629 UString& append( iterator start, iterator end );
00630 #if MYGUI_IS_NATIVE_WCHAR_T
00632 UString& append( const wchar_t* w_str, size_type num );
00634 UString& append( size_type num, wchar_t ch );
00635 #endif
00637 UString& append( const char* c_str, size_type num );
00639 UString& append( size_type num, char ch );
00641 UString& append( size_type num, unicode_char ch );
00642
00643
00645
00647
00648
00649 iterator insert( iterator i, const code_point& ch );
00651 UString& insert( size_type index, const UString& str );
00653 UString& insert( size_type index, const code_point* str ) {
00654 mData.insert( index, str );
00655 return *this;
00656 }
00658 UString& insert( size_type index1, const UString& str, size_type index2, size_type num );
00660 void insert( iterator i, iterator start, iterator end );
00662 UString& insert( size_type index, const code_point* str, size_type num );
00663 #if MYGUI_IS_NATIVE_WCHAR_T
00665 UString& insert( size_type index, const wchar_t* w_str, size_type num );
00666 #endif
00668 UString& insert( size_type index, const char* c_str, size_type num );
00670 UString& insert( size_type index, size_type num, code_point ch );
00671 #if MYGUI_IS_NATIVE_WCHAR_T
00673 UString& insert( size_type index, size_type num, wchar_t ch );
00674 #endif
00676 UString& insert( size_type index, size_type num, char ch );
00678 UString& insert( size_type index, size_type num, unicode_char ch );
00680 void insert( iterator i, size_type num, const code_point& ch );
00681 #if MYGUI_IS_NATIVE_WCHAR_T
00683 void insert( iterator i, size_type num, const wchar_t& ch );
00684 #endif
00686 void insert( iterator i, size_type num, const char& ch );
00688 void insert( iterator i, size_type num, const unicode_char& ch );
00689
00690
00692
00694
00695
00696 iterator erase( iterator loc );
00698 iterator erase( iterator start, iterator end );
00700 UString& erase( size_type index = 0, size_type num = npos );
00702
00704
00706
00707
00708 UString& replace( size_type index1, size_type num1, const UString& str );
00710 UString& replace( size_type index1, size_type num1, const UString& str, size_type num2 );
00712 UString& replace( size_type index1, size_type num1, const UString& str, size_type index2, size_type num2 );
00714 UString& replace( iterator start, iterator end, const UString& str, size_type num = npos );
00716 UString& replace( size_type index, size_type num1, size_type num2, code_point ch );
00718 UString& replace( iterator start, iterator end, size_type num, code_point ch );
00720
00722
00724
00725
00726 int compare( const UString& str ) const;
00728 int compare( const code_point* str ) const;
00730 int compare( size_type index, size_type length, const UString& str ) const;
00732 int compare( size_type index, size_type length, const UString& str, size_type index2, size_type length2 ) const;
00734 int compare( size_type index, size_type length, const code_point* str, size_type length2 ) const;
00735 #if MYGUI_IS_NATIVE_WCHAR_T
00737 int compare( size_type index, size_type length, const wchar_t* w_str, size_type length2 ) const;
00738 #endif
00740 int compare( size_type index, size_type length, const char* c_str, size_type length2 ) const;
00741
00742
00744
00746
00747
00748
00749 size_type find( const UString& str, size_type index = 0 ) const;
00751
00752 size_type find( const code_point* cp_str, size_type index, size_type length ) const;
00754
00755 size_type find( const char* c_str, size_type index, size_type length ) const;
00756 #if MYGUI_IS_NATIVE_WCHAR_T
00758
00759 size_type find( const wchar_t* w_str, size_type index, size_type length ) const;
00760 #endif
00762
00763 size_type find( char ch, size_type index = 0 ) const;
00765
00766 size_type find( code_point ch, size_type index = 0 ) const;
00767 #if MYGUI_IS_NATIVE_WCHAR_T
00769
00770 size_type find( wchar_t ch, size_type index = 0 ) const;
00771 #endif
00773
00774 size_type find( unicode_char ch, size_type index = 0 ) const;
00775
00777 size_type rfind( const UString& str, size_type index = 0 ) const;
00779 size_type rfind( const code_point* cp_str, size_type index, size_type num ) const;
00781 size_type rfind( const char* c_str, size_type index, size_type num ) const;
00782 #if MYGUI_IS_NATIVE_WCHAR_T
00784 size_type rfind( const wchar_t* w_str, size_type index, size_type num ) const;
00785 #endif
00787 size_type rfind( char ch, size_type index = 0 ) const;
00789 size_type rfind( code_point ch, size_type index ) const;
00790 #if MYGUI_IS_NATIVE_WCHAR_T
00792 size_type rfind( wchar_t ch, size_type index = 0 ) const;
00793 #endif
00795 size_type rfind( unicode_char ch, size_type index = 0 ) const;
00796
00797
00799
00801
00802
00803 size_type find_first_of( const UString &str, size_type index = 0, size_type num = npos ) const;
00805 size_type find_first_of( code_point ch, size_type index = 0 ) const;
00807 size_type find_first_of( char ch, size_type index = 0 ) const;
00808 #if MYGUI_IS_NATIVE_WCHAR_T
00810 size_type find_first_of( wchar_t ch, size_type index = 0 ) const;
00811 #endif
00813 size_type find_first_of( unicode_char ch, size_type index = 0 ) const;
00814
00816 size_type find_first_not_of( const UString& str, size_type index = 0, size_type num = npos ) const;
00818 size_type find_first_not_of( code_point ch, size_type index = 0 ) const;
00820 size_type find_first_not_of( char ch, size_type index = 0 ) const;
00821 #if MYGUI_IS_NATIVE_WCHAR_T
00823 size_type find_first_not_of( wchar_t ch, size_type index = 0 ) const;
00824 #endif
00826 size_type find_first_not_of( unicode_char ch, size_type index = 0 ) const;
00827
00829 size_type find_last_of( const UString& str, size_type index = npos, size_type num = npos ) const;
00831 size_type find_last_of( code_point ch, size_type index = npos ) const;
00833 size_type find_last_of( char ch, size_type index = npos ) const {
00834 return find_last_of( static_cast<code_point>( ch ), index );
00835 }
00836 #if MYGUI_IS_NATIVE_WCHAR_T
00838 size_type find_last_of( wchar_t ch, size_type index = npos ) const;
00839 #endif
00841 size_type find_last_of( unicode_char ch, size_type index = npos ) const;
00842
00844 size_type find_last_not_of( const UString& str, size_type index = npos, size_type num = npos ) const;
00846 size_type find_last_not_of( code_point ch, size_type index = npos ) const;
00848 size_type find_last_not_of( char ch, size_type index = npos ) const;
00849 #if MYGUI_IS_NATIVE_WCHAR_T
00851 size_type find_last_not_of( wchar_t ch, size_type index = npos ) const;
00852 #endif
00854 size_type find_last_not_of( unicode_char ch, size_type index = npos ) const;
00855
00856
00858
00860
00861
00862 bool operator<( const UString& right ) const;
00864 bool operator<=( const UString& right ) const;
00866 bool operator>( const UString& right ) const;
00868 bool operator>=( const UString& right ) const;
00870 bool operator==( const UString& right ) const;
00872 bool operator!=( const UString& right ) const;
00874 UString& operator=( const UString& s );
00876 UString& operator=( code_point ch );
00878 UString& operator=( char ch );
00879 #if MYGUI_IS_NATIVE_WCHAR_T
00881 UString& operator=( wchar_t ch );
00882 #endif
00884 UString& operator=( unicode_char ch );
00886 code_point& operator[]( size_type index );
00888 const code_point& operator[]( size_type index ) const;
00889
00890
00892
00894
00895
00896 operator std::string() const;
00898 operator std::wstring() const;
00900
00902
00904
00905
00906 static bool _utf16_independent_char( code_point cp );
00908 static bool _utf16_surrogate_lead( code_point cp );
00910 static bool _utf16_surrogate_follow( code_point cp );
00912 static size_t _utf16_char_length( code_point cp );
00914 static size_t _utf16_char_length( unicode_char uc );
00916
00920 static size_t _utf16_to_utf32( const code_point in_cp[2], unicode_char& out_uc );
00922
00927 static size_t _utf32_to_utf16( const unicode_char& in_uc, code_point out_cp[2] );
00929
00931
00933
00934
00935 static bool _utf8_start_char( unsigned char cp );
00937 static size_t _utf8_char_length( unsigned char cp );
00939 static size_t _utf8_char_length( unicode_char uc );
00940
00942 static size_t _utf8_to_utf32( const unsigned char in_cp[6], unicode_char& out_uc );
00944 static size_t _utf32_to_utf8( const unicode_char& in_uc, unsigned char out_cp[6] );
00945
00947 static size_type _verifyUTF8( const unsigned char* c_str );
00949 static size_type _verifyUTF8( const std::string& str );
00951
00952 private:
00953
00954 dstring mData;
00955
00957 enum BufferType {
00958 bt_none,
00959 bt_string,
00960 bt_wstring,
00961 bt_utf32string
00962 };
00963
00965 void _init();
00966
00968
00970 void _cleanBuffer() const;
00971
00973 void _getBufferStr() const;
00975 void _getBufferWStr() const;
00977 void _getBufferUTF32Str() const;
00978
00979 void _load_buffer_UTF8() const;
00980 void _load_buffer_WStr() const;
00981 void _load_buffer_UTF32() const;
00982
00983 mutable BufferType m_bufferType;
00984 mutable size_t m_bufferSize;
00985
00986
00987 union {
00988 mutable void* mVoidBuffer;
00989 mutable std::string* mStrBuffer;
00990 mutable std::wstring* mWStrBuffer;
00991 mutable utf32string* mUTF32StrBuffer;
00992 }
00993 m_buffer;
00994 };
00995
00997 inline UString operator+( const UString& s1, const UString& s2 ) {
00998 return UString( s1 ).append( s2 );
00999 }
01001 inline UString operator+( const UString& s1, UString::code_point c ) {
01002 return UString( s1 ).append( 1, c );
01003 }
01005 inline UString operator+( const UString& s1, UString::unicode_char c ) {
01006 return UString( s1 ).append( 1, c );
01007 }
01009 inline UString operator+( const UString& s1, char c ) {
01010 return UString( s1 ).append( 1, c );
01011 }
01012 #if MYGUI_IS_NATIVE_WCHAR_T
01014 inline UString operator+( const UString& s1, wchar_t c ) {
01015 return UString( s1 ).append( 1, c );
01016 }
01017 #endif
01019 inline UString operator+( UString::code_point c, const UString& s2 ) {
01020 return UString().append( 1, c ).append( s2 );
01021 }
01023 inline UString operator+( UString::unicode_char c, const UString& s2 ) {
01024 return UString().append( 1, c ).append( s2 );
01025 }
01027 inline UString operator+( char c, const UString& s2 ) {
01028 return UString().append( 1, c ).append( s2 );
01029 }
01030 #if MYGUI_IS_NATIVE_WCHAR_T
01032 inline UString operator+( wchar_t c, const UString& s2 ) {
01033 return UString().append( 1, c ).append( s2 );
01034 }
01035 #endif
01036
01037
01038 inline UString::size_type operator-( const UString::_const_fwd_iterator& left, const UString::_const_fwd_iterator& right ) {
01039 return ( left.mIter - right.mIter );
01040 }
01041 inline bool operator==( const UString::_const_fwd_iterator& left, const UString::_const_fwd_iterator& right ) {
01042 return left.mIter == right.mIter;
01043 }
01044 inline bool operator!=( const UString::_const_fwd_iterator& left, const UString::_const_fwd_iterator& right ) {
01045 return left.mIter != right.mIter;
01046 }
01047 inline bool operator<( const UString::_const_fwd_iterator& left, const UString::_const_fwd_iterator& right ) {
01048 return left.mIter < right.mIter;
01049 }
01050 inline bool operator<=( const UString::_const_fwd_iterator& left, const UString::_const_fwd_iterator& right ) {
01051 return left.mIter <= right.mIter;
01052 }
01053 inline bool operator>( const UString::_const_fwd_iterator& left, const UString::_const_fwd_iterator& right ) {
01054 return left.mIter > right.mIter;
01055 }
01056 inline bool operator>=( const UString::_const_fwd_iterator& left, const UString::_const_fwd_iterator& right ) {
01057 return left.mIter >= right.mIter;
01058 }
01059
01060
01061
01062 inline UString::size_type operator-( const UString::_const_rev_iterator& left, const UString::_const_rev_iterator& right ) {
01063 return ( right.mIter - left.mIter );
01064 }
01065 inline bool operator==( const UString::_const_rev_iterator& left, const UString::_const_rev_iterator& right ) {
01066 return left.mIter == right.mIter;
01067 }
01068 inline bool operator!=( const UString::_const_rev_iterator& left, const UString::_const_rev_iterator& right ) {
01069 return left.mIter != right.mIter;
01070 }
01071 inline bool operator<( const UString::_const_rev_iterator& left, const UString::_const_rev_iterator& right ) {
01072 return right.mIter < left.mIter;
01073 }
01074 inline bool operator<=( const UString::_const_rev_iterator& left, const UString::_const_rev_iterator& right ) {
01075 return right.mIter <= left.mIter;
01076 }
01077 inline bool operator>( const UString::_const_rev_iterator& left, const UString::_const_rev_iterator& right ) {
01078 return right.mIter > left.mIter;
01079 }
01080 inline bool operator>=( const UString::_const_rev_iterator& left, const UString::_const_rev_iterator& right ) {
01081 return right.mIter >= left.mIter;
01082 }
01083
01085 inline std::ostream& operator << ( std::ostream& os, const UString& s ) {
01086 return os << s.asUTF8();
01087 }
01088
01090 inline std::wostream& operator << ( std::wostream& os, const UString& s ) {
01091 return os << s.asWStr();
01092 }
01093
01094 }
01095
01096 #endif // __MYGUI_U_STRING_H__