All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ndn::Buffer Class Reference

Class representing a general-use automatically managed/resized buffer. More...

#include <buffer.hpp>

Inheritance diagram for ndn::Buffer:
[legend]
Collaboration diagram for ndn::Buffer:
[legend]

Public Member Functions

 Buffer ()
 Creates an empty buffer. More...
 
 Buffer (size_t size)
 Creates a buffer with pre-allocated size. More...
 
 Buffer (const void *buf, size_t length)
 Create a buffer by copying the supplied data from a const buffer. More...
 
template<class InputIterator >
 Buffer (InputIterator first, InputIterator last)
 Create a buffer by copying the supplied data using iterator interface. More...
 
uint8_t * get ()
 Get pointer to the first byte of the buffer. More...
 
uint8_t * buf ()
 Get pointer to the first byte of the buffer (alternative version) More...
 
template<class T >
T * get ()
 Get pointer to the first byte of the buffer and cast it (reinterpret_cast) to the requested type T. More...
 
const uint8_t * buf () const
 Get pointer to the first byte of the buffer (alternative version) More...
 
const uint8_t * get () const
 Get const pointer to the first byte of the buffer. More...
 
template<class T >
const T * get () const
 Get const pointer to the first byte of the buffer and cast it (reinterpret_cast) to the requested type T. More...
 

Data Fields

elements
 STL member. More...
 

Detailed Description

Class representing a general-use automatically managed/resized buffer.

In most respect, Buffer class is equivalent to std::vector<uint8_t> and is in fact uses it as a base class. In addition to that, it provides buf() and buf<T>() helper method for easier access to the underlying data (buf<T>() casts pointer to the requested class)

Definition at line 28 of file buffer.hpp.

Constructor & Destructor Documentation

ndn::Buffer::Buffer ( )
inline

Creates an empty buffer.

Definition at line 34 of file buffer.hpp.

ndn::Buffer::Buffer ( size_t  size)
inlineexplicit

Creates a buffer with pre-allocated size.

Parameters
sizesize of the buffer to be allocated

Definition at line 43 of file buffer.hpp.

ndn::Buffer::Buffer ( const void *  buf,
size_t  length 
)
inline

Create a buffer by copying the supplied data from a const buffer.

Parameters
bufconst pointer to buffer
lengthlength of the buffer to copy

Definition at line 53 of file buffer.hpp.

template<class InputIterator >
ndn::Buffer::Buffer ( InputIterator  first,
InputIterator  last 
)
inline

Create a buffer by copying the supplied data using iterator interface.

Note that the supplied iterators must be compatible with std::vector<uint8_t> interface

Parameters
firstiterator to a first element to copy
lastiterator to an element immediately following the last element to copy

Definition at line 68 of file buffer.hpp.

Member Function Documentation

uint8_t* ndn::Buffer::buf ( )
inline

Get pointer to the first byte of the buffer (alternative version)

Definition at line 86 of file buffer.hpp.

const uint8_t* ndn::Buffer::buf ( ) const
inline

Get pointer to the first byte of the buffer (alternative version)

Definition at line 106 of file buffer.hpp.

uint8_t* ndn::Buffer::get ( )
inline

Get pointer to the first byte of the buffer.

Definition at line 77 of file buffer.hpp.

template<class T >
T* ndn::Buffer::get ( )
inline

Get pointer to the first byte of the buffer and cast it (reinterpret_cast) to the requested type T.

Definition at line 97 of file buffer.hpp.

const uint8_t* ndn::Buffer::get ( ) const
inline

Get const pointer to the first byte of the buffer.

Definition at line 115 of file buffer.hpp.

template<class T >
const T* ndn::Buffer::get ( ) const
inline

Get const pointer to the first byte of the buffer and cast it (reinterpret_cast) to the requested type T.

Definition at line 126 of file buffer.hpp.

Field Documentation

T std::vector< T >::elements
inherited

STL member.