NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
ndn::Buffer Class Reference

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

#include <buffer.hpp>

Inheritance diagram for ndn::Buffer:
Collaboration diagram for ndn::Buffer:

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 contents from a buffer. More...
 
template<class InputIterator >
 Buffer (InputIterator first, InputIterator last)
 Create a buffer by copying contents of the range [first, last) More...
 
uint8_t * get ()
 
uint8_t * buf ()
 
template<class T >
T * get ()
 
const uint8_t * buf () const
 
const uint8_t * get () const
 
template<class T >
const T * get () const
 

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 44 of file buffer.hpp.

Constructor & Destructor Documentation

◆ Buffer() [1/4]

ndn::Buffer::Buffer ( )

Creates an empty buffer.

Definition at line 38 of file buffer.cpp.

◆ Buffer() [2/4]

ndn::Buffer::Buffer ( size_t  size)
explicit

Creates a buffer with pre-allocated size.

Parameters
sizesize of the buffer to be allocated

Definition at line 42 of file buffer.cpp.

◆ Buffer() [3/4]

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

Create a buffer by copying contents from a buffer.

Parameters
bufconst pointer to buffer
lengthlength of the buffer to copy

Definition at line 47 of file buffer.cpp.

◆ Buffer() [4/4]

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

Create a buffer by copying contents of the range [first, last)

Template Parameters
InputIteratoran InputIterator compatible with std::vector<uint8_t> constructor
Parameters
firstiterator to the first element to copy
lastiterator to the element immediately following the last element to copy

Definition at line 69 of file buffer.hpp.

Member Function Documentation

◆ get() [1/4]

uint8_t* ndn::Buffer::get ( )
inline
Returns
pointer to the first byte of the buffer

Definition at line 77 of file buffer.hpp.

Referenced by ndn::security::SafeBag::wireEncode().

◆ buf() [1/2]

◆ get() [2/4]

template<class T >
T* ndn::Buffer::get ( )
inline
Returns
pointer to the first byte of the buffer and reinterpret_cast it to the requested type T

Definition at line 97 of file buffer.hpp.

◆ buf() [2/2]

const uint8_t* ndn::Buffer::buf ( ) const
inline
Returns
pointer to the first byte of the buffer

This is same as .get()

Definition at line 107 of file buffer.hpp.

◆ get() [3/4]

const uint8_t* ndn::Buffer::get ( ) const
inline
Returns
pointer to the first byte of the buffer

Definition at line 115 of file buffer.hpp.

◆ get() [4/4]

template<class T >
const T* ndn::Buffer::get ( ) const
inline
Returns
const pointer to the first byte of the buffer and reinterpret_cast it to the requested type T

Definition at line 125 of file buffer.hpp.


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