X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6286f3c8fc47e21bb2ab8cd48ecad5980f3320d3..0555b2a0a3c509687e7fc5aeb160f5171b7e6311:/include/wx/ustring.h?ds=inline diff --git a/include/wx/ustring.h b/include/wx/ustring.h index a3d8209440..5b0d377e74 100644 --- a/include/wx/ustring.h +++ b/include/wx/ustring.h @@ -3,7 +3,7 @@ // Purpose: 32-bit string (UCS-4) // Author: Robert Roebling // Copyright: (c) Robert Roebling -// RCS-ID: $Id: tab.h 37400 2006-02-09 00:28:34Z VZ $ +// RCS-ID: $Id$ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -17,16 +17,27 @@ #if SIZEOF_WCHAR_T == 2 typedef wxWCharBuffer wxU16CharBuffer; +typedef wxScopedWCharBuffer wxScopedU16CharBuffer; #else typedef wxCharTypeBuffer wxU16CharBuffer; +typedef wxScopedCharTypeBuffer wxScopedU16CharBuffer; #endif #if SIZEOF_WCHAR_T == 4 typedef wxWCharBuffer wxU32CharBuffer; +typedef wxScopedWCharBuffer wxScopedU32CharBuffer; #else typedef wxCharTypeBuffer wxU32CharBuffer; +typedef wxScopedCharTypeBuffer wxScopedU32CharBuffer; #endif +#ifdef __VISUALC__ + // "non dll-interface class 'std::basic_string' used as base + // interface for dll-interface class 'wxString'" -- this is OK in our case + // (and warning is unavoidable anyhow) + #pragma warning(push) + #pragma warning(disable:4275) +#endif class WXDLLIMPEXP_BASE wxUString: public std::basic_string { @@ -34,16 +45,15 @@ public: wxUString() { } wxUString( const wxChar32 *str ) { assign(str); } - wxUString( const wxUString &str ) { assign(str); } - wxUString( const wxU32CharBuffer &buf ) { assign(buf); } + wxUString( const wxScopedU32CharBuffer &buf ) { assign(buf); } wxUString( const char *str ) { assign(str); } - wxUString( const wxCharBuffer &buf ) { assign(buf); } + wxUString( const wxScopedCharBuffer &buf ) { assign(buf); } wxUString( const char *str, const wxMBConv &conv ) { assign(str,conv); } - wxUString( const wxCharBuffer &buf, const wxMBConv &conv ) { assign(buf,conv); } + wxUString( const wxScopedCharBuffer &buf, const wxMBConv &conv ) { assign(buf,conv); } wxUString( const wxChar16 *str ) { assign(str); } - wxUString( const wxU16CharBuffer &buf ) { assign(buf); } + wxUString( const wxScopedU16CharBuffer &buf ) { assign(buf); } wxUString( const wxCStrData *cstr ) { assign(cstr); } wxUString( const wxString &str ) { assign(str); } @@ -116,11 +126,11 @@ public: // conversions - wxCharBuffer utf8_str() const; - wxU16CharBuffer utf16_str() const; + wxScopedCharBuffer utf8_str() const; + wxScopedU16CharBuffer utf16_str() const; #if SIZEOF_WCHAR_T == 2 - wxWCharBuffer wc_str() const + wxScopedWCharBuffer wc_str() const { return utf16_str(); } @@ -145,13 +155,13 @@ public: } #if wxUSE_UNICODE_UTF8 - wxCharBuffer wx_str() + wxScopedCharBuffer wx_str() { return utf8_str(); } #else #if SIZEOF_WCHAR_T == 2 - wxWCharBuffer wx_str() + wxScopedWCharBuffer wx_str() { return utf16_str(); } @@ -189,19 +199,45 @@ public: return (wxUString &) base->assign( str, pos, n ); } - wxUString &assign( wxChar32 ch ) - { - std::basic_string *base = this; - return (wxUString &) base->assign( (size_type) 1, ch ); - } + // FIXME-VC6: VC 6.0 stl does not support all types of assign functions + #ifdef __VISUALC6__ + wxUString &assign( wxChar32 ch ) + { + wxChar32 chh[1]; + chh[0] = ch; + std::basic_string *base = this; + return (wxUString &)base->assign(chh); + } - wxUString &assign( size_type n, wxChar32 ch ) - { - std::basic_string *base = this; - return (wxUString &) base->assign( n, ch ); - } + wxUString &assign( size_type n, wxChar32 ch ) + { + wxU32CharBuffer buffer(n); + wxChar32 *p = buffer.data(); + size_type i; + for (i = 0; i < n; i++) + { + *p = ch; + p++; + } + + std::basic_string *base = this; + return (wxUString &)base->assign(buffer.data()); + } + #else + wxUString &assign( wxChar32 ch ) + { + std::basic_string *base = this; + return (wxUString &) base->assign( (size_type) 1, ch ); + } - wxUString &assign( const wxU32CharBuffer &buf ) + wxUString &assign( size_type n, wxChar32 ch ) + { + std::basic_string *base = this; + return (wxUString &) base->assign( n, ch ); + } + #endif // __VISUALC6__ + + wxUString &assign( const wxScopedU32CharBuffer &buf ) { return assign( buf.data() ); } @@ -211,7 +247,7 @@ public: return assignFromCString( str ); } - wxUString &assign( const wxCharBuffer &buf ) + wxUString &assign( const wxScopedCharBuffer &buf ) { return assignFromCString( buf.data() ); } @@ -221,7 +257,7 @@ public: return assignFromCString( str, conv ); } - wxUString &assign( const wxCharBuffer &buf, const wxMBConv &conv ) + wxUString &assign( const wxScopedCharBuffer &buf, const wxMBConv &conv ) { return assignFromCString( buf.data(), conv ); } @@ -231,7 +267,7 @@ public: return assignFromUTF16( str ); } - wxUString &assign( const wxU16CharBuffer &buf ) + wxUString &assign( const wxScopedU16CharBuffer &buf ) { return assignFromUTF16( buf.data() ); } @@ -346,11 +382,29 @@ public: return (wxUString &) base->append( s, n ); } - wxUString &append( size_type n, wxChar32 c ) - { - std::basic_string *base = this; - return (wxUString &) base->append( n, c ); - } + // FIXME-VC6: VC 6.0 stl does not support all types of append functions + #ifdef __VISUALC6__ + wxUString &append( size_type n, wxChar32 c ) + { + wxU32CharBuffer buffer(n); + wxChar32 *p = buffer.data(); + size_type i; + for (i = 0; i < n; i++) + { + *p = c; + p++; + } + + std::basic_string *base = this; + return (wxUString &) base->append(buffer.data()); + } + #else + wxUString &append( size_type n, wxChar32 c ) + { + std::basic_string *base = this; + return (wxUString &) base->append( n, c ); + } + #endif // __VISUALC6__ wxUString &append( wxChar32 c ) { @@ -360,12 +414,12 @@ public: // append [wx overload] - wxUString &append( const wxU16CharBuffer &buf ) + wxUString &append( const wxScopedU16CharBuffer &buf ) { return append( buf.data() ); } - wxUString &append( const wxU32CharBuffer &buf ) + wxUString &append( const wxScopedU32CharBuffer &buf ) { return append( buf.data() ); } @@ -375,7 +429,7 @@ public: return append( wxUString( str ) ); } - wxUString &append( const wxCharBuffer &buf ) + wxUString &append( const wxScopedCharBuffer &buf ) { return append( wxUString( buf ) ); } @@ -467,17 +521,17 @@ public: return insert( n, wxUString( s ) ); } - wxUString &insert( size_type n, const wxCharBuffer &buf ) + wxUString &insert( size_type n, const wxScopedCharBuffer &buf ) { return insert( n, wxUString( buf ) ); } - wxUString &insert( size_type n, const wxU16CharBuffer &buf ) + wxUString &insert( size_type n, const wxScopedU16CharBuffer &buf ) { return insert( n, wxUString( buf ) ); } - wxUString &insert( size_type n, const wxU32CharBuffer &buf ) + wxUString &insert( size_type n, const wxScopedU32CharBuffer &buf ) { return insert( n, buf.data() ); } @@ -524,8 +578,6 @@ public: // operator = - wxUString& operator=(const wxUString& s) - { return assign( s ); } wxUString& operator=(const wxString& s) { return assign( s ); } wxUString& operator=(const wxCStrData* s) @@ -536,11 +588,11 @@ public: { return assign( s ); } wxUString& operator=(const wxChar32 *s) { return assign( s ); } - wxUString& operator=(const wxCharBuffer &s) + wxUString& operator=(const wxScopedCharBuffer &s) { return assign( s ); } - wxUString& operator=(const wxU16CharBuffer &s) + wxUString& operator=(const wxScopedU16CharBuffer &s) { return assign( s ); } - wxUString& operator=(const wxU32CharBuffer &s) + wxUString& operator=(const wxScopedU32CharBuffer &s) { return assign( s ); } wxUString& operator=(const char ch) { return assign( ch ); } @@ -566,11 +618,11 @@ public: { return append( s ); } wxUString& operator+=(const wxChar32 *s) { return append( s ); } - wxUString& operator+=(const wxCharBuffer &s) + wxUString& operator+=(const wxScopedCharBuffer &s) { return append( s ); } - wxUString& operator+=(const wxU16CharBuffer &s) + wxUString& operator+=(const wxScopedU16CharBuffer &s) { return append( s ); } - wxUString& operator+=(const wxU32CharBuffer &s) + wxUString& operator+=(const wxScopedU32CharBuffer &s) { return append( s ); } wxUString& operator+=(const char ch) { return append( ch ); } @@ -585,6 +637,10 @@ public: }; +#ifdef __VISUALC__ + #pragma warning(pop) +#endif + inline wxUString operator+(const wxUString &s1, const wxUString &s2) { wxUString ret( s1 ); ret.append( s2 ); return ret; } inline wxUString operator+(const wxUString &s1, const char *s2) @@ -597,11 +653,11 @@ inline wxUString operator+(const wxUString &s1, const wxChar16* s2) { return s1 + wxUString(s2); } inline wxUString operator+(const wxUString &s1, const wxChar32 *s2) { return s1 + wxUString(s2); } -inline wxUString operator+(const wxUString &s1, const wxCharBuffer &s2) +inline wxUString operator+(const wxUString &s1, const wxScopedCharBuffer &s2) { return s1 + wxUString(s2); } -inline wxUString operator+(const wxUString &s1, const wxU16CharBuffer &s2) +inline wxUString operator+(const wxUString &s1, const wxScopedU16CharBuffer &s2) { return s1 + wxUString(s2); } -inline wxUString operator+(const wxUString &s1, const wxU32CharBuffer &s2) +inline wxUString operator+(const wxUString &s1, const wxScopedU32CharBuffer &s2) { return s1 + wxUString(s2); } inline wxUString operator+(const wxUString &s1, char s2) { return s1 + wxUString(s2); } @@ -624,11 +680,11 @@ inline wxUString operator+(const wxChar16* s1, const wxUString &s2) { return wxUString(s1) + s2; } inline wxUString operator+(const wxChar32 *s1, const wxUString &s2) { return wxUString(s1) + s2; } -inline wxUString operator+(const wxCharBuffer &s1, const wxUString &s2) +inline wxUString operator+(const wxScopedCharBuffer &s1, const wxUString &s2) { return wxUString(s1) + s2; } -inline wxUString operator+(const wxU16CharBuffer &s1, const wxUString &s2) +inline wxUString operator+(const wxScopedU16CharBuffer &s1, const wxUString &s2) { return wxUString(s1) + s2; } -inline wxUString operator+(const wxU32CharBuffer &s1, const wxUString &s2) +inline wxUString operator+(const wxScopedU32CharBuffer &s1, const wxUString &s2) { return wxUString(s1) + s2; } inline wxUString operator+(char s1, const wxUString &s2) { return wxUString(s1) + s2; } @@ -686,9 +742,9 @@ wxUSTRING_COMP_OPERATORS( const wxString & ) wxUSTRING_COMP_OPERATORS( const char * ) wxUSTRING_COMP_OPERATORS( const wxChar16 * ) wxUSTRING_COMP_OPERATORS( const wxChar32 * ) -wxUSTRING_COMP_OPERATORS( const wxCharBuffer & ) -wxUSTRING_COMP_OPERATORS( const wxU16CharBuffer & ) -wxUSTRING_COMP_OPERATORS( const wxU32CharBuffer & ) +wxUSTRING_COMP_OPERATORS( const wxScopedCharBuffer & ) +wxUSTRING_COMP_OPERATORS( const wxScopedU16CharBuffer & ) +wxUSTRING_COMP_OPERATORS( const wxScopedU32CharBuffer & ) wxUSTRING_COMP_OPERATORS( const wxCStrData * ) #endif // _WX_USTRING_H_