|
#include <BufferStorage.h>
Public Member Functions | |
| BufferStorage () | |
| BufferStorage (size_t sz) | |
| BufferStorage (const BufferStorage &bufferStorage)=default | |
| BufferStorage (BufferStorage &&bufferStorage) noexcept=default | |
| virtual | ~BufferStorage ()=default |
| BufferStorage & | operator= (const BufferStorage &bufferStorage)=default |
| BufferStorage & | operator= (BufferStorage &&bufferStorage) noexcept=default |
| template<typename T > | |
| BufferStorage (const T *data, size_t sz) | |
| uint8_t * | data () |
| const uint8_t * | data () const |
| const char * | c_str () const |
| bool | empty () const |
| virtual void | checkSize (size_t sz) |
| template<typename T > | |
| void | set (const T *data, size_t sz) |
| void | set (const BufferStorage &data) |
| void | set (const String &data) |
| size_t | capacity () const |
| size_t | length () const |
| size_t | bytes () const |
| void | bytes (size_t b) |
| virtual void | append (char ch) |
| virtual void | append (const char *data, size_t sz=0) |
| virtual void | append (const uint8_t *data, size_t sz) |
| void | reset (size_t sz=0) |
| void | fill (char ch, size_t count) |
| void | erase (size_t offset, size_t length) |
Protected Member Functions | |
| void | adjustSize (size_t sz) |
| void | allocate (size_t size) |
| void | allocate (const uint8_t *data, size_t size) |
| void | reallocate (size_t size) |
| void | deallocate () noexcept |
| void | init (const uint8_t *data, size_t size, size_t bytes) |
Memory data buffer storage
|
inline |
Default constructor
Creates an empty buffer.
|
inlineexplicit |
|
default |
Copy constructor
| bufferStorage | Other object |
|
defaultnoexcept |
Move constructor
| bufferStorage | Other object |
|
virtualdefault |
Destructor
|
inline |
Constructor
Creates a buffer from void *data. The data is copied inside the buffer. The return of the bytes() method will be the input data size.
| data | Data buffer |
| sz | Data buffer size |
|
protected |
Resizes current buffer
| sz | Required memory size |
|
inlineprotected |
Allocate memory
| size | Number of bytes for new buffer |
|
inlineprotected |
Allocate memory
| size | Number of bytes for new buffer |
|
virtual |
Appends a single char to the current buffer.
Allocates memory if needed.
| ch | Single character |
Reimplemented in sptk::Buffer.
Referenced by sptk::Buffer::append().
|
virtual |
Appends the external data of size sz to the current buffer.
Allocates memory if needed.
| data | External data buffer |
| sz | Required memory size |
Reimplemented in sptk::Buffer.
|
virtual |
Appends the external data of size sz to the current buffer.
Allocates memory if needed.
| data | External data buffer |
| sz | Required memory size |
Reimplemented in sptk::Buffer.
|
inline |
Returns the size of data in the data buffer
Referenced by sptk::Buffer::append(), sptk::ReadBuffer::available(), sptk::ReadBuffer::eof(), sptk::WSString::operator=(), sptk::QueryParameter::operator=(), and sptk::Field::operator=().
|
inline |
Sets the size of the data stored
Doesn't check anything so use it this caution.
| b | New size of the buffer |
|
inline |
Returns const char pointer on the data buffer.
|
inline |
Returns the size of memory allocated for the data buffer
|
inlinevirtual |
Checks if the current buffer size is enough
Allocates memory if needed.
| sz | Required memory size |
|
inline |
Returns pointer on the data buffer.
Referenced by sptk::Buffer::append(), sptk::ReadBuffer::head(), sptk::WSString::operator=(), sptk::QueryParameter::operator=(), sptk::Field::operator=(), and sptk::ReadBuffer::read().
|
inline |
Returns pointer on the data buffer.
|
inlineprotectednoexcept |
Free memory
|
inline |
Returns true if number of bytes in buffer is zero.
| void sptk::BufferStorage::erase | ( | size_t | offset, |
| size_t | length | ||
| ) |
Remove fragment from buffer's content
| offset | Fragment start offset |
| length | Fragment length |
| void sptk::BufferStorage::fill | ( | char | ch, |
| size_t | count | ||
| ) |
Fills the bytes() characters in buffer with character ch.
| ch | The character to fill the buffer |
| count | How many characters are to be filled. If counter is greater than capacity, then buffer is extended. |
|
inline |
Returns the size of data in the data buffer
|
inlineprotected |
Reallocate memory
| size | Number of bytes for new buffer |
| void sptk::BufferStorage::reset | ( | size_t | sz = 0 | ) |
Truncates the current buffer to the size sz.
Deallocates unused memory if needed.
| sz | Required data size in bytes |
|
inline |
Copies the external data of size sz into the current buffer.
Allocates memory if needed.
| data | External data buffer |
|
inline |
Copies the external data of size sz into the current buffer.
Allocates memory if needed.
| data | External data |
|
inline |
Copies the external data of size sz into the current buffer.
Allocates memory if needed.
| data | External data buffer |
| sz | Required memory size |