libqi-api  2.1.4.13
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | List of all members
qi::BufferReader Class Reference

Class to read const buffer. More...

#include <bufferreader.hpp>

Public Member Functions

 BufferReader (const Buffer &buf)
 Constructor. More...
 
 ~BufferReader ()
 Default destructor. More...
 
size_t read (void *data, size_t length)
 read and store data from the buffer. More...
 
void * read (size_t offset)
 read data from buffer. More...
 
bool seek (size_t offset)
 Move forward the buffer cursor by the given offset. More...
 
void * peek (size_t offset) const
 Check if we can read from the actual position toward offset bytes. More...
 
bool hasSubBuffer () const
 Check if there is sub-buffer at the actual position. More...
 
const BuffersubBuffer ()
 return the sub-buffer at the actual position. More...
 
size_t position () const
 return the actual position in the buffer. More...
 

Detailed Description

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.

Definition at line 15 of file bufferreader.hpp.

Constructor & Destructor Documentation

qi::BufferReader::BufferReader ( const Buffer buf)
explicit

Constructor.

Parameters
bufThe buffer to copy.
qi::BufferReader::~BufferReader ( )

Default destructor.

Member Function Documentation

qi::BufferReader::hasSubBuffer ( ) const

Check if there is sub-buffer at the actual position.

Returns
true if there is sub-buffer, false otherwise.
qi::BufferReader::peek ( size_t  offset) const

Check if we can read from the actual position toward offset bytes.

Warning
This function doesn't move the internal pointer.
Parameters
offsetThe relative offset.
Returns
The pointer if it succeed. If actual position + offset exceed size of buffer return 0.
qi::BufferReader::position ( ) const

return the actual position in the buffer.

Returns
The current offset.
qi::BufferReader::read ( void *  data,
size_t  length 
)

read and store data from the buffer.

Parameters
dataA pre-allocated pointer to store read data.
lengthSize of the object pointed by data or size to read.
Returns
size of really read and stored data.
qi::BufferReader::read ( size_t  offset)

read data from buffer.

Parameters
offsetNumber of bytes to read.
Returns
a pointer to data at the given
qi::BufferReader::seek ( size_t  offset)

Move forward the buffer cursor by the given offset.

Parameters
offsetValue for move forward the cursor. \ return Return true if succeed, false otherwise.
qi::BufferReader::subBuffer ( )

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.

The documentation for this class was generated from the following files: