libqi-api  2.0.6.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions
qi::BufferReader Class Reference

Class to read const buffer. More...

#include <bufferreader.hpp>

List of all members.

Public Member Functions

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

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.

Default destructor.


Member Function Documentation

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.

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.

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:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines