Public Member Functions | |
CFX_BinaryBuf (IFX_Allocator *pAllocator=0) | |
A default constructor creating an empty buffer. More... | |
CFX_BinaryBuf (FX_STRSIZE size, IFX_Allocator *pAllocator=0) | |
A default constructor creating an empty buffer. More... | |
~CFX_BinaryBuf () | |
The destructor. | |
FX_BOOL | AppendBlock (const void *pBuf, FX_STRSIZE size) |
Append a binary buffer block. More... | |
void | AppendByte (FX_BYTE byte) |
Append a single byte. More... | |
FX_BOOL | AppendFill (FX_BYTE byte, FX_STRSIZE count) |
Append a byte for specified number times. Not a byte-by-byte processing, but a byte filling processing internally. More... | |
void | AppendString (FX_BSTR str) |
Append a non-buffered byte string. More... | |
void | AttachData (void *pBuf, FX_STRSIZE size) |
Attach to a buffer (this buffer will belong to this object). The buffer must be allocated by FX_Alloc. More... | |
void | Clear () |
Set the binary buffer to be empty. More... | |
FX_BOOL | CopyData (const void *pBuf, FX_STRSIZE size) |
Copy from another buffer. More... | |
void | Delete (int start_index, int count) |
Delete a inter-zone buffer defining by parameters start_index and count in the binary buffer. More... | |
void | DetachBuffer () |
Detach the buffer. Just set buffer pointer to NULL, and set the binary buffer size to zero. More... | |
FX_BOOL | EstimateSize (FX_STRSIZE size, FX_STRSIZE alloc_step=0) |
Change the allocated buffer size, and set the allocation step if alloc_step is non-zero. More... | |
FX_LPBYTE | GetBuffer () const |
Get a byte pointer to the binary buffer. More... | |
CFX_ByteStringC | GetByteString () const |
Get a byte string from the buffer. More... | |
void | GetByteStringL (CFX_ByteStringL &str) const |
Get a byte string from current buffer object. More... | |
FX_STRSIZE | GetSize () const |
Get the length of the binary buffer. More... | |
FX_BOOL | InsertBlock (FX_STRSIZE pos, const void *pBuf, FX_STRSIZE size) |
Insert a binary buffer block at the specified position. More... | |
void | TakeOver (CFX_BinaryBuf &other) |
Takeover another buffer. More... | |
Public Attributes | |
IFX_Allocator * | m_pAllocator |
Special allocator pointer. NULL means to use default allocator. | |
Dynamic binary buffers designed for more efficient appending.
CFX_BinaryBuf::CFX_BinaryBuf | ( | IFX_Allocator * | pAllocator = 0 | ) |
A default constructor creating an empty buffer.
[in] | pAllocator | An allocator. Default value: NULL. |
CFX_BinaryBuf::CFX_BinaryBuf | ( | FX_STRSIZE | size, |
IFX_Allocator * | pAllocator = 0 |
||
) |
A default constructor creating an empty buffer.
[in] | size | The size of buffer. |
[in] | pAllocator | An allocator. Default value: NULL. |
FX_BOOL CFX_BinaryBuf::AppendBlock | ( | const void * | pBuf, |
FX_STRSIZE | size | ||
) |
Append a binary buffer block.
[in] | pBuf | A pointer to a binary buffer block. |
[in] | size | The size in bytes of the buffer block. |
|
inline |
Append a single byte.
[in] | byte | A single byte. |
FX_BOOL CFX_BinaryBuf::AppendFill | ( | FX_BYTE | byte, |
FX_STRSIZE | count | ||
) |
Append a byte for specified number times. Not a byte-by-byte processing, but a byte filling processing internally.
[in] | byte | The input byte. |
[in] | count | Number of times. |
|
inline |
Append a non-buffered byte string.
[in] | str | A no-buffered byte string. |
void CFX_BinaryBuf::AttachData | ( | void * | pBuf, |
FX_STRSIZE | size | ||
) |
Attach to a buffer (this buffer will belong to this object). The buffer must be allocated by FX_Alloc.
[in] | pBuf | A pointer to a binary buffer. |
[in] | size | The size in bytes of the buffer. |
void CFX_BinaryBuf::Clear | ( | ) |
Set the binary buffer to be empty.
FX_BOOL CFX_BinaryBuf::CopyData | ( | const void * | pBuf, |
FX_STRSIZE | size | ||
) |
Copy from another buffer.
[in] | pBuf | A pointer to a binary buffer. |
[in] | size | The size in bytes of the input buffer. |
void CFX_BinaryBuf::Delete | ( | int | start_index, |
int | count | ||
) |
Delete a inter-zone buffer defining by parameters start_index and count in the binary buffer.
[in] | start_index | Specifies the zero-based index of the start position to be deleted in the binary buffer. |
[in] | count | Specifies the length in bytes to be deleted. |
void CFX_BinaryBuf::DetachBuffer | ( | ) |
Detach the buffer. Just set buffer pointer to NULL, and set the binary buffer size to zero.
FX_BOOL CFX_BinaryBuf::EstimateSize | ( | FX_STRSIZE | size, |
FX_STRSIZE | alloc_step = 0 |
||
) |
Change the allocated buffer size, and set the allocation step if alloc_step is non-zero.
[in] | size | The new size expected. |
[in] | alloc_step | The new allocation step. If alloc_step is 0, then the allocation step will not change. Default value: 0. |
|
inline |
Get a byte pointer to the binary buffer.
CFX_ByteStringC CFX_BinaryBuf::GetByteString | ( | ) | const |
Get a byte string from the buffer.
void CFX_BinaryBuf::GetByteStringL | ( | CFX_ByteStringL & | str | ) | const |
Get a byte string from current buffer object.
[out] | str | Receives the byte string from current buffer object. |
|
inline |
Get the length of the binary buffer.
FX_BOOL CFX_BinaryBuf::InsertBlock | ( | FX_STRSIZE | pos, |
const void * | pBuf, | ||
FX_STRSIZE | size | ||
) |
Insert a binary buffer block at the specified position.
[in] | pos | Specifies the zero-based index of the position in the binary buffer. |
[in] | pBuf | A pointer to a binary buffer block. |
[in] | size | The size in bytes of the buffer block. |
void CFX_BinaryBuf::TakeOver | ( | CFX_BinaryBuf & | other | ) |
Takeover another buffer.
This function attaches to the source CFX_BinaryBuf object's buffer. The source CFX_BinaryBuf object has detached the buffer.
[in] | other | A ref to CFX_BinaryBuf object. |