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. */