]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/buffer.h
Added intermediate state (m_showOnIdle) indicating that
[wxWidgets.git] / include / wx / buffer.h
index c15ca72c27fac6247baa53007dd091243d30acf5..f17aa0c1abaec6c582a452f3358dd031eb1bfb32 100644 (file)
 class WXDLLIMPEXP_BASE classname                                            \
 {                                                                           \
 public:                                                                     \
 class WXDLLIMPEXP_BASE classname                                            \
 {                                                                           \
 public:                                                                     \
-    classname(const chartype *str)                                          \
+    classname(const chartype *str = NULL)                                   \
         : m_str(str ? strdupfunc(str) : NULL)                               \
     {                                                                       \
     }                                                                       \
                                                                             \
         : m_str(str ? strdupfunc(str) : NULL)                               \
     {                                                                       \
     }                                                                       \
                                                                             \
-    classname(size_t len=0)                                                 \
+    classname(size_t len)                                                   \
         : m_str((chartype *)malloc((len + 1)*sizeof(chartype)))             \
     {                                                                       \
         m_str[len] = (chartype)0;                                           \
         : m_str((chartype *)malloc((len + 1)*sizeof(chartype)))             \
     {                                                                       \
         m_str[len] = (chartype)0;                                           \
@@ -64,6 +64,12 @@ public:                                                                     \
         return p;                                                           \
     }                                                                       \
                                                                             \
         return p;                                                           \
     }                                                                       \
                                                                             \
+    void reset()                                                            \
+    {                                                                       \
+        free(m_str);                                                        \
+        m_str = NULL;                                                       \
+    }                                                                       \
+                                                                            \
     classname(const classname& src)                                         \
         : m_str(src.release())                                              \
     {                                                                       \
     classname(const classname& src)                                         \
         : m_str(src.release())                                              \
     {                                                                       \
@@ -84,6 +90,18 @@ public:                                                                     \
         return *this;                                                       \
     }                                                                       \
                                                                             \
         return *this;                                                       \
     }                                                                       \
                                                                             \
+    bool extend(size_t len)                                                 \
+    {                                                                       \
+        chartype *                                                          \
+            str = (chartype *)realloc(m_str, (len + 1)*sizeof(chartype));   \
+        if ( !str )                                                         \
+            return false;                                                   \
+                                                                            \
+        m_str = str;                                                        \
+                                                                            \
+        return true;                                                        \
+    }                                                                       \
+                                                                            \
     chartype *data() { return m_str; }                                      \
     const chartype *data() const { return m_str; }                          \
     operator const chartype *() const { return m_str; }                     \
     chartype *data() { return m_str; }                                      \
     const chartype *data() const { return m_str; }                          \
     operator const chartype *() const { return m_str; }                     \
@@ -104,11 +122,15 @@ DEFINE_BUFFER(wxWCharBuffer, wchar_t, wxStrdupW);
 #undef DEFINE_BUFFER
 
 #if wxUSE_UNICODE
 #undef DEFINE_BUFFER
 
 #if wxUSE_UNICODE
+    typedef wxWCharBuffer wxWxCharBuffer;
+
     #define wxMB2WXbuf wxWCharBuffer
     #define wxWX2MBbuf wxCharBuffer
     #define wxWC2WXbuf wxChar*
     #define wxWX2WCbuf wxChar*
 #else // ANSI
     #define wxMB2WXbuf wxWCharBuffer
     #define wxWX2MBbuf wxCharBuffer
     #define wxWC2WXbuf wxChar*
     #define wxWX2WCbuf wxChar*
 #else // ANSI
+    typedef wxCharBuffer wxWxCharBuffer;
+
     #define wxMB2WXbuf wxChar*
     #define wxWX2MBbuf wxChar*
     #define wxWC2WXbuf wxCharBuffer
     #define wxMB2WXbuf wxChar*
     #define wxWX2MBbuf wxChar*
     #define wxWC2WXbuf wxCharBuffer