#include <datachunk.h>
Inheritance diagram for DataChunk:
Public Member Functions | |
DataChunk () | |
Construct an empty data chunk. | |
DataChunk (size_t BufferSize) | |
Construct a data chunk with a pre-allocated buffer. | |
DataChunk (size_t MemSize, const UInt8 *Buffer) | |
Construct a data chunk with contents. | |
template<int SIZE> | |
DataChunk (const Identifier< SIZE > *ID) | |
Construct a data chunk from an identifier. | |
DataChunk (const DataChunk &Chunk) | |
Data chunk copy constructor. | |
DataChunk (const DataChunkPtr &Chunk) | |
Data chunk construct from smart pointer. | |
~DataChunk () | |
void | Resize (size_t NewSize, bool PreserveContents=true) |
Resize the data chunk, preserving contents if requested. | |
void | ResizeBuffer (size_t NewSize, bool PreserveContents=true) |
Resize the data buffer, preserving contents if requested. | |
UInt8 * | StealBuffer (bool MakeEmpty=false) |
Steal the buffer belonging to this data chunk. | |
void | Set (const DataChunk &Buffer, size_t Start=0) |
Set some data into a data chunk (expanding it if required). | |
void | Set (const DataChunkPtr &Buffer, size_t Start=0) |
Set some data into a data chunk (expanding it if required). | |
void | Set (size_t MemSize, const UInt8 *Buffer, size_t Start=0) |
Set some data into a data chunk (expanding it if required). | |
void | Append (const DataChunk &Buffer) |
Append some data to a data chunk. | |
void | Append (const DataChunkPtr &Buffer) |
Append some data to a data chunk. | |
void | Append (size_t MemSize, const UInt8 *Buffer) |
Append some data to a data chunk. | |
DataChunk & | operator= (const DataChunk &Right) |
bool | operator== (const DataChunk &Right) const |
bool | operator!= (const DataChunk &Right) const |
std::string | GetString (void) |
Get a (hex) string representation of the data in the buffer. | |
void | SetGranularity (size_t Gran) |
Allocation granularity access functions. | |
size_t | GetGranularity (void) |
void | SetBuffer (UInt8 *Buffer, size_t BuffSize, size_t AllocatedSize=0) |
Set an external buffer as the data buffer. | |
bool | TakeBuffer (DataChunk &OldOwner, bool MakeEmpty=false) |
Transfer ownership of a data buffer from another DataChunk. | |
bool | TakeBuffer (DataChunkPtr &OldOwner, bool MakeEmpty=false) |
Transfer ownership of a data buffer from another DataChunk (via a smart pointer). | |
Public Attributes | |
size_t | Size |
True if the buffer is not owned by us. | |
UInt8 * | Data |
Size of the active data in the buffer. | |
Private Attributes | |
size_t | DataSize |
size_t | AllocationGranularity |
Size of the data buffer. | |
bool | ExternalBuffer |
Granulatiry of new memory allocations. |
DataChunk | ( | ) | [inline] |
Construct an empty data chunk.
DataChunk | ( | size_t | BufferSize | ) | [inline] |
Construct a data chunk with a pre-allocated buffer.
DataChunk | ( | const Identifier< SIZE > * | ID | ) | [inline] |
Construct a data chunk from an identifier.
DataChunk | ( | const DataChunkPtr & | Chunk | ) | [inline] |
Data chunk construct from smart pointer.
~DataChunk | ( | ) | [inline] |
void Resize | ( | size_t | NewSize, | |
bool | PreserveContents = true | |||
) |
Resize the data chunk, preserving contents if requested.
void ResizeBuffer | ( | size_t | NewSize, | |
bool | PreserveContents = true | |||
) |
Resize the data buffer, preserving contents if requested.
The buffer is resized to at least NewSize, but Size remains unchanged
UInt8 * StealBuffer | ( | bool | MakeEmpty = false |
) |
Steal the buffer belonging to this data chunk.
The buffer is detached and ownership moves to the caller. It is the caller's responsibility to free the buffer with delete[] at a later point. If MakeEmpty is false the data chunk will not be empty after the call, but the ownership will still be transferred
void Set | ( | const DataChunk & | Buffer, | |
size_t | Start = 0 | |||
) | [inline] |
Set some data into a data chunk (expanding it if required).
void Set | ( | const DataChunkPtr & | Buffer, | |
size_t | Start = 0 | |||
) | [inline] |
Set some data into a data chunk (expanding it if required).
void Set | ( | size_t | MemSize, | |
const UInt8 * | Buffer, | |||
size_t | Start = 0 | |||
) | [inline] |
Set some data into a data chunk (expanding it if required).
void Append | ( | const DataChunk & | Buffer | ) | [inline] |
Append some data to a data chunk.
void Append | ( | const DataChunkPtr & | Buffer | ) | [inline] |
Append some data to a data chunk.
void Append | ( | size_t | MemSize, | |
const UInt8 * | Buffer | |||
) | [inline] |
Append some data to a data chunk.
bool operator== | ( | const DataChunk & | Right | ) | const [inline] |
bool operator!= | ( | const DataChunk & | Right | ) | const [inline] |
std::string GetString | ( | void | ) |
Get a (hex) string representation of the data in the buffer.
void SetGranularity | ( | size_t | Gran | ) | [inline] |
Allocation granularity access functions.
size_t GetGranularity | ( | void | ) | [inline] |
void SetBuffer | ( | UInt8 * | Buffer, | |
size_t | BuffSize, | |||
size_t | AllocatedSize = 0 | |||
) |
Set an external buffer as the data buffer.
Data
is checked before assuming the external buffer is still in use. bool TakeBuffer | ( | DataChunk & | OldOwner, | |
bool | MakeEmpty = false | |||
) |
bool TakeBuffer | ( | DataChunkPtr & | OldOwner, | |
bool | MakeEmpty = false | |||
) |
size_t DataSize [private] |
size_t AllocationGranularity [private] |
Size of the data buffer.
bool ExternalBuffer [private] |
Granulatiry of new memory allocations.
size_t Size |
True if the buffer is not owned by us.