ndn::encoding::EncodingImpl< EncoderTag > Class Template Reference

EncodingImpl specialization for actual TLV encoding. More...

#include <encoding-buffer.hpp>

+ Inheritance diagram for ndn::encoding::EncodingImpl< EncoderTag >:
+ Collaboration diagram for ndn::encoding::EncodingImpl< EncoderTag >:

Public Types

using const_iterator = Buffer::const_iterator
 
using iterator = Buffer::iterator
 
using value_type = Buffer::value_type
 

Public Member Functions

 EncodingImpl (size_t totalReserve=MAX_NDN_PACKET_SIZE, size_t reserveFromBack=400)
 
 EncodingImpl (const Block &block)
 
size_t appendBlock (const Block &block)
 Append TLV block block. More...
 
size_t appendByte (uint8_t value)
 Append a byte. More...
 
size_t appendByteArray (const uint8_t *array, size_t length)
 Append a byte array array of length length. More...
 
size_t appendByteArrayBlock (uint32_t type, const uint8_t *array, size_t arraySize)
 Append TLV block of type type and value from buffer array of size arraySize. More...
 
size_t appendNonNegativeInteger (uint64_t integer)
 Append non-negative integer integer of NDN TLV encoding. More...
 
template<class Iterator >
size_t appendRange (Iterator first, Iterator last)
 Append range of bytes from the range [first, last) More...
 
size_t appendVarNumber (uint64_t varNumber)
 Prepend VarNumber varNumber of NDN TLV encoding. More...
 
iterator begin ()
 Get an iterator pointing to the first byte of the encoded buffer. More...
 
const_iterator begin () const
 Get an iterator pointing to the first byte of the encoded buffer. More...
 
Block block (bool verifyLength=true) const
 Create Block from the underlying buffer. More...
 
uint8_t * buf ()
 Get a pointer to the first byte of the encoded buffer. More...
 
const uint8_t * buf () const
 Get a pointer to the first byte of the encoded buffer. More...
 
size_t capacity () const
 Get size of the underlying buffer. More...
 
iterator end ()
 Get an iterator pointing to the past-the-end byte of the encoded buffer. More...
 
const_iterator end () const
 
shared_ptr< BuffergetBuffer ()
 Get underlying buffer. More...
 
size_t prependBlock (const Block &block)
 Prepend TLV block block. More...
 
size_t prependByte (uint8_t value)
 Prepend a byte. More...
 
size_t prependByteArray (const uint8_t *array, size_t length)
 Prepend a byte array array of length length. More...
 
size_t prependByteArrayBlock (uint32_t type, const uint8_t *array, size_t arraySize)
 Prepend TLV block of type type and value from buffer array of size arraySize. More...
 
size_t prependNonNegativeInteger (uint64_t integer)
 Prepend non-negative integer integer of NDN TLV encoding. More...
 
template<class Iterator >
size_t prependRange (Iterator first, Iterator last)
 Prepend range of bytes from the range [first, last) More...
 
size_t prependVarNumber (uint64_t varNumber)
 Prepend VarNumber varNumber of NDN TLV encoding. More...
 
void reserve (size_t size, bool addInFront)
 Reserve size bytes for the underlying buffer. More...
 
void reserveBack (size_t size)
 Reserve at least size bytes at the back of the underlying buffer. More...
 
void reserveFront (size_t size)
 Reserve at least isze bytes at the beginning of the underlying buffer. More...
 
size_t size () const
 Get size of the encoded buffer. More...
 

Detailed Description

template<>
class ndn::encoding::EncodingImpl< EncoderTag >

EncodingImpl specialization for actual TLV encoding.

Definition at line 36 of file encoding-buffer.hpp.

Member Typedef Documentation

using ndn::encoding::Encoder::const_iterator = Buffer::const_iterator
inherited

Definition at line 144 of file encoder.hpp.

using ndn::encoding::Encoder::iterator = Buffer::iterator
inherited

Definition at line 143 of file encoder.hpp.

using ndn::encoding::Encoder::value_type = Buffer::value_type
inherited

Definition at line 142 of file encoder.hpp.

Constructor & Destructor Documentation

ndn::encoding::EncodingImpl< EncoderTag >::EncodingImpl ( size_t  totalReserve = MAX_NDN_PACKET_SIZE,
size_t  reserveFromBack = 400 
)
inlineexplicit

Definition at line 40 of file encoding-buffer.hpp.

ndn::encoding::EncodingImpl< EncoderTag >::EncodingImpl ( const Block block)
inlineexplicit

Definition at line 46 of file encoding-buffer.hpp.

Member Function Documentation

size_t ndn::encoding::Encoder::appendBlock ( const Block block)
inherited

Append TLV block block.

Definition at line 272 of file encoder.cpp.

size_t ndn::encoding::Encoder::appendByte ( uint8_t  value)
inherited

Append a byte.

Definition at line 114 of file encoder.cpp.

size_t ndn::encoding::Encoder::appendByteArray ( const uint8_t *  array,
size_t  length 
)
inherited

Append a byte array array of length length.

Definition at line 135 of file encoder.cpp.

size_t ndn::encoding::Encoder::appendByteArrayBlock ( uint32_t  type,
const uint8_t *  array,
size_t  arraySize 
)
inherited

Append TLV block of type type and value from buffer array of size arraySize.

Definition at line 251 of file encoder.cpp.

