![]() |
Libftpp
A modern C++ library
|
A simple LIFO data buffer for serialization and deserialization for simple data types and std::string. More...
#include <data_buffer.hpp>
Public Member Functions | |
| DataBuffer () | |
| ~DataBuffer ()=default | |
| const std::vector< unsigned char > | data () const |
| void | increaseCursor (size_t amount) const |
| Increase the read/write cursor by a specified amount. More... | |
| void | decreaseCursor (size_t amount) const |
| Decrease the read/write cursor by a specified amount. More... | |
| void | reset () const |
| Reset the read/write cursor to the beginning of the buffer. More... | |
| void | clear () |
| Clear the buffer and reset the cursor. More... | |
| size_t | size () const |
| void | append (const unsigned char *data, size_t len) |
| DataBuffer & | operator<< (const std::string &value) |
| const DataBuffer & | operator>> (std::string &value) const |
| template<typename T > | |
| DataBuffer & | operator<< (const T &value) |
| template<typename T > | |
| const DataBuffer & | operator>> (T &value) const |
A simple LIFO data buffer for serialization and deserialization for simple data types and std::string.
| std::out_of_range | Thrown when trying to read more data than available in the buffer. |
Definition at line 36 of file data_buffer.hpp.
| DataBuffer::DataBuffer | ( | ) |
Definition at line 3 of file data_buffer.cpp.
|
default |
| void DataBuffer::append | ( | const unsigned char * | data, |
| size_t | len | ||
| ) |
Definition at line 22 of file data_buffer.cpp.
References data().
Referenced by Message::appendBytes().
| void DataBuffer::clear | ( | ) |
Clear the buffer and reset the cursor.
Definition at line 16 of file data_buffer.cpp.
| const std::vector< unsigned char > DataBuffer::data | ( | ) | const |
Definition at line 57 of file data_buffer.cpp.
Referenced by append(), and Message::getSerializedData().
| void DataBuffer::decreaseCursor | ( | size_t | amount | ) | const |
Decrease the read/write cursor by a specified amount.
| amount | The amount to decrease the cursor by. |
Usefull with const data() to move the cursor backward after reading data.
Definition at line 80 of file data_buffer.cpp.
Referenced by Message::decr_cursor(), and Message::isComplet().
| void DataBuffer::increaseCursor | ( | size_t | amount | ) | const |
Increase the read/write cursor by a specified amount.
| amount | The amount to increase the cursor by. |
Usefull with const data() to move the cursor forward after reading data.
Definition at line 67 of file data_buffer.cpp.
Referenced by Message::incr_cursor().
| DataBuffer & DataBuffer::operator<< | ( | const std::string & | value | ) |
Definition at line 29 of file data_buffer.cpp.
References size().
|
inline |
Definition at line 60 of file data_buffer.hpp.
| const DataBuffer & DataBuffer::operator>> | ( | std::string & | value | ) | const |
Definition at line 38 of file data_buffer.cpp.
References size().
|
inline |
Definition at line 68 of file data_buffer.hpp.
| void DataBuffer::reset | ( | ) | const |
Reset the read/write cursor to the beginning of the buffer.
Definition at line 8 of file data_buffer.cpp.
Referenced by Message::reset().
| size_t DataBuffer::size | ( | ) | const |
Definition at line 52 of file data_buffer.cpp.
Referenced by Message::getSerializedData(), Message::isComplet(), operator<<(), and operator>>().