xorp

Buffer Class Reference

A class for storing buffered data. More...

#include <buffer.hh>

List of all members.

Public Member Functions

 Buffer (size_t init_max_size)
 Constructor of a buffer of specified size.
 ~Buffer ()
 Destructor.
void reset ()
 Reset/remove the data in the buffer.
size_t max_size () const
size_t data_size () const
uint8_t data (size_t offset) const throw (InvalidBufferOffset)
 Get the data value of the octet at the specified offset.
uint8_t * data ()
int add_data (uint8_t value)
 Add a data octet to the buffer.
bool is_full () const
 Test if the buffer is full.

Private Attributes

size_t _max_size
size_t _cur_size
uint8_t * _data

Detailed Description

A class for storing buffered data.

This class can be used to conveniently store data. Note: currently it has limited functionalities; more will be added in the future.


Constructor & Destructor Documentation

Buffer::Buffer ( size_t  init_max_size) [inline, explicit]

Constructor of a buffer of specified size.

Parameters:
init_max_sizethe maximum amount of data that can be stored in the buffer.

Member Function Documentation

int Buffer::add_data ( uint8_t  value) [inline]

Add a data octet to the buffer.

Parameters:
valuethe value of the data octet to add to the buffer.
Returns:
XORP_OK on success, otherwise XORP_ERROR.
uint8_t* Buffer::data ( ) [inline]
Returns:
a pointer to the data in the buffer.
uint8_t Buffer::data ( size_t  offset) const throw (InvalidBufferOffset) [inline]

Get the data value of the octet at the specified offset.

Parameters:
offsetthe data offset from the beginning of the buffer.
Returns:
the data value at offset.
size_t Buffer::data_size ( ) const [inline]
Returns:
the amount of data in the buffer.
bool Buffer::is_full ( ) const [inline]

Test if the buffer is full.

Returns:
true if the buffer is full, otherwise false.
size_t Buffer::max_size ( ) const [inline]
Returns:
the maximum amount of data that can be stored in the buffer.

The documentation for this class was generated from the following file:
 All Classes Namespaces Functions Variables Typedefs Enumerations