Base Framework
|
#include <base/mem/Buffer.h>
Inherits Object.
Public Member Functions | |
Buffer (MemorySize size=0, MemorySize granularity=DEFAULT_GRANULARITY) | |
Buffer (const Buffer ©) | |
uint8 * | getBytes () noexcept |
const uint8 * | getBytes () const noexcept |
MemorySize | getSize () const noexcept |
void | setSize (MemorySize size) |
uint8 | operator[] (MemorySize i) const |
uint8 & | operator[] (MemorySize i) |
uint8 * | begin () noexcept |
uint8 * | end () noexcept |
const uint8 * | begin () const noexcept |
const uint8 * | end () const noexcept |
operator bool () const noexcept | |
~Buffer () noexcept | |
Static Public Attributes | |
static const MemorySize | DEFAULT_GRANULARITY = 1024 |
Protected Attributes | |
HeapBlockOwned< uint8 > | heap |
MemorySize | size = 0 |
MemorySize | granularity = DEFAULT_GRANULARITY |
This class implements a resizeable buffer and provides some low-level operations. The implementation is not MT-safe.
|
explicit |
Initializes the buffer of given size and does not clear the memory. Raises MemoryException if unable to allocate the required memory.
size | Specifies the initial size of the buffer. Default is 0. |
granularity | Specifies the granularity of the size. Default is given by DEFAULT_GRANULARITY. |
Buffer::Buffer | ( | const Buffer & | copy | ) |
Copy constructor. Raises MemoryException if unable to allocate the required memory.
|
noexcept |
Destroys the buffer.
|
inlinenoexcept |
Returns the bytes of the buffer.
|
inlinenoexcept |
Returns the bytes of the buffer.
|
inlinenoexcept |
Returns the size of the buffer.
|
inline |
Returns the byte at the given index.
|
inline |
Returns the byte at the given index.
void Buffer::setSize | ( | MemorySize | size | ) |
Sets the size of the buffer. The original bytes of the buffer are not changed. If the buffer is expanded the bytes are not initialized. Raises MemoryException if unable to adjust the size of the buffer or the buffer is externally managed.
size | The desired size. |
|
static |
Specifies the granularity of the buffer size. Guaranteed to be greater than 16 bytes.
|
protected |
The granularity of the size.
|
protected |
The bytes of the buffer.
|
protected |
The size of the buffer.