+ wxCharTypeBuffer& operator=(const wxCharTypeBuffer& src)
+ {
+ wxScopedCharTypeBuffer<T>::operator=(src);
+ return *this;
+ }
+
+ wxCharTypeBuffer(const wxScopedCharTypeBuffer<T>& src)
+ {
+ this->MakeOwnedCopyOf(src);
+ }
+
+ wxCharTypeBuffer& operator=(const wxScopedCharTypeBuffer<T>& src)
+ {
+ MakeOwnedCopyOf(src);
+ return *this;
+ }
+
+ bool extend(size_t len)
+ {
+ wxASSERT_MSG( this->m_data->m_owned, "cannot extend non-owned buffer" );
+ wxASSERT_MSG( this->m_data->m_ref == 1, "can't extend shared buffer" );
+
+ CharType *str =
+ (CharType *)realloc(this->data(), (len + 1) * sizeof(CharType));
+ if ( !str )
+ return false;
+
+ if ( this->m_data == this->GetNullData() )
+ {
+ this->m_data = new Data(str, len);
+ }
+ else
+ {
+ this->m_data->Set(str, len);
+ this->m_data->m_owned = true;
+ }
+
+ return true;
+ }
+
+ void shrink(size_t len)
+ {
+ wxASSERT_MSG( this->m_data->m_owned, "cannot shrink non-owned buffer" );
+ wxASSERT_MSG( this->m_data->m_ref == 1, "can't shrink shared buffer" );
+
+ wxASSERT( len <= this->length() );
+
+ this->m_data->m_length = len;
+ this->data()[len] = 0;
+ }
+};
+
+WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxScopedCharTypeBuffer<char> )
+WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxCharTypeBuffer<char> )
+
+class wxCharBuffer : public wxCharTypeBuffer<char>
+{
+public:
+ typedef wxCharTypeBuffer<char> wxCharTypeBufferBase;
+ typedef wxScopedCharTypeBuffer<char> wxScopedCharTypeBufferBase;
+
+ wxCharBuffer(const wxCharTypeBufferBase& buf)
+ : wxCharTypeBufferBase(buf) {}
+ wxCharBuffer(const wxScopedCharTypeBufferBase& buf)
+ : wxCharTypeBufferBase(buf) {}
+
+ wxCharBuffer(const CharType *str = NULL) : wxCharTypeBufferBase(str) {}
+ wxCharBuffer(size_t len) : wxCharTypeBufferBase(len) {}
+
+ wxCharBuffer(const wxCStrData& cstr);
+};
+
+WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxScopedCharTypeBuffer<wchar_t> )
+WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxCharTypeBuffer<wchar_t> )
+
+class wxWCharBuffer : public wxCharTypeBuffer<wchar_t>
+{
+public:
+ typedef wxCharTypeBuffer<wchar_t> wxCharTypeBufferBase;
+ typedef wxScopedCharTypeBuffer<wchar_t> wxScopedCharTypeBufferBase;
+
+ wxWCharBuffer(const wxCharTypeBufferBase& buf)
+ : wxCharTypeBufferBase(buf) {}
+ wxWCharBuffer(const wxScopedCharTypeBufferBase& buf)
+ : wxCharTypeBufferBase(buf) {}
+
+ wxWCharBuffer(const CharType *str = NULL) : wxCharTypeBufferBase(str) {}
+ wxWCharBuffer(size_t len) : wxCharTypeBufferBase(len) {}
+
+ wxWCharBuffer(const wxCStrData& cstr);
+};
+
+// wxCharTypeBuffer<T> implicitly convertible to T*
+template <typename T>
+class wxWritableCharTypeBuffer : public wxCharTypeBuffer<T>
+{
+public:
+ typedef typename wxScopedCharTypeBuffer<T>::CharType CharType;
+
+ wxWritableCharTypeBuffer(const wxScopedCharTypeBuffer<T>& src)
+ : wxCharTypeBuffer<T>(src) {}
+ // FIXME-UTF8: this won't be needed after converting mb_str()/wc_str() to
+ // always return a buffer
+ // + we should derive this class from wxScopedCharTypeBuffer
+ // then
+ wxWritableCharTypeBuffer(const CharType *str = NULL)
+ : wxCharTypeBuffer<T>(str) {}
+
+ operator CharType*() { return this->data(); }