libqi-api
2.1.4.13
|
Class to store buffer. More...
#include <buffer.hpp>
Public Member Functions | |
Buffer () | |
Default constructor. More... | |
Buffer (const Buffer &b) | |
Copy constructor. More... | |
Buffer & | operator= (const Buffer &b) |
Assignment operator. More... | |
bool | write (const void *data, size_t size) |
Write data in the buffer. More... | |
size_t | addSubBuffer (const Buffer &buffer) |
Add a sub-buffer to the main buffer. More... | |
bool | hasSubBuffer (size_t offset) const |
Check if there is a sub-buffer at given offset. More... | |
const Buffer & | subBuffer (size_t offset) const |
Return the sub-buffer at given offset. More... | |
size_t | size () const |
Return the content size of this buffer not counting sub-buffers. More... | |
size_t | totalSize () const |
Return the content size of this buffer and of all its sub-buffers. More... | |
const std::vector< std::pair < size_t, Buffer > > & | subBuffers () const |
Return a vector of sub-buffers of the current buffer. More... | |
void * | reserve (size_t size) |
Reserve bytes at the end of current buffer. More... | |
void | clear () |
Erase content of buffer and remove sub-buffers whithout clearing them. More... | |
void * | data () |
Return a pointer to the raw data storage of this buffer. More... | |
const void * | data () const |
Return a const pointer to the raw data in this buffer. More... | |
const void * | read (size_t offset=0, size_t length=0) const |
Read some data from the buffer. More... | |
size_t | read (void *buffer, size_t offset=0, size_t length=0) const |
Read some data in the buffer and store it in a new pre-allocated buffer. More... | |
Friends | |
class | BufferReader |
Class to store buffer.
* This class can store buffer and sub-buffers. * Here is a representation of internal management of sub-buffers. * * .. graphviz:: * * digraph g { * graph [ rankdir = "LR" ]; * node [ fontsize = "16", shape = "ellipse" ]; * * subgraph cluster_buffer { * mainbuffer; * label = "Main buffer"; * } * * subgraph cluster_subbuffer1 { * subbuffer1; * label = "Sub-buffer 1"; * } * * subgraph cluster_subbuffer2 { * subbuffer2; * label = "Sub-buffer 2"; * } * * "mainbuffer" [ * label = "...| ...| ...| ...| ...| ...|<f0> uint32_t subBufferSize| ...| ...|<f1> uint32_t subBufferSize| ...| ...| ..." * shape = "record" * ]; * "subbuffer1" [ * label = "<f0> ...| ...|...| ...| ...| ...| ...| ...| ...| ..." * shape = "record" * ]; * "subbuffer2" [ * label = "<f0> ...| ...|...| ...| ...| ...| ...| ...| ...| ..." * shape = "record" * ]; * "mainbuffer":f0-> "subbuffer1":f0[ * id = 0 * ]; * "mainbuffer":f1-> "subbuffer2":f0[ * id = 0 * ]; * } * *
Definition at line 26 of file buffer.hpp.
qi::Buffer::Buffer | ( | ) |
Default constructor.
qi::Buffer::Buffer | ( | const Buffer & | buffer | ) |
Copy constructor.
As data are store as a shared pointer, the different copy of the same buffer all handle the same data.
buffer | The buffer to copy. |
qi::Buffer::addSubBuffer | ( | const Buffer & | buffer | ) |
Add a sub-buffer to the main buffer.
This function add a uint32_t for the size of sub-buffers in main buffer and add the buffer to the list of sub-buffers.
buffer | The buffer to have as sub-buffer. |
qi::Buffer::clear | ( | ) |
Erase content of buffer and remove sub-buffers whithout clearing them.
qi::Buffer::data | ( | ) |
Return a pointer to the raw data storage of this buffer.
qi::Buffer::data | ( | ) | const |
Return a const pointer to the raw data in this buffer.
qi::Buffer::hasSubBuffer | ( | size_t | offset | ) | const |
Check if there is a sub-buffer at given offset.
offset | The offset to look at the presence of sub-buffer. |
qi::Buffer::operator= | ( | const Buffer & | buffer | ) |
Assignment operator.
As data are store as a shared pointer, the different copy of the same buffer all handle the same data.
buffer | The buffer to copy. |
qi::Buffer::read | ( | size_t | offset = 0 , |
size_t | length = 0 |
||
) | const |
Read some data from the buffer.
offset | offset at which reading begin in the buffer. |
length | length of the data to read. |
qi::Buffer::read | ( | void * | buffer, |
size_t | offset = 0 , |
||
size_t | length = 0 |
||
) | const |
Read some data in the buffer and store it in a new pre-allocated buffer.
buffer | the pre-allocated buffer to store data. |
offset | Offset in the current buffer to start copy. |
length | Length of the data to be copied. |
qi::Buffer::reserve | ( | size_t | size | ) |
Reserve bytes at the end of current buffer.
size | number of new bytes to reserve at the end of buffer. |
qi::Buffer::size | ( | ) | const |
qi::Buffer::subBuffer | ( | size_t | offset | ) | const |
Return the sub-buffer at given offset.
If there is no sub-buffer throw a std::runtime_error.
offset | The offset to look for sub-buffer. |
qi::Buffer::subBuffers | ( | ) | const |
Return a vector of sub-buffers of the current buffer.
qi::Buffer::totalSize | ( | ) | const |
qi::Buffer::write | ( | const void * | data, |
size_t | size | ||
) |
Write data in the buffer.
data | The data to write |
size | The size of the data to write |
|
friend |
Definition at line 70 of file buffer.hpp.