X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7d46f92bb09316fcdb11ce3801d33d6f1409bdbd..52170c5b4419c63d6e0083df411aad420395ec98:/include/wx/string.h?ds=sidebyside diff --git a/include/wx/string.h b/include/wx/string.h index 436a6831f4..b70306b886 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -380,8 +380,9 @@ protected: #if wxUSE_UNICODE_UTF8 // see the comment near wxString::iterator for why we need this -struct WXDLLIMPEXP_BASE wxStringIteratorNode +class WXDLLIMPEXP_BASE wxStringIteratorNode { +public: wxStringIteratorNode() : m_str(NULL), m_citer(NULL), m_iter(NULL), m_prev(NULL), m_next(NULL) {} wxStringIteratorNode(const wxString *str, @@ -1087,19 +1088,25 @@ public: void resize(size_t nSize, wxUniChar ch = wxT('\0')) { + const size_t len = length(); + if ( nSize == len) + return; + #if wxUSE_UNICODE_UTF8 - if ( !ch.IsAscii() ) + if ( nSize < len ) { - size_t len = length(); - if ( nSize == len) - return; - else if ( nSize < len ) - erase(nSize); - else - append(nSize - len, ch); + // we can't use wxStringImpl::resize() for truncating the string as it + // counts in bytes, not characters + erase(nSize); + return; } + + // we also can't use (presumably more efficient) resize() if we have to + // append characters taking more than one byte + if ( !ch.IsAscii() ) + append(nSize - len, ch); else -#endif +#endif // wxUSE_UNICODE_UTF8 m_impl.resize(nSize, (wxStringCharType)ch); } @@ -2760,7 +2767,7 @@ private: #endif // !wxUSE_STL_BASED_WXSTRING template -class wxStringTypeBufferBase +class WXDLLIMPEXP_BASE wxStringTypeBufferBase { public: typedef T CharType; @@ -2778,7 +2785,7 @@ protected: }; template -class wxStringTypeBufferLengthBase +class WXDLLIMPEXP_BASE wxStringTypeBufferLengthBase { public: typedef T CharType; @@ -2828,6 +2835,9 @@ public: }; #if wxUSE_STL_BASED_WXSTRING + +WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxStringTypeBufferBase ) + class wxStringInternalBuffer : public wxStringTypeBufferBase { public: @@ -2839,7 +2849,11 @@ public: DECLARE_NO_COPY_CLASS(wxStringInternalBuffer) }; -class wxStringInternalBufferLength : public wxStringTypeBufferLengthBase +WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( + wxStringTypeBufferLengthBase ) + +class wxStringInternalBufferLength + : public wxStringTypeBufferLengthBase { public: wxStringInternalBufferLength(wxString& str, size_t lenWanted = 1024) @@ -2868,6 +2882,9 @@ typedef wxStringInternalBufferLength wxStringBufferLength; typedef wxStringInternalBuffer wxUTF8StringBuffer; typedef wxStringInternalBufferLength wxUTF8StringBufferLength; #elif wxUSE_UNICODE_WCHAR + +WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxStringTypeBufferBase ) + class WXDLLIMPEXP_BASE wxUTF8StringBuffer : public wxStringTypeBufferBase { public: @@ -2878,6 +2895,8 @@ public: DECLARE_NO_COPY_CLASS(wxUTF8StringBuffer) }; +WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxStringTypeBufferLengthBase ) + class WXDLLIMPEXP_BASE wxUTF8StringBufferLength : public wxStringTypeBufferLengthBase { @@ -3013,7 +3032,15 @@ WXDLLIMPEXP_BASE wxSTD ostream& operator<<(wxSTD ostream&, const wxCharBuffer&); WXDLLIMPEXP_BASE wxSTD ostream& operator<<(wxSTD ostream&, const wxWCharBuffer&); #endif -#endif // wxSTD_STRING_COMPATIBILITY +#if wxUSE_UNICODE && defined(HAVE_WOSTREAM) + +WXDLLIMPEXP_BASE wxSTD wostream& operator<<(wxSTD wostream&, const wxString&); +WXDLLIMPEXP_BASE wxSTD wostream& operator<<(wxSTD wostream&, const wxCStrData&); +WXDLLIMPEXP_BASE wxSTD wostream& operator<<(wxSTD wostream&, const wxWCharBuffer&); + +#endif // wxUSE_UNICODE && defined(HAVE_WOSTREAM) + +#endif // wxUSE_STD_IOSTREAM // --------------------------------------------------------------------------- // wxCStrData implementation