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

General-purpose 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)
 Creates a Buffer by copying contents from a raw buffer. More...
 
template<class InputIt >
 Buffer (InputIt first, InputIt last)
 Creates a Buffer by copying the elements of the range [first, last) More...
 
template<class T >
T * get () noexcept
 
template<class T >
const T * get () const noexcept
 

Detailed Description

General-purpose automatically managed/resized buffer.

In most respect, the Buffer class is equivalent to a std::vector<uint8_t>, and it in fact uses the latter as a base class. In addition to that, it provides the get<T>() helper method that automatically casts the returned pointer to the requested type.

Definition at line 40 of file buffer.hpp.

Constructor & Destructor Documentation

ndn::Buffer::Buffer ( )
default

Creates an empty Buffer.

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 40 of file buffer.cpp.

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

Creates a Buffer by copying contents from a raw buffer.

Parameters
bufconst pointer to buffer to copy
lengthlength of the buffer to copy

Definition at line 45 of file buffer.cpp.

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

Creates a Buffer by copying the elements of the range [first, last)

Parameters
firstan input iterator to the first element to copy
lastan input iterator to the element immediately following the last element to copy

Definition at line 64 of file buffer.hpp.

Member Function Documentation

template<class T >
T* ndn::Buffer::get ( )
inlinenoexcept
Returns
pointer to the first byte of the buffer, cast to the requested type T

Definition at line 73 of file buffer.hpp.

template<class T >
const T* ndn::Buffer::get ( ) const
inlinenoexcept
Returns
const pointer to the first byte of the buffer, cast to the requested type T

Definition at line 82 of file buffer.hpp.


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