- Aldebaran documentation |
- C++ Libraries |
- index

libqi-api 2.8.7.4

- Main Page
- Related Pages
- Namespaces
- Classes
- Files
- Examples

- Class List
- Class Hierarchy
- Class Members

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

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 <buffer.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 Buffer & | subBuffer ()
| return the sub-buffer at the actual position. If there is no sub-buffer at actual position throw a std::runtime-error. 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 227 of file buffer.hpp.

## Constructor & Destructor Documentation

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

Constructor.

Parameters

  buf | The buffer to copy.

qi::BufferReader::~BufferReader | ( |  | ) |

Default destructor.

## Member Function Documentation

bool qi::BufferReader::hasSubBuffer | ( |  | ) | const

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

Returns
  true if there is sub-buffer, false otherwise.

void* 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

  offset | The relative offset.

Returns
  The pointer if it succeed. If actual position + offset exceed size of buffer return 0.

size_t qi::BufferReader::position | ( |  | ) | const

Return the actual position in the buffer.

Returns
  The current offset.

size_t qi::BufferReader::read | ( | void * | data,
|  | size_t | length
| ) |  |

read and store data from the buffer.

Parameters

  data | A pre-allocated pointer to store read data.
  length | Size of the object pointed by data or size to read.

Returns
  size of really read and stored data.

void* qi::BufferReader::read | ( | size_t | offset | ) |

read data from buffer.

Parameters

  offset | Number of bytes to read.

Returns
  a pointer to data at the given

bool qi::BufferReader::seek | ( | size_t | offset | ) |

Move forward the buffer cursor by the given offset.

Parameters

  offset | Value for move forward the cursor.

Returns
  Return true if succeed, false otherwise.

const Buffer& 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 file:

- /home/opennao/work/release-2.8/sdk/libqi/qi/buffer.hpp