wxWidgets: wxMemoryBuffer Class Reference

| Version: 3.1.5

Loading...
Searching...
No Matches
Public Member Functions | List of all members
wxMemoryBuffer Class Reference
Class List by Category » Data Structures

`#include </cygdrive/c/Users/Hamis/Cygwin-packaging/wxWidgets3.1/wxWidgets3.1-3.1.5-4.x86_64/src/wxWidgets-3.1.5/interface/wx/buffer.h>`

## Detailed Description

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.

##

Library: wxBase

<>< =''>:</>&;&;< =''>\ </></>

## Public Member Functions
| 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=1024)
| Create a new buffer.
void | AppendByte (char data)
| Append a single byte to the buffer.
void | AppendData (const void *data, size_t len)
| Single call to append a data block to the buffer.
void | Clear ()
| Clear the buffer contents.
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.
size_t | GetBufSize () const
| Returns the size of the buffer.
void * | GetData () const
| Return a pointer to the data in the buffer.
size_t | GetDataLen () const
| Returns the length of the valid data in the buffer.
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.
bool | IsEmpty () const
| Returns true if the buffer contains no data.
void | SetBufSize (size_t size)
| Ensures the buffer has at least size bytes available.
void | SetDataLen (size_t size)
| Sets the length of the data stored in the buffer.
void | UngetAppendBuf (size_t sizeUsed)
| Update the length after completing a direct append, which you must have used GetAppendBuf() to initialise.
void | UngetWriteBuf (size_t sizeUsed)
| Update the buffer after completing a direct write, which you must have used GetWriteBuf() to initialise.

## Constructor & Destructor Documentation

## ◆ wxMemoryBuffer() [1/2]

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.

See also
  Reference Counting

## ◆ wxMemoryBuffer() [2/2]

wxMemoryBuffer::wxMemoryBuffer | ( | size_t | size = 1024 | ) |

Create a new buffer.

Parameters

  size | size of the new buffer, 1KiB by default.

## Member Function Documentation

## ◆ AppendByte()

void wxMemoryBuffer::AppendByte | ( | char | data | ) |

Append a single byte to the buffer.

Parameters

  data | New byte to append to the buffer.

## ◆ AppendData()

void wxMemoryBuffer::AppendData | ( | const void * | data,
|  | size_t | len )

Single call to append a data block to the buffer.

Parameters

  data | Pointer to block to append to the buffer.
  len | Length of data to append.

## ◆ Clear()

void wxMemoryBuffer::Clear | ( |  | ) |

Clear the buffer contents.

The buffer won't contain any data after this method is called.

See also
  IsEmpty()

Since
  2.9.4

## ◆ GetAppendBuf()

void * wxMemoryBuffer::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.

Parameters

  sizeNeeded | Amount of extra space required in the buffer for the append operation

## ◆ GetBufSize()

size_t wxMemoryBuffer::GetBufSize | ( |  | ) | const

Returns the size of the buffer.

## ◆ GetData()

void * wxMemoryBuffer::GetData | ( |  | ) | const

Return a pointer to the data in the buffer.

## ◆ GetDataLen()

size_t wxMemoryBuffer::GetDataLen | ( |  | ) | const

Returns the length of the valid data in the buffer.

## ◆ GetWriteBuf()

void * wxMemoryBuffer::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.

## ◆ IsEmpty()

bool wxMemoryBuffer::IsEmpty | ( |  | ) | const

Returns true if the buffer contains no data.

See also
  Clear()

Since
  2.9.4

## ◆ SetBufSize()

void wxMemoryBuffer::SetBufSize | ( | size_t | size | ) |

Ensures the buffer has at least size bytes available.

## ◆ SetDataLen()

void wxMemoryBuffer::SetDataLen | ( | size_t | size | ) |

Sets the length of the data stored in the buffer.

Mainly useful for truncating existing data.

Parameters

  size | New length of the valid data in the buffer. This is distinct from the allocated size

## ◆ UngetAppendBuf()

void wxMemoryBuffer::UngetAppendBuf | ( | size_t | sizeUsed | ) |

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

Parameters

  sizeUsed | This is the amount of new data that has been appended.

## ◆ UngetWriteBuf()

void wxMemoryBuffer::UngetWriteBuf | ( | size_t | sizeUsed | ) |

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

Parameters

  sizeUsed | The amount of data written in to buffer by the direct write