contents up previous next

wxmemorybuffer

a wxmemorybuffer is a useful data structure for storing arbitrary sized blocks of memory. wxmemorybuffer guarantees deletion of the memory block when the object is destroyed.

derived from

none

include files

<wx/buffer.h>

members

wxmemorybuffer::wxmemorybuffer
wxmemorybuffer::getdata
wxmemorybuffer::getbufsize
wxmemorybuffer::getdatalen
wxmemorybuffer::setbufsize
wxmemorybuffer::setdatalen
wxmemorybuffer::getwritebuf
wxmemorybuffer::ungetwritebuf
wxmemorybuffer::getappendbuf
wxmemorybuffer::ungetappendbuf
wxmemorybuffer::appendbyte
wxmemorybuffer::appenddata


wxmemorybuffer::wxmemorybuffer

wxmemorybuffer(const wxmemorybuffer& src)

copy constructor, refcounting is used for performance , but wxmemorybuffer is not a copy-on-write structure so changes made to one buffer effect all copies made from it.

wxmemorybuffer(size_t size)

create a new buffer.

size


wxmemorybuffer::getdata

void* getdata()

return a pointer to the data in the buffer.


wxmemorybuffer::getbufsize

size_t getbufsize()

returns the size of the buffer.


wxmemorybuffer::getdatalen

size_t getdatalen()

returns the length of the valid data in the buffer.


wxmemorybuffer::setbufsize

void setbufsize(size_t size)

ensures the buffer has at least size bytes available.


wxmemorybuffer::setdatalen

void setdatalen(size_t size)

sets the length of the data stored in the buffer. mainly useful for truncating existing data.

size


wxmemorybuffer::getwritebuf

void * getwritebuf(size_t sizeneeded)

ensure the buffer is big enough and return a pointer to the buffer which can be used to directly write into the buffer up to sizeneeded bytes.


wxmemorybuffer::ungetwritebuf

void ungetwritebuf(size_t sizeused)

update the buffer after completing a direct write, which you must have used getwritebuf() to initialise.

sizeused


wxmemorybuffer::getappendbuf

void * getappendbuf(size_t sizeneeded)

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 write data into the buffer, this new data will be appended to the existing data.

sizeneeded


wxmemorybuffer::ungetappendbuf

void ungetappendbuf(size_t sizeused)

update the length after completing a direct append, which you must have used getappendbuf() to initialise.

sizeused


wxmemorybuffer::appendbyte

void appendbyte(char data)

append a single byte to the buffer.

data


wxmemorybuffer::appenddata

void appenddata(void* data, size_t len)

single call to append a data block to the buffer.

data

len