#include <wx/string.h>
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:
wxString theAnswer; wxStringBuffer theAnswerBuffer(theAnswer, 1024); int nLength = GetMeaningOfLifeAsString(theAnswerBuffer); theAnswerBuffer.SetLength(nLength); if ( theAnswer != "42" ) wxLogError("Something is very wrong!");
Note that wxStringBuffer::SetLength must be called before wxStringBufferLength destructs.
Public Member Functions | |
wxStringBufferLength (const 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 () | |
Restores the string passed to the constructor to the usable state by calling wxString::UngetWriteBuf on it. | |
void | SetLength (size_t nLength) |
Sets the internal length of the string referred to by wxStringBufferLength to nLength characters. | |
wxChar * | operator wxChar * () |
Returns the writable pointer to a buffer of the size at least equal to the length specified in the constructor. |
wxStringBufferLength::wxStringBufferLength | ( | const 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.
Basically, this is equivalent to calling wxString::GetWriteBuf and saving the result.
wxStringBufferLength::~wxStringBufferLength | ( | ) |
Restores the string passed to the constructor to the usable state by calling wxString::UngetWriteBuf on it.
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.
![]() |
[ top ] |