#include <wx/string.h>
This helper class allows you to conveniently access the wxString internal buffer as a writable pointer and requires explicitly specifying the actual length.
For example, assuming you have a low-level OS function called "int GetMeaningOfLifeAsString(char *)"
copying the value in the provided buffer (which must be writable, of course), and returning the actual length of the string, you might call it like this:
Note that the string can't be used in any way while a buffer associated with it exists, the buffer must be destroyed to allow using the string again.
If possible, this class uses the internal wxString storage directly, however this may not be the case depending on wxWidgets build options.
Note that wxStringBuffer::SetLength must be called before wxStringBufferLength destructs.
Public Member Functions | |
wxStringBufferLength (wxString &str, size_t len) | |
Constructs a writable string buffer object associated with the given string and containing enough space for at least len characters. More... | |
~wxStringBufferLength () | |
Restores the string passed to the constructor to the usable state. More... | |
void | SetLength (size_t nLength) |
Sets the internal length of the string referred to by wxStringBufferLength to nLength characters. More... | |
wxChar * | operator wxChar * () |
Returns the writable pointer to a buffer of the size at least equal to the length specified in the constructor. More... | |
wxStringBufferLength::wxStringBufferLength | ( | wxString & | str, |
size_t | len | ||
) |
Constructs a writable string buffer object associated with the given string and containing enough space for at least len characters.
wxStringBufferLength::~wxStringBufferLength | ( | ) |
Restores the string passed to the constructor to the usable state.
Returns the writable pointer to a buffer of the size at least equal to the length specified in the constructor.
void wxStringBufferLength::SetLength | ( | size_t | nLength | ) |
Sets the internal length of the string referred to by wxStringBufferLength to nLength characters.
Must be called before wxStringBufferLength destructs.