Contents Up Previous Next

wxStringBuffer

This tiny class allows to conveniently access the wxString internal buffer as a writable pointer without any risk to forget to restore the string to the usable state later.

For example, assuming you have a low-level OS function called GetMeaningOfLifeAsString(char *) returning the value in the provided buffer (which must be writable, of course) you might call it like this:

    wxString theAnswer;
    GetMeaningOfLifeAsString(wxStringBuffer(theAnswer, 1024));
    if ( theAnswer != "42" )
    {
        wxLogError("Something is very wrong!");
    }
Derived from

None

Include files

<wx/string.h>

Members

wxStringBuffer::wxStringBuffer
wxStringBuffer::~wxStringBuffer
wxStringBuffer::operator wxChar *


wxStringBuffer::wxStringBuffer

wxStringBuffer(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 GetWriteBuf and saving the result.


wxStringBuffer::~wxStringBuffer

~wxStringBuffer()

Restores the string passed to the constructor to the usable state by calling UngetWriteBuf on it.


wxStringBuffer::operator wxChar *

wxChar * operator wxChar *() const

Returns the writable pointer to a buffer of the size at least equal to the length specified in the constructor.