Global Classes
class qi::BufferReader
class qi::Buffer
Buffer
()Buffer
(const Buffer& buffer)operator=
(const Buffer& buffer)Buffer
(Buffer&& buffer)operator=
(Buffer&& buffer)write
(const void* data, size_t size)addSubBuffer
(const Buffer& buffer)hasSubBuffer
(size_t offset) constsubBuffer
(size_t offset) constsize
() consttotalSize
() constsubBuffers
() constreserve
(size_t size)clear
()data
()data
() constread
(size_t offset, size_t length) constread
(void* buffer, size_t offset, size_t length) constThis class can store buffer and sub-buffers. Here is a representation of internal management of sub-buffers.
qi::Buffer::
Buffer
()¶Default constructor.
qi::Buffer::
Buffer
(const Buffer& buffer)¶Brief: Copy constructor.
Parameters: |
|
---|
As data are store as a shared pointer, the different copy of the same buffer all handle the same data.
qi::Buffer::
operator=
(const Buffer& buffer)¶Brief: Assignment operator. As data are store as a shared pointer, the different copy of the same buffer all handle the same data.
Parameters: |
|
---|
qi::Buffer::
Buffer
(Buffer&& buffer)¶Brief: Move constructor. The moved-from buffer’s state is like a default constructed Buffer.
Parameters: |
|
---|
qi::Buffer::
operator=
(Buffer&& buffer)¶Brief: Move assignment operator. The moved-from buffer’s state is like a default constructed Buffer.
Parameters: |
|
---|
qi::Buffer::
write
(const void* data, size_t size)¶Brief: Write data in the buffer.
Parameters: |
|
---|---|
Returns: | true if operation succeeded, false otherwise. |
qi::Buffer::
addSubBuffer
(const Buffer& buffer)¶Brief: 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.
Parameters: |
|
---|---|
Returns: | return te offset at which sub-buffer have been added. |
qi::Buffer::
hasSubBuffer
(size_t offset) const
¶Brief: Check if there is a sub-buffer at given offset.
Parameters: |
|
---|---|
Returns: | true if there is a sub-buffer, false otherwise. |
qi::Buffer::
subBuffer
(size_t offset) const
¶Brief: Return the sub-buffer at given offset. If there is no sub-buffer throw a std::runtime_error.
Parameters: |
|
---|---|
Returns: | the sub-buffer. |
qi::Buffer::
size
() const
¶Brief: Return the content size of this buffer not counting sub-buffers.
Returns: | the size. |
---|
qi::Buffer::
totalSize
() const
¶Brief: Return the content size of this buffer and of all its sub-buffers.
Returns: | the size. |
---|
qi::Buffer::
subBuffers
() const
¶Brief: Return a vector of sub-buffers of the current buffer.
Returns: | a vector of pairs. The first value of the pair is the offset of the sub-buffer into the master buffer. The second value is the sub-buffer itself. |
---|
qi::Buffer::
reserve
(size_t size)¶Brief: Reserve bytes at the end of current buffer.
Parameters: |
|
---|---|
Returns: | a pointer to the data. |
qi::Buffer::
clear
()¶Erase content of buffer and remove sub-buffers whithout clearing them.
qi::Buffer::
data
()¶Brief: Return a pointer to the raw data storage of this buffer.
Returns: | the pointer to the data. |
---|
qi::Buffer::
data
() const
¶Brief: Return a const pointer to the raw data in this buffer.
Returns: | the pointer to the data. |
---|
qi::Buffer::
read
(size_t offset = 0, size_t length = 0) const
¶Brief: Read some data from the buffer.
Parameters: |
|
---|---|
Returns: | 0 if the buffer is empty or if we try to read data after the end of the buffer. Otherwise return a pointer to the data. Only length bytes can be read in the returned buffer. |
qi::Buffer::
read
(void* buffer, size_t offset = 0, size_t length = 0) const
¶Brief: Read some data in the buffer and store it in a new pre-allocated buffer.
Parameters: |
|
---|---|
Returns: | -1 if there is no data in buffer or if offset is bigger than total data in buffer. Otherwise return the total length of copied data. |
Class to read const buffer. This class is intendeed to read buffer. It store an internal data cursor and an internal sub-buffer index. All offset are relative to the current position. More...
#include <qi/buffer.hpp>
BufferReader
(const Buffer& buf)~BufferReader
()read
(void* data, size_t length)read
(size_t offset)seek
(size_t offset)peek
(size_t offset) consthasSubBuffer
() constsubBuffer
()position
() constClass to read const buffer. This class is intendeed to read buffer. It store an internal data cursor and an internal sub-buffer index. All offset are relative to the current position.
qi::BufferReader::
BufferReader
(const Buffer& buf)¶Brief: Constructor.
Parameters: |
|
---|
qi::BufferReader::
~BufferReader
()¶Default destructor.
qi::BufferReader::
read
(void* data, size_t length)¶Brief: read and store data from the buffer.
Parameters: |
|
---|---|
Returns: | size of really read and stored data. |
qi::BufferReader::
read
(size_t offset)¶Brief: read data from buffer.
Parameters: |
|
---|---|
Returns: | a pointer to data at the given |
qi::BufferReader::
seek
(size_t offset)¶Brief: Move forward the buffer cursor by the given offset.
Parameters: |
|
---|---|
Returns: | Return true if succeed, false otherwise. |
qi::BufferReader::
peek
(size_t offset) const
¶Brief: Check if we can read from the actual position toward offset bytes.
Parameters: |
|
---|---|
Returns: | The pointer if it succeed. If actual position + offset exceed size of buffer return 0. |
qi::BufferReader::
hasSubBuffer
() const
¶Brief: Check if there is sub-buffer at the actual position.
Returns: | true if there is sub-buffer, false otherwise. |
---|
qi::BufferReader::
subBuffer
()¶Brief: return the sub-buffer at the actual position. If there is no sub-buffer at actual position throw a std::runtime-error.
Returns: | Return the sub-buffer if any. |
---|
qi::BufferReader::
position
() const
¶Brief: Return the actual position in the buffer.
Returns: | The current offset. |
---|