From: Vadim Zeitlin Date: Fri, 20 Jan 2012 12:22:22 +0000 (+0000) Subject: Added wxMemoryBuffer::Clear() and IsEmpty() methods. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/846b6c86586ff3c5a1948132761ba223f3ccb75c Added wxMemoryBuffer::Clear() and IsEmpty() methods. Add two convenient methods which may be used instead of testing or setting the buffer length. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70407 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/buffer.h b/include/wx/buffer.h index e0644474e8..800c41b714 100644 --- a/include/wx/buffer.h +++ b/include/wx/buffer.h @@ -535,6 +535,8 @@ public: size_t GetBufSize() const { return m_bufdata->m_size; } size_t GetDataLen() const { return m_bufdata->m_len; } + bool IsEmpty() const { return GetDataLen() == 0; } + void SetBufSize(size_t size) { m_bufdata->ResizeIfNeeded(size); } void SetDataLen(size_t len) { @@ -542,6 +544,8 @@ public: m_bufdata->m_len = len; } + void Clear() { SetDataLen(0); } + // Ensure the buffer is big enough and return a pointer to it void *GetWriteBuf(size_t sizeNeeded) { diff --git a/interface/wx/buffer.h b/interface/wx/buffer.h index f9ce4835ef..4ef51bac3b 100644 --- a/interface/wx/buffer.h +++ b/interface/wx/buffer.h @@ -309,6 +309,17 @@ public: */ void AppendData(const void *data, size_t len); + /** + Clear the buffer contents. + + The buffer won't contain any data after this method is called. + + @see IsEmpty() + + @since 2.9.4 + */ + void Clear(); + /** Ensure that the buffer is big enough and return a pointer to the start of the empty space in the buffer. This pointer can be used to directly @@ -343,6 +354,15 @@ public: */ void* GetWriteBuf(size_t sizeNeeded); + /** + Returns true if the buffer contains no data. + + @see Clear() + + @since 2.9.4 + */ + bool IsEmpty() const; + /** Ensures the buffer has at least @a size bytes available. */