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
This commit is contained in:
Vadim Zeitlin
2012-01-20 12:22:22 +00:00
parent 11c278c43c
commit 846b6c8658
2 changed files with 24 additions and 0 deletions

View File

@@ -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)
{

View File

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