X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/486a5941821db1810e75eb35cfce0e7024158f8c..d31a4a84fb81e0f4975690e45d4d3b11a0f3cd5d:/include/wx/buffer.h diff --git a/include/wx/buffer.h b/include/wx/buffer.h index c3d246e7fc..3d7d6403f6 100644 --- a/include/wx/buffer.h +++ b/include/wx/buffer.h @@ -12,14 +12,12 @@ #ifndef _WX_BUFFER_H #define _WX_BUFFER_H -#include "wx/wxchar.h" +#include "wx/chartype.h" +#include "wx/wxcrtbase.h" #include // malloc() and free() -inline char *wxStrDup(const char *s) { return wxStrdupA(s); } -#if wxUSE_WCHAR_T - inline wchar_t *wxStrDup(const wchar_t *ws) { return wxStrdupW(ws); } -#endif +class WXDLLIMPEXP_FWD_BASE wxCStrData; // ---------------------------------------------------------------------------- // Special classes for (wide) character strings: they use malloc/free instead @@ -33,7 +31,7 @@ public: typedef T CharType; wxCharTypeBuffer(const CharType *str = NULL) - : m_str(str ? wxStrDup(str) : NULL), + : m_str(str ? wxStrdup(str) : NULL), m_owned(true) { } @@ -45,10 +43,10 @@ public: m_str[len] = (CharType)0; } - static wxCharTypeBuffer CreateNonOwned(const CharType *str) + static const wxCharTypeBuffer CreateNonOwned(const CharType *str) { wxCharTypeBuffer buf; - buf.m_str = str; + buf.m_str = wx_const_cast(CharType*, str); buf.m_owned = false; return buf; } @@ -100,7 +98,7 @@ public: { if ( m_owned ) free(m_str); - m_str = str ? wxStrDup(str) : NULL; + m_str = str ? wxStrdup(str) : NULL; m_owned = true; return *this; } @@ -152,11 +150,14 @@ private: bool m_owned; }; -class WXDLLIMPEXP_BASE wxCharBuffer : public wxCharTypeBuffer +class wxCharBuffer : public wxCharTypeBuffer { public: typedef wxCharTypeBuffer wxCharTypeBufferBase; + wxCharBuffer(const wxCharTypeBufferBase& buf) + : wxCharTypeBufferBase(buf) {} + wxCharBuffer(const CharType *str = NULL) : wxCharTypeBufferBase(str) {} wxCharBuffer(size_t len) : wxCharTypeBufferBase(len) {} @@ -164,11 +165,14 @@ public: }; #if wxUSE_WCHAR_T -class WXDLLIMPEXP_BASE wxWCharBuffer : public wxCharTypeBuffer +class wxWCharBuffer : public wxCharTypeBuffer { public: typedef wxCharTypeBuffer wxCharTypeBufferBase; + wxWCharBuffer(const wxCharTypeBufferBase& buf) + : wxCharTypeBufferBase(buf) {} + wxWCharBuffer(const CharType *str = NULL) : wxCharTypeBufferBase(str) {} wxWCharBuffer(size_t len) : wxCharTypeBufferBase(len) {}