A memory buffer of static size.
More...
#include <StaticBuffer.h>
A memory buffer of static size.
The actual buffer can be allocated or assigned by the caller. If the StaticBuffer "owns" the pointer then it will be released when going out of scope.
Definition at line 45 of file StaticBuffer.h.
Hypertable::StaticBuffer::StaticBuffer |
( |
| ) |
|
|
inline |
Constructor.
Creates an empty buffer
Definition at line 48 of file StaticBuffer.h.
Hypertable::StaticBuffer::StaticBuffer |
( |
size_t |
len, |
|
|
size_t |
alignment = 0 |
|
) |
| |
|
inlineexplicit |
Constructor.
Allocates a new buffer of size len
. If alignment
is non-zero, then the posix_memalign() function will be called to obtain memory and alignment is set to alignment
. Memory will be released when going out of scope.
- Parameters
-
len | The size of the new buffer, in bytes |
alignment | Buffer alignment |
Definition at line 61 of file StaticBuffer.h.
Hypertable::StaticBuffer::StaticBuffer |
( |
void * |
data, |
|
|
uint32_t |
len, |
|
|
bool |
take_ownership = true |
|
) |
| |
|
inline |
Constructor; assigns an existing buffer and can take ownership of that buffer.
- Parameters
-
data | Pointer to the existing buffer |
len | Size of the existing buffer |
take_ownership | If yes, will "own" the existing buffer and delete[] the memory when going out of scope. Make sure that the buffer was allocated with new[]! |
Definition at line 83 of file StaticBuffer.h.
Hypertable::StaticBuffer::~StaticBuffer |
( |
| ) |
|
|
inline |
Destructor; if "own" is true then the buffer will be delete[]d.
Definition at line 100 of file StaticBuffer.h.
Hypertable::StaticBuffer::StaticBuffer |
( |
StaticBuffer & |
other | ) |
|
|
inline |
Copy constructor.
WARNING: This assignment operator will cause the ownership of the buffer to transfer to the lvalue buffer if the own flag is set to 'true' in the buffer being copied. The buffer being copied will be modified to have it's 'own' flag set to false and the 'base' pointer will be set to NULL. In other words, the buffer being copied is no longer usable after the assignment.
- Parameters
-
other | Reference to the original instance |
Definition at line 116 of file StaticBuffer.h.
size_t Hypertable::StaticBuffer::aligned_size |
( |
| ) |
|
|
inline |
void Hypertable::StaticBuffer::free |
( |
| ) |
|
|
inline |
Clears the data; if this object is owner of the data then the allocated buffer is delete[]d.
Definition at line 185 of file StaticBuffer.h.
Assignment operator.
WARNING: This assignment operator will cause the ownership of the buffer to transfer to the lvalue buffer if the own flag is set to 'true' in the buffer being copied. The buffer being copied will be modified to have it's 'own' flag set to false and the 'base' pointer will be set to NULL. In other words, the buffer being copied is no longer usable after the assignment.
- Parameters
-
other | Reference to the original instance |
Definition at line 139 of file StaticBuffer.h.
void Hypertable::StaticBuffer::set |
( |
uint8_t * |
data, |
|
|
uint32_t |
len, |
|
|
bool |
take_ownership = true |
|
) |
| |
|
inline |
Sets data pointer; the existing buffer is discarded and deleted.
- Parameters
-
data | Pointer to the existing buffer |
len | Size of the existing buffer |
take_ownership | If yes, will "own" the existing buffer and delete[] the memory when going out of scope. Make sure that the buffer was allocated with new[]! |
Definition at line 175 of file StaticBuffer.h.
size_t Hypertable::StaticBuffer::alignment |
uint8_t* Hypertable::StaticBuffer::base |
bool Hypertable::StaticBuffer::own |
uint32_t Hypertable::StaticBuffer::size |
The documentation for this class was generated from the following file: