]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/buffer.h
wxCStrData must be dllexport'd now that it has non-inline methods
[wxWidgets.git] / include / wx / buffer.h
index c9232820fec15c0d34d3554088350b2e51e2a7c2..59a7ad6c35de5e5dd713f2848bfe9a22ede9de02 100644 (file)
@@ -126,9 +126,7 @@ public:
     wxCharBuffer(const CharType *str = NULL) : wxCharTypeBufferBase(str) {}
     wxCharBuffer(size_t len) : wxCharTypeBufferBase(len) {}
 
-#if !wxUSE_UNICODE
     wxCharBuffer(const wxCStrData& cstr);
-#endif
 };
 
 #if wxUSE_WCHAR_T
@@ -140,12 +138,31 @@ public:
     wxWCharBuffer(const CharType *str = NULL) : wxCharTypeBufferBase(str) {}
     wxWCharBuffer(size_t len) : wxCharTypeBufferBase(len) {}
 
-#if wxUSE_UNICODE
     wxWCharBuffer(const wxCStrData& cstr);
-#endif
 };
 #endif // wxUSE_WCHAR_T
 
+// wxCharTypeBuffer<T> implicitly convertible to T*
+template <typename T>
+class wxWritableCharTypeBuffer : public wxCharTypeBuffer<T>
+{
+public:
+    typedef typename wxCharTypeBuffer<T>::CharType CharType;
+
+    wxWritableCharTypeBuffer(const wxCharTypeBuffer<T>& src)
+        : wxCharTypeBuffer<T>(src) {}
+    // FIXME-UTF8: this won't be needed after converting mb_str()/wc_str() to
+    //             always return a buffer
+    wxWritableCharTypeBuffer(const CharType *str = NULL)
+        : wxCharTypeBuffer<T>(str) {}
+
+    operator CharType*() { return this->data(); }
+};
+
+typedef wxWritableCharTypeBuffer<char> wxWritableCharBuffer;
+typedef wxWritableCharTypeBuffer<wchar_t> wxWritableWCharBuffer;
+
+
 #if wxUSE_UNICODE
     #define wxWxCharBuffer wxWCharBuffer