size_t ndn::encoding::Encoder::appendNonNegativeInteger ( uint64_t  integer)
inherited

Append non-negative integer integer of NDN TLV encoding.

See also
http://named-data.net/doc/ndn-tlv/

Definition at line 221 of file encoder.cpp.

template<class Iterator >
size_t ndn::encoding::Encoder::appendRange ( Iterator  first,
Iterator  last 
)
inlineinherited

Append range of bytes from the range [first, last)

Definition at line 332 of file encoder.hpp.

size_t ndn::encoding::Encoder::appendVarNumber ( uint64_t  varNumber)
inherited

Prepend VarNumber varNumber of NDN TLV encoding.

See also
http://named-data.net/doc/ndn-tlv/

Definition at line 173 of file encoder.cpp.

Buffer::iterator ndn::encoding::Encoder::begin ( )
inlineinherited

Get an iterator pointing to the first byte of the encoded buffer.

Definition at line 279 of file encoder.hpp.

Buffer::const_iterator ndn::encoding::Encoder::begin ( ) const
inlineinherited

Get an iterator pointing to the first byte of the encoded buffer.

Definition at line 291 of file encoder.hpp.

Block ndn::encoding::Encoder::block ( bool  verifyLength = true) const
inherited

Create Block from the underlying buffer.

Parameters
verifyLengthIf this parameter set to true, Block's constructor will be requested to verify consistency of the encoded length in the Block, otherwise ignored

Definition at line 60 of file encoder.cpp.

uint8_t * ndn::encoding::Encoder::buf ( )
inlineinherited

Get a pointer to the first byte of the encoded buffer.

Definition at line 303 of file encoder.hpp.

const uint8_t * ndn::encoding::Encoder::buf ( ) const
inlineinherited

Get a pointer to the first byte of the encoded buffer.

Definition at line 309 of file encoder.hpp.

size_t ndn::encoding::Encoder::capacity ( ) const
inlineinherited

Get size of the underlying buffer.

Definition at line 273 of file encoder.hpp.

Buffer::iterator ndn::encoding::Encoder::end ( )
inlineinherited

Get an iterator pointing to the past-the-end byte of the encoded buffer.

Definition at line 285 of file encoder.hpp.

Buffer::const_iterator ndn::encoding::Encoder::end ( ) const
inlineinherited

Definition at line 297 of file encoder.hpp.

shared_ptr< Buffer > ndn::encoding::Encoder::getBuffer ( )
inlineinherited

Get underlying buffer.

Definition at line 267 of file encoder.hpp.

size_t ndn::encoding::Encoder::prependBlock ( const Block block)
inherited

Prepend TLV block block.

Definition at line 261 of file encoder.cpp.

size_t ndn::encoding::Encoder::prependByte ( uint8_t  value)
inherited

Prepend a byte.

Definition at line 104 of file encoder.cpp.

size_t ndn::encoding::Encoder::prependByteArray ( const uint8_t *  array,
size_t  length 
)
inherited

Prepend a byte array array of length length.

Definition at line 125 of file encoder.cpp.

size_t ndn::encoding::Encoder::prependByteArrayBlock ( uint32_t  type,
const uint8_t *  array,
size_t  arraySize 
)
inherited

Prepend TLV block of type type and value from buffer array of size arraySize.

Definition at line 241 of file encoder.cpp.

size_t ndn::encoding::Encoder::prependNonNegativeInteger ( uint64_t  integer)
inherited

Prepend non-negative integer integer of NDN TLV encoding.

See also
http://named-data.net/doc/ndn-tlv/

Definition at line 201 of file encoder.cpp.

template<class Iterator >
size_t ndn::encoding::Encoder::prependRange ( Iterator  first,
Iterator  last 
)
inlineinherited

Prepend range of bytes from the range [first, last)

Definition at line 316 of file encoder.hpp.

size_t ndn::encoding::Encoder::prependVarNumber ( uint64_t  varNumber)
inherited

Prepend VarNumber varNumber of NDN TLV encoding.

See also
http://named-data.net/doc/ndn-tlv/

Definition at line 146 of file encoder.cpp.

void ndn::encoding::Encoder::reserve ( size_t  size,
bool  addInFront 
)
inherited

Reserve size bytes for the underlying buffer.

Parameters
sizeamount of bytes to reserve in the underlying buffer
addInFrontif true, then size bytes will be available in front (i.e., subsequent call to prepend* will not need to allocate memory). If false, then reservation will be done at the end of the buffer (i.d., for subsequent append* calls)
Note
Reserve size is exact, unlike reserveFront and reserveBack methods
See also
reserveFront, reserveBack

Definition at line 68 of file encoder.cpp.

void ndn::encoding::Encoder::reserveBack ( size_t  size)
inherited

Reserve at least size bytes at the back of the underlying buffer.

Note
the actual reserve size can be (and in most cases is) larger than specified reservation length

Definition at line 45 of file encoder.cpp.

void ndn::encoding::Encoder::reserveFront ( size_t  size)
inherited

Reserve at least isze bytes at the beginning of the underlying buffer.

Note
the actual reserve size can be (and in most cases is) larger than specified reservation length

Definition at line 52 of file encoder.cpp.

size_t ndn::encoding::Encoder::size ( ) const
inlineinherited

Get size of the encoded buffer.

Definition at line 261 of file encoder.hpp.