X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8db4a5d27a7ed301d395fce08e2c1618cd629696..09b895cb4a954494063eb17d3dc302a654fd99e5:/include/wx/buffer.h diff --git a/include/wx/buffer.h b/include/wx/buffer.h index 6d50b2a0a9..346ef113f9 100644 --- a/include/wx/buffer.h +++ b/include/wx/buffer.h @@ -13,16 +13,13 @@ #define _WX_BUFFER_H #include "wx/chartype.h" -#include "wx/wxcrt.h" +#include "wx/wxcrtbase.h" +#ifndef __WXPALMOS5__ #include // malloc() and free() +#endif // ! __WXPALMOS5__ -class WXDLLIMPEXP_BASE wxCStrData; - -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 @@ -30,13 +27,13 @@ inline char *wxStrDup(const char *s) { return wxStrdupA(s); } // ---------------------------------------------------------------------------- template -class wxCharTypeBuffer +class WXDLLIMPEXP_BASE wxCharTypeBuffer { public: typedef T CharType; wxCharTypeBuffer(const CharType *str = NULL) - : m_str(str ? wxStrDup(str) : NULL), + : m_str(str ? wxStrdup(str) : NULL), m_owned(true) { } @@ -103,16 +100,19 @@ public: { if ( m_owned ) free(m_str); - m_str = str ? wxStrDup(str) : NULL; + m_str = str ? wxStrdup(str) : NULL; m_owned = true; return *this; } wxCharTypeBuffer& operator=(const wxCharTypeBuffer& src) { - if ( m_owned ) - free(m_str); - CopyFrom(src); + if (&src != this) + { + if ( m_owned ) + free(m_str); + CopyFrom(src); + } return *this; } @@ -155,6 +155,8 @@ private: bool m_owned; }; +WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxCharTypeBuffer ) + class WXDLLIMPEXP_BASE wxCharBuffer : public wxCharTypeBuffer { public: @@ -170,6 +172,8 @@ public: }; #if wxUSE_WCHAR_T +WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxCharTypeBuffer ) + class WXDLLIMPEXP_BASE wxWCharBuffer : public wxCharTypeBuffer { public: @@ -227,6 +231,13 @@ typedef wxWritableCharTypeBuffer wxWritableWCharBuffer; #define wxWX2WCbuf wxWCharBuffer #endif // Unicode/ANSI +// type of the value returned by wxString::utf8_str() +#if wxUSE_UNICODE_UTF8 + #define wxUTF8Buf char * +#else + #define wxUTF8Buf wxCharBuffer +#endif + // ---------------------------------------------------------------------------- // A class for holding growable data buffers (not necessarily strings) // ---------------------------------------------------------------------------- @@ -289,7 +300,7 @@ private: }; -class wxMemoryBuffer +class WXDLLIMPEXP_BASE wxMemoryBuffer { public: // ctor and dtor @@ -311,9 +322,12 @@ public: wxMemoryBuffer& operator=(const wxMemoryBuffer& src) { - m_bufdata->DecRef(); - m_bufdata = src.m_bufdata; - m_bufdata->IncRef(); + if (&src != this) + { + m_bufdata->DecRef(); + m_bufdata = src.m_bufdata; + m_bufdata->IncRef(); + } return *this; }