]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/string.h
add wxUSE_MINIFRAME wrapper
[wxWidgets.git] / include / wx / string.h
index 3f4fe1a6bff42e533018d3a999f31e21fedb9389..ba651e5d976ec28178424da1f9045565fde82ccd 100644 (file)
@@ -1087,19 +1087,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 +2766,7 @@ private:
 #endif // !wxUSE_STL_BASED_WXSTRING
 
 template<typename T>
-class wxStringTypeBufferBase
+class WXDLLIMPEXP_BASE wxStringTypeBufferBase
 {
 public:
     typedef T CharType;
@@ -2778,7 +2784,7 @@ protected:
 };
 
 template<typename T>
-class wxStringTypeBufferLengthBase
+class WXDLLIMPEXP_BASE wxStringTypeBufferLengthBase
 {
 public:
     typedef T CharType;
@@ -2787,12 +2793,6 @@ public:
         : m_str(str), m_buf(lenWanted), m_len(0), m_lenSet(false)
         { }
 
-    ~wxStringTypeBufferLengthBase()
-    {
-        wxASSERT(m_lenSet);
-        m_str.assign(m_buf.data(), m_len);
-    }
-
     operator CharType*() { return m_buf.data(); }
     void SetLength(size_t length) { m_len = length; m_lenSet = true; }
 
@@ -2834,6 +2834,9 @@ public:
 };
 
 #if wxUSE_STL_BASED_WXSTRING
+
+WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxStringTypeBufferBase<wxStringCharType> )
+
 class wxStringInternalBuffer : public wxStringTypeBufferBase<wxStringCharType>
 {
 public:
@@ -2845,7 +2848,11 @@ public:
     DECLARE_NO_COPY_CLASS(wxStringInternalBuffer)
 };
 
-class wxStringInternalBufferLength : public wxStringTypeBufferLengthBase<wxStringCharType>
+WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE(
+    wxStringTypeBufferLengthBase<wxStringCharType> )
+
+class wxStringInternalBufferLength
+    : public wxStringTypeBufferLengthBase<wxStringCharType>
 {
 public:
     wxStringInternalBufferLength(wxString& str, size_t lenWanted = 1024)
@@ -2870,6 +2877,38 @@ typedef wxStringInternalBuffer                wxStringBuffer;
 typedef wxStringInternalBufferLength          wxStringBufferLength;
 #endif // !wxUSE_STL_BASED_WXSTRING && !wxUSE_UNICODE_UTF8
 
+#if wxUSE_UNICODE_UTF8
+typedef wxStringInternalBuffer                wxUTF8StringBuffer;
+typedef wxStringInternalBufferLength          wxUTF8StringBufferLength;
+#elif wxUSE_UNICODE_WCHAR
+
+WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxStringTypeBufferBase<char> )
+
+class WXDLLIMPEXP_BASE wxUTF8StringBuffer : public wxStringTypeBufferBase<char>
+{
+public:
+    wxUTF8StringBuffer(wxString& str, size_t lenWanted = 1024)
+        : wxStringTypeBufferBase<char>(str, lenWanted) {}
+    ~wxUTF8StringBuffer();
+
+    DECLARE_NO_COPY_CLASS(wxUTF8StringBuffer)
+};
+
+WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxStringTypeBufferLengthBase<char> )
+
+class WXDLLIMPEXP_BASE wxUTF8StringBufferLength
+    : public wxStringTypeBufferLengthBase<char>
+{
+public:
+    wxUTF8StringBufferLength(wxString& str, size_t lenWanted = 1024)
+        : wxStringTypeBufferLengthBase<char>(str, lenWanted) {}
+    ~wxUTF8StringBufferLength();
+
+    DECLARE_NO_COPY_CLASS(wxUTF8StringBufferLength)
+};
+#endif // wxUSE_UNICODE_UTF8/wxUSE_UNICODE_WCHAR
+
+
 // ---------------------------------------------------------------------------
 // wxString comparison functions: operator versions are always case sensitive
 // ---------------------------------------------------------------------------
@@ -2992,7 +3031,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