]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/buffer.h
define {first,second}_type in the struct declared by _WX_DECLARE_PAIR too for compati...
[wxWidgets.git] / include / wx / buffer.h
index 8e7fd8dbb16e146f810ca11745d6831b0c3c09ad..346ef113f9b6bb78d4f9f0e653d765e54810c773 100644 (file)
 #include "wx/chartype.h"
 #include "wx/wxcrtbase.h"
 
+#ifndef __WXPALMOS5__
 #include <stdlib.h>             // malloc() and free()
+#endif // ! __WXPALMOS5__
 
-class WXDLLIMPEXP_BASE wxCStrData;
+class WXDLLIMPEXP_FWD_BASE wxCStrData;
 
 // ----------------------------------------------------------------------------
 // Special classes for (wide) character strings: they use malloc/free instead
@@ -25,7 +27,7 @@ class WXDLLIMPEXP_BASE wxCStrData;
 // ----------------------------------------------------------------------------
 
 template <typename T>
-class wxCharTypeBuffer
+class WXDLLIMPEXP_BASE wxCharTypeBuffer
 {
 public:
     typedef T CharType;
@@ -105,9 +107,12 @@ public:
 
     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;
     }
 
@@ -150,7 +155,9 @@ private:
     bool m_owned;
 };
 
-class wxCharBuffer : public wxCharTypeBuffer<char>
+WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxCharTypeBuffer<char> )
+
+class WXDLLIMPEXP_BASE wxCharBuffer : public wxCharTypeBuffer<char>
 {
 public:
     typedef wxCharTypeBuffer<char> wxCharTypeBufferBase;
@@ -165,7 +172,9 @@ public:
 };
 
 #if wxUSE_WCHAR_T
-class wxWCharBuffer : public wxCharTypeBuffer<wchar_t>
+WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxCharTypeBuffer<wchar_t> )
+
+class WXDLLIMPEXP_BASE wxWCharBuffer : public wxCharTypeBuffer<wchar_t>
 {
 public:
     typedef wxCharTypeBuffer<wchar_t> wxCharTypeBufferBase;
@@ -222,6 +231,13 @@ typedef wxWritableCharTypeBuffer<wchar_t> 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)
 // ----------------------------------------------------------------------------
@@ -284,7 +300,7 @@ private:
 };
 
 
-class wxMemoryBuffer
+class WXDLLIMPEXP_BASE wxMemoryBuffer
 {
 public:
     // ctor and dtor
@@ -306,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;
     }