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

EncodingImpl specialization for actual TLV encoding. More...

#include <ndn-cxx/encoding/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 (const Block &block)
 
 EncodingImpl (size_t totalReserve=MAX_NDN_PACKET_SIZE, size_t reserveFromBack=400)
 
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 appendBytes (span< const uint8_t > bytes)
 Append a sequence of bytes. More...
 
size_t appendNonNegativeInteger (uint64_t integer)
 Append integer encoded as a NonNegativeInteger in NDN-TLV format. 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 number)
 Append number encoded as a VAR-NUMBER in NDN-TLV format. More...
 
const_iterator begin () const noexcept
 Returns an iterator pointing to the first byte of the encoded buffer. More...
 
iterator begin () noexcept
 Returns 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...
 
const uint8_t * buf () const noexcept
 
uint8_t * buf () noexcept
 
size_t capacity () const noexcept
 Get size of the underlying buffer. More...
 
const uint8_t * data () const noexcept
 Returns a pointer to the first byte of the encoded buffer. More...
 
uint8_t * data () noexcept
 Returns a pointer to the first byte of the encoded buffer. More...
 
const_iterator end () const noexcept
 Returns an iterator pointing to the past-the-end byte of the encoded buffer. More...
 
iterator end () noexcept
 Returns an iterator pointing to the past-the-end byte of the encoded buffer. More...
 
shared_ptr< BuffergetBuffer () const noexcept
 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 prependBytes (span< const uint8_t > bytes)
 Prepend a sequence of bytes. More...
 
size_t prependNonNegativeInteger (uint64_t integer)
 Prepend integer encoded as a NonNegativeInteger in NDN-TLV format. 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 number)
 Prepend number encoded as a VAR-NUMBER in NDN-TLV format. 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 noexcept
 Returns the size of the encoded buffer. More...
 

Detailed Description

EncodingImpl specialization for actual TLV encoding.

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

Member Typedef Documentation

◆ const_iterator

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

Definition at line 173 of file encoder.hpp.

◆ iterator

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

Definition at line 172 of file encoder.hpp.

◆ value_type

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

Definition at line 171 of file encoder.hpp.

Constructor & Destructor Documentation

◆ EncodingImpl() [1/2]

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.

◆ EncodingImpl() [2/2]

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

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

Member Function Documentation

◆ appendBlock()

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

Append TLV block block.

Deprecated:

Definition at line 237 of file encoder.cpp.

◆ appendByte()

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

Append a byte.

Deprecated:

Definition at line 69 of file encoder.hpp.

◆ appendByteArray()

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

Append a byte array array of length length.

Deprecated:

Definition at line 91 of file encoder.hpp.

◆ appendByteArrayBlock()

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.

Deprecated:

Definition at line 214 of file encoder.cpp.

◆ appendBytes()

size_t ndn::encoding::Encoder::appendBytes ( span< const uint8_t >  bytes)
inherited

Append a sequence of bytes.

Definition at line 104 of file encoder.cpp.

◆ appendNonNegativeInteger()

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

Append integer encoded as a NonNegativeInteger in NDN-TLV format.

See also
https://named-data.net/doc/NDN-packet-spec/current/tlv.html

Definition at line 184 of file encoder.cpp.

◆ appendRange()

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

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

Definition at line 362 of file encoder.hpp.

◆ appendVarNumber()

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

Append number encoded as a VAR-NUMBER in NDN-TLV format.

See also
https://named-data.net/doc/NDN-packet-spec/current/tlv.html

Definition at line 137 of file encoder.cpp.

◆ begin() [1/2]

const_iterator ndn::encoding::Encoder::begin ( ) const
inlinenoexceptinherited

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

Definition at line 256 of file encoder.hpp.

◆ begin() [2/2]

iterator ndn::encoding::Encoder::begin ( )
inlinenoexceptinherited

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

Definition at line 247 of file encoder.hpp.

◆ block()

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 59 of file encoder.cpp.

◆ buf() [1/2]

const uint8_t* ndn::encoding::Encoder::buf ( ) const
inlinenoexceptinherited
Deprecated:

Definition at line 312 of file encoder.hpp.

◆ buf() [2/2]

uint8_t* ndn::encoding::Encoder::buf ( )
inlinenoexceptinherited
Deprecated:

Definition at line 302 of file encoder.hpp.

◆ capacity()

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

Get size of the underlying buffer.

Definition at line 228 of file encoder.hpp.

◆ data() [1/2]

const uint8_t* ndn::encoding::Encoder::data ( ) const
inlinenoexceptinherited

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

Definition at line 292 of file encoder.hpp.

◆ data() [2/2]

uint8_t* ndn::encoding::Encoder::data ( )
inlinenoexceptinherited

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

Definition at line 283 of file encoder.hpp.

◆ end() [1/2]

const_iterator ndn::encoding::Encoder::end ( ) const
inlinenoexceptinherited

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

Definition at line 274 of file encoder.hpp.

◆ end() [2/2]

iterator ndn::encoding::Encoder::end ( )
inlinenoexceptinherited

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

Definition at line 265 of file encoder.hpp.

◆ getBuffer()

shared_ptr<Buffer> ndn::encoding::Encoder::getBuffer ( ) const
inlinenoexceptinherited

Get underlying buffer.

Definition at line 237 of file encoder.hpp.

◆ prependBlock()

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

Prepend TLV block block.

Deprecated:

Definition at line 226 of file encoder.cpp.

◆ prependByte()

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

Prepend a byte.

Deprecated:

Definition at line 58 of file encoder.hpp.

◆ prependByteArray()

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

Prepend a byte array array of length length.

Deprecated:

Definition at line 80 of file encoder.hpp.

◆ prependByteArrayBlock()

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.

Deprecated:

Definition at line 204 of file encoder.cpp.

◆ prependBytes()

size_t ndn::encoding::Encoder::prependBytes ( span< const uint8_t >  bytes)
inherited

Prepend a sequence of bytes.

Definition at line 98 of file encoder.cpp.

◆ prependNonNegativeInteger()

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

Prepend integer encoded as a NonNegativeInteger in NDN-TLV format.

See also
https://named-data.net/doc/NDN-packet-spec/current/tlv.html

Definition at line 164 of file encoder.cpp.

◆ prependRange()

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

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

Definition at line 347 of file encoder.hpp.

◆ prependVarNumber()

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

Prepend number encoded as a VAR-NUMBER in NDN-TLV format.

See also
https://named-data.net/doc/NDN-packet-spec/current/tlv.html

Definition at line 110 of file encoder.cpp.

◆ reserve()

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 65 of file encoder.cpp.

◆ reserveBack()

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.

◆ reserveFront()

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()

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

Returns the size of the encoded buffer.

Definition at line 321 of file encoder.hpp.