]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/buffer.h
fixed wxUniCharRef::IsAscii() definition
[wxWidgets.git] / include / wx / buffer.h
index c9232820fec15c0d34d3554088350b2e51e2a7c2..81184c7705c3fbcd7e7d86b6295a72c7e7853235 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,19 +138,43 @@ 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
 
     #define wxMB2WXbuf wxWCharBuffer
     #define wxWX2MBbuf wxCharBuffer
-    #define wxWC2WXbuf wxChar*
-    #define wxWX2WCbuf wxChar*
+    #if wxUSE_UNICODE_WCHAR
+        #define wxWC2WXbuf wxChar*
+        #define wxWX2WCbuf wxChar*
+    #elif wxUSE_UNICODE_UTF8
+        #define wxWC2WXbuf wxWCharBuffer
+        #define wxWX2WCbuf wxWCharBuffer
+    #endif
 #else // ANSI
     #define wxWxCharBuffer wxCharBuffer