|
#include <Buffer.h>
Public Member Functions | |
| Buffer (const String &str) | |
| Buffer (const Buffer &other)=default | |
| Buffer (Buffer &&other) noexcept=default | |
| ~Buffer () noexcept override=default | |
| Buffer & | operator= (Buffer &&other) DOESNT_THROW=default |
| Buffer & | operator= (const Buffer &other)=default |
| void | append (char ch) override |
| void | append (const char *data, size_t sz=0) override |
| void | append (const uint8_t *data, size_t sz) override |
| template<class T > | |
| void | append (T val) |
| void | append (const std::string &str) |
| void | append (const String &str) |
| void | append (const Buffer &buffer) |
| uint8_t & | operator[] (size_t index) |
| const uint8_t & | operator[] (size_t index) const |
| bool | operator== (const Buffer &other) const |
| bool | operator!= (const Buffer &other) const |
| void | loadFromFile (const fs::path &fileName) |
| void | saveToFile (const fs::path &fileName) const |
| Buffer & | operator= (const String &str) |
| Buffer & | operator= (const char *str) |
| operator String () const | |
| BufferStorage () | |
| BufferStorage (size_t sz) | |
| BufferStorage (const BufferStorage &bufferStorage)=default | |
| BufferStorage (BufferStorage &&bufferStorage) noexcept=default | |
| template<typename T > | |
| BufferStorage (const T *data, size_t sz) | |
Public Member Functions inherited from sptk::BufferStorage | |
| 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) |
Additional Inherited Members | |
Protected Member Functions inherited from sptk::BufferStorage | |
| 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
Generic buffer with a special memory-allocation strategy for effective append() operation
|
explicit |
Constructor
Creates a buffer from string. The string is copied inside the buffer. The return of the bytes() method will be the input string length.
| str | Input string |
|
default |
Copy constructor
Creates a buffer from another buffer.
| other | Data buffer |
|
defaultnoexcept |
Move constructor
Moves a buffer from another buffer.
| other | Data buffer |
|
overridedefaultnoexcept |
Destructor
|
inlineoverridevirtual |
Appends a single char to the current buffer.
Allocates memory if needed.
| ch | Single character |
Reimplemented from sptk::BufferStorage.
References sptk::BufferStorage::append().
|
inline |
Appends the string to the current buffer.
Allocates memory if needed.
| buffer | Data to append |
References sptk::BufferStorage::bytes(), and sptk::BufferStorage::data().
|
inlineoverridevirtual |
Appends the external data of size sz to the current buffer.
Allocates memory if needed.
| data | External data buffer |
| sz | Required memory size |
Reimplemented from sptk::BufferStorage.
References sptk::BufferStorage::append().
|
inline |
Appends the string to the current buffer.
Allocates memory if needed.
| str | String to append |
|
inline |
Appends the string to the current buffer.
Allocates memory if needed.
| str | String to append |
|
inlineoverridevirtual |
Appends the external data of size sz to the current buffer.
Allocates memory if needed.
| data | External data buffer |
| sz | Required memory size |
Reimplemented from sptk::BufferStorage.
References sptk::BufferStorage::append().
|
inline |
Append a value of primitive type or structure to the current buffer.
Allocates memory if needed.
| val | Primitive type or structure |
|
inline |
Default constructor
Creates an empty buffer.
|
defaultnoexcept |
Move constructor
| bufferStorage | Other object |
|
default |
Copy constructor
| bufferStorage | Other object |
|
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 |
|
inlineexplicit |
| void sptk::Buffer::loadFromFile | ( | const fs::path & | fileName | ) |
Loads the buffer from file fileName.
| fileName | Name of the input file |
|
inlineexplicit |
Convertor to std::string
| bool sptk::Buffer::operator!= | ( | const Buffer & | other | ) | const |
Compare operator
| other | Other buffer |
| Buffer & sptk::Buffer::operator= | ( | const char * | str | ) |
Assigns from char *
| str | const char *, the string to assign from |
| bool sptk::Buffer::operator== | ( | const Buffer & | other | ) | const |
Compare operator
| other | Other buffer |
|
inline |
Access the chars by index
| index | Character index |
|
inline |
Access the chars by index, const version
| index | Character index |
| void sptk::Buffer::saveToFile | ( | const fs::path & | fileName | ) | const |
Saves the buffer to the file fileName.
| fileName | Name of the output file |