// Purpose: interface of wxMemoryBuffer
// Author: wxWidgets team
// RCS-ID: $Id$
-// Licence: wxWindows license
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
@param len If specified, length of the string, otherwise the string
is considered to be NUL-terminated.
*/
- static const wxScopedCharTypeBuffer CreateOwned(const CharType *str, size_t len = wxNO_LEN);
+ static const wxScopedCharTypeBuffer CreateOwned(CharType *str, size_t len = wxNO_LEN);
/**
Copy constructor.
wxCharTypeBuffer(const wxScopedCharTypeBuffer<T>& src);
/**
- Assigns @a str to this buffer and takes ownership of it (i.e. the
+ Assigns @a str to this buffer and takes ownership of it (i.e.\ the
buffer becomes "owned").
*/
wxCharTypeBuffer& operator=(const CharType *str);
Can only be called on buffers that don't share data with another
buffer (i.e. reference count of the data is 1).
+
+ @see shrink()
*/
bool extend(size_t len);
+
+ /**
+ Shrinks the buffer to have size @a len and NUL-terminates the string
+ at this length.
+
+ Can only be called on buffers that don't share data with another
+ buffer (i.e. reference count of the data is 1).
+
+ @param len Length to shrink to. Must not be larger than current length.
+
+ @note The string is not reallocated to take less memory.
+
+ @since 2.9.0
+
+ @see extend()
+ */
+ bool shrink(size_t len);
};
/**
Create a new buffer.
@param size
- size of the new buffer.
+ size of the new buffer, 1KiB by default.
*/
- wxMemoryBuffer(size_t size = DefBufSize);
+ wxMemoryBuffer(size_t size = 1024);
/**
Append a single byte to the buffer.
*/
void AppendByte(char data);
+ /**
+ Single call to append a data block to the buffer.
+
+ @param data
+ Pointer to block to append to the buffer.
+ @param len
+ Length of data to append.
+ */
+ 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
*/
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.
*/