ndn::encoding Namespace Reference

Namespaces

 detail
 

Classes

class  Encoder
 Helper class to perform TLV encoding. More...
 
class  EncodingImpl
 
class  EncodingImpl< EncoderTag >
 EncodingImpl specialization for actual TLV encoding. More...
 
class  EncodingImpl< EstimatorTag >
 EncodingImpl specialization for TLV size estimation. More...
 
class  Estimator
 Helper class to estimate size of TLV encoding. More...
 

Typedefs

using EncodingBuffer = EncodingImpl< EncoderTag >
 
using EncodingEstimator = EncodingImpl< EstimatorTag >
 

Enumerations

enum  Tag {
  EncoderTag = true ,
  EstimatorTag = false
}
 

Functions

template<class Iterator >
Block makeBinaryBlock (uint32_t type, Iterator first, Iterator last)
 Create a TLV block copying TLV-VALUE from iterators. More...
 
Block makeBinaryBlock (uint32_t type, span< const uint8_t > value)
 Create a TLV block copying the TLV-VALUE from a byte range. More...
 
Block makeDoubleBlock (uint32_t type, double value)
 Create a TLV element containing an IEEE 754 double-precision floating-point number. More...
 
Block makeEmptyBlock (uint32_t type)
 Create an empty TLV block. More...
 
template<class U >
Block makeNestedBlock (uint32_t type, const U &value)
 Create a TLV block containing a nested TLV element. More...
 
template<class I >
Block makeNestedBlock (uint32_t type, I first, I last)
 Create a TLV block containing a sequence of nested TLV elements. More...
 
Block makeNonNegativeIntegerBlock (uint32_t type, uint64_t value)
 Create a TLV block containing a non-negative integer. More...
 
Block makeStringBlock (uint32_t type, std::string_view value)
 Create a TLV block containing a string. More...
 
template<Tag TAG>
size_t prependBinaryBlock (EncodingImpl< TAG > &encoder, uint32_t type, span< const uint8_t > value)
 Prepend a TLV element containing a sequence of raw bytes. More...
 
template size_t prependBinaryBlock< EncoderTag > (EncodingImpl< EncoderTag > &, uint32_t, span< const uint8_t >)
 
template size_t prependBinaryBlock< EstimatorTag > (EncodingImpl< EstimatorTag > &, uint32_t, span< const uint8_t >)
 
template<Tag TAG>
size_t prependBlock (EncodingImpl< TAG > &encoder, const Block &block)
 Prepend a TLV element. More...
 
template size_t prependBlock< EncoderTag > (EncodingImpl< EncoderTag > &, const Block &)
 
template size_t prependBlock< EstimatorTag > (EncodingImpl< EstimatorTag > &, const Block &)
 
template<Tag TAG>
size_t prependDoubleBlock (EncodingImpl< TAG > &encoder, uint32_t type, double value)
 Prepend a TLV element containing an IEEE 754 double-precision floating-point number. More...
 
template size_t prependDoubleBlock< EncoderTag > (EncodingImpl< EncoderTag > &, uint32_t, double)
 
template size_t prependDoubleBlock< EstimatorTag > (EncodingImpl< EstimatorTag > &, uint32_t, double)
 
template<Tag TAG>
size_t prependEmptyBlock (EncodingImpl< TAG > &encoder, uint32_t type)
 Prepend an empty TLV element. More...
 
template size_t prependEmptyBlock< EncoderTag > (EncodingImpl< EncoderTag > &, uint32_t)
 
template size_t prependEmptyBlock< EstimatorTag > (EncodingImpl< EstimatorTag > &, uint32_t)
 
template<Tag TAG, class U >
size_t prependNestedBlock (EncodingImpl< TAG > &encoder, uint32_t type, const U &value)
 Prepend a TLV element containing a nested TLV element. More...
 
template<Tag TAG, class I >
size_t prependNestedBlock (EncodingImpl< TAG > &encoder, uint32_t type, I first, I last)
 Prepend a TLV element containing a sequence of nested TLV elements. More...
 
template<Tag TAG>
size_t prependNonNegativeIntegerBlock (EncodingImpl< TAG > &encoder, uint32_t type, uint64_t value)
 Prepend a TLV element containing a non-negative integer. More...
 
template size_t prependNonNegativeIntegerBlock< EncoderTag > (EncodingImpl< EncoderTag > &, uint32_t, uint64_t)
 
template size_t prependNonNegativeIntegerBlock< EstimatorTag > (EncodingImpl< EstimatorTag > &, uint32_t, uint64_t)
 
template<Tag TAG>
size_t prependStringBlock (EncodingImpl< TAG > &encoder, uint32_t type, std::string_view value)
 Prepend a TLV element containing a string. More...
 
template size_t prependStringBlock< EncoderTag > (EncodingImpl< EncoderTag > &, uint32_t, std::string_view)
 
template size_t prependStringBlock< EstimatorTag > (EncodingImpl< EstimatorTag > &, uint32_t, std::string_view)
 
double readDouble (const Block &block)
 Read TLV-VALUE of a TLV element as an IEEE 754 double-precision floating-point number. More...
 
uint64_t readNonNegativeInteger (const Block &block)
 Read a non-negative integer from a TLV element. More...
 
template<typename R >
std::enable_if_t< std::is_integral_v< R >, R > readNonNegativeIntegerAs (const Block &block)
 Read a non-negative integer from a TLV element and cast to the specified type. More...
 
template<typename R >
std::enable_if_t< std::is_enum_v< R >, R > readNonNegativeIntegerAs (const Block &block)
 Read a non-negative integer from a TLV element and cast to the specified type. More...
 
std::string readString (const Block &block)
 Read the TLV-VALUE of a TLV element as a string. More...
 

Typedef Documentation

◆ EncodingBuffer

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

◆ EncodingEstimator

Enumeration Type Documentation

◆ Tag

Enumerator
EncoderTag 

Tag for EncodingImpl to indicate that Encoder is requested.

EstimatorTag 

Tag for EncodingImpl to indicate that Estimator is requested.

Definition at line 28 of file encoding-buffer-fwd.hpp.

Function Documentation

◆ makeBinaryBlock() [1/2]

template<class Iterator >
Block ndn::encoding::makeBinaryBlock ( uint32_t  type,
Iterator  first,
Iterator  last 
)

Create a TLV block copying TLV-VALUE from iterators.

Template Parameters
Iteratoran InputIterator dereferenceable to a 1-octet type; a faster implementation is automatically selected for RandomAccessIterator
Parameters
typeTLV-TYPE number
firstbegin iterator
lastpast-the-end iterator
See also
prependBinaryBlock

Definition at line 235 of file block-helpers.hpp.

◆ makeBinaryBlock() [2/2]

Block ndn::encoding::makeBinaryBlock ( uint32_t  type,
span< const uint8_t >  value 
)

Create a TLV block copying the TLV-VALUE from a byte range.

Parameters
typeTLV-TYPE number
valuerange of bytes to use as TLV-VALUE
See also
prependBinaryBlock

Definition at line 157 of file block-helpers.cpp.

◆ makeDoubleBlock()

Block ndn::encoding::makeDoubleBlock ( uint32_t  type,
double  value 
)

Create a TLV element containing an IEEE 754 double-precision floating-point number.

Parameters
typeTLV-TYPE number
valuefloating point number value
See also
prependDoubleBlock, readDouble

Definition at line 117 of file block-helpers.cpp.

◆ makeEmptyBlock()

Block ndn::encoding::makeEmptyBlock ( uint32_t  type)

Create an empty TLV block.

Parameters
typeTLV-TYPE number
Returns
A TLV block with zero-length TLV-VALUE
See also
prependEmptyBlock

Definition at line 47 of file block-helpers.cpp.

◆ makeNestedBlock() [1/2]

template<class U >
Block ndn::encoding::makeNestedBlock ( uint32_t  type,
const U &  value 
)

Create a TLV block containing a nested TLV element.

Template Parameters
Utype that satisfies WireEncodableWithEncodingBuffer concept
Parameters
typeTLV-TYPE number for outer TLV element
valuean object to be encoded as inner TLV element
See also
prependNestedBlock

Definition at line 324 of file block-helpers.hpp.

◆ makeNestedBlock() [2/2]

template<class I >
Block ndn::encoding::makeNestedBlock ( uint32_t  type,
first,
last 
)

Create a TLV block containing a sequence of nested TLV elements.

Template Parameters
Ibidirectional iterator to a type that satisfies WireEncodableWithEncodingBuffer concept
Parameters
typeTLV-TYPE number for outer TLV element
firstbegin iterator to inner TLV elements
lastpast-end iterator to inner TLV elements
See also
prependNestedBlock

Definition at line 370 of file block-helpers.hpp.

◆ makeNonNegativeIntegerBlock()

Block ndn::encoding::makeNonNegativeIntegerBlock ( uint32_t  type,
uint64_t  value 
)

Create a TLV block containing a non-negative integer.

Parameters
typeTLV-TYPE number
valuenon-negative integer value
See also
prependNonNegativeIntegerBlock, readNonNegativeInteger

Definition at line 78 of file block-helpers.cpp.

◆ makeStringBlock()

Block ndn::encoding::makeStringBlock ( uint32_t  type,
std::string_view  value 
)
inline

Create a TLV block containing a string.

Parameters
typeTLV-TYPE number
valuestring value, may contain NUL octets
See also
prependStringBlock, readString

Definition at line 268 of file block-helpers.hpp.

◆ prependBinaryBlock()

template<Tag TAG>
size_t ndn::encoding::prependBinaryBlock ( EncodingImpl< TAG > &  encoder,
uint32_t  type,
span< const uint8_t >  value 
)

Prepend a TLV element containing a sequence of raw bytes.

Parameters
encoderan EncodingBuffer or EncodingEstimator
typeTLV-TYPE number
valuerange of bytes to use as TLV-VALUE
See also
makeBinaryBlock

Definition at line 141 of file block-helpers.cpp.

◆ prependBinaryBlock< EncoderTag >()

template size_t ndn::encoding::prependBinaryBlock< EncoderTag > ( EncodingImpl< EncoderTag > &  ,
uint32_t  ,
span< const uint8_t >   
)

◆ prependBinaryBlock< EstimatorTag >()

template size_t ndn::encoding::prependBinaryBlock< EstimatorTag > ( EncodingImpl< EstimatorTag > &  ,
uint32_t  ,
span< const uint8_t >   
)

◆ prependBlock()

template<Tag TAG>
size_t ndn::encoding::prependBlock ( EncodingImpl< TAG > &  encoder,
const Block block 
)

Prepend a TLV element.

Parameters
encoderan EncodingBuffer or EncodingEstimator
blockthe TLV element

Definition at line 193 of file block-helpers.cpp.

◆ prependBlock< EncoderTag >()

template size_t ndn::encoding::prependBlock< EncoderTag > ( EncodingImpl< EncoderTag > &  ,
const Block  
)

◆ prependBlock< EstimatorTag >()

template size_t ndn::encoding::prependBlock< EstimatorTag > ( EncodingImpl< EstimatorTag > &  ,
const Block  
)

◆ prependDoubleBlock()

template<Tag TAG>
size_t ndn::encoding::prependDoubleBlock ( EncodingImpl< TAG > &  encoder,
uint32_t  type,
double  value 
)

Prepend a TLV element containing an IEEE 754 double-precision floating-point number.

Parameters
encoderan EncodingBuffer or EncodingEstimator
typeTLV-TYPE number
valuea floating point number value
See also
makeDoubleBlock, readDouble

Definition at line 102 of file block-helpers.cpp.

◆ prependDoubleBlock< EncoderTag >()

template size_t ndn::encoding::prependDoubleBlock< EncoderTag > ( EncodingImpl< EncoderTag > &  ,
uint32_t  ,
double   
)

◆ prependDoubleBlock< EstimatorTag >()

template size_t ndn::encoding::prependDoubleBlock< EstimatorTag > ( EncodingImpl< EstimatorTag > &  ,
uint32_t  ,
double   
)

◆ prependEmptyBlock()

template<Tag TAG>
size_t ndn::encoding::prependEmptyBlock ( EncodingImpl< TAG > &  encoder,
uint32_t  type 
)

Prepend an empty TLV element.

Parameters
encoderan EncodingBuffer or EncodingEstimator
typeTLV-TYPE number

The TLV element has zero-length TLV-VALUE.

See also
makeEmptyBlock

Definition at line 32 of file block-helpers.cpp.

◆ prependEmptyBlock< EncoderTag >()

template size_t ndn::encoding::prependEmptyBlock< EncoderTag > ( EncodingImpl< EncoderTag > &  ,
uint32_t   
)

◆ prependEmptyBlock< EstimatorTag >()

template size_t ndn::encoding::prependEmptyBlock< EstimatorTag > ( EncodingImpl< EstimatorTag > &  ,
uint32_t   
)

◆ prependNestedBlock() [1/2]

template<Tag TAG, class U >
size_t ndn::encoding::prependNestedBlock ( EncodingImpl< TAG > &  encoder,
uint32_t  type,
const U &  value 
)

Prepend a TLV element containing a nested TLV element.

Template Parameters
Utype that satisfies WireEncodableWithEncodingBuffer concept
Parameters
encoderan EncodingBuffer or EncodingEstimator
typeTLV-TYPE number for outer TLV element
valuean object to be encoded as inner TLV element
See also
makeNestedBlock

Definition at line 306 of file block-helpers.hpp.

◆ prependNestedBlock() [2/2]

template<Tag TAG, class I >
size_t ndn::encoding::prependNestedBlock ( EncodingImpl< TAG > &  encoder,
uint32_t  type,
first,
last 
)

Prepend a TLV element containing a sequence of nested TLV elements.

Template Parameters
Ibidirectional iterator to a type that satisfies WireEncodableWithEncodingBuffer concept
Parameters
encoderan EncodingBuffer or EncodingEstimator
typeTLV-TYPE number for outer TLV element
firstbegin iterator to inner TLV elements
lastpast-end iterator to inner TLV elements
See also
makeNestedBlock

Definition at line 344 of file block-helpers.hpp.

◆ prependNonNegativeIntegerBlock()

template<Tag TAG>
size_t ndn::encoding::prependNonNegativeIntegerBlock ( EncodingImpl< TAG > &  encoder,
uint32_t  type,
uint64_t  value 
)

Prepend a TLV element containing a non-negative integer.

Parameters
encoderan EncodingBuffer or EncodingEstimator
typeTLV-TYPE number
valuenon-negative integer value
See also
makeNonNegativeIntegerBlock, readNonNegativeInteger

Definition at line 62 of file block-helpers.cpp.

◆ prependNonNegativeIntegerBlock< EncoderTag >()

template size_t ndn::encoding::prependNonNegativeIntegerBlock< EncoderTag > ( EncodingImpl< EncoderTag > &  ,
uint32_t  ,
uint64_t   
)

◆ prependNonNegativeIntegerBlock< EstimatorTag >()

template size_t ndn::encoding::prependNonNegativeIntegerBlock< EstimatorTag > ( EncodingImpl< EstimatorTag > &  ,
uint32_t  ,
uint64_t   
)

◆ prependStringBlock()

template<Tag TAG>
size_t ndn::encoding::prependStringBlock ( EncodingImpl< TAG > &  encoder,
uint32_t  type,
std::string_view  value 
)

Prepend a TLV element containing a string.

Parameters
encoderan EncodingBuffer or EncodingEstimator
typeTLV-TYPE number
valuestring value, may contain NUL octets
See also
makeStringBlock, readString

Definition at line 172 of file block-helpers.cpp.

◆ prependStringBlock< EncoderTag >()

template size_t ndn::encoding::prependStringBlock< EncoderTag > ( EncodingImpl< EncoderTag > &  ,
uint32_t  ,
std::string_view   
)

◆ prependStringBlock< EstimatorTag >()

template size_t ndn::encoding::prependStringBlock< EstimatorTag > ( EncodingImpl< EstimatorTag > &  ,
uint32_t  ,
std::string_view   
)

◆ readDouble()

double ndn::encoding::readDouble ( const Block block)

Read TLV-VALUE of a TLV element as an IEEE 754 double-precision floating-point number.

Parameters
blockthe TLV element
Returns
a floating point number value
See also
prependDoubleBlock, makeDoubleBlock

Definition at line 129 of file block-helpers.cpp.

◆ readNonNegativeInteger()

uint64_t ndn::encoding::readNonNegativeInteger ( const Block block)

Read a non-negative integer from a TLV element.

Parameters
blockthe TLV element
Exceptions
tlv::Errorblock does not contain a non-negative integer
See also
prependNonNegativeIntegerBlock, makeNonNegativeIntegerBlock

Definition at line 90 of file block-helpers.cpp.

◆ readNonNegativeIntegerAs() [1/2]

template<typename R >
std::enable_if_t<std::is_integral_v<R>, R> ndn::encoding::readNonNegativeIntegerAs ( const Block block)

Read a non-negative integer from a TLV element and cast to the specified type.

Template Parameters
Rresult type, must be an integral type
Parameters
blockthe TLV element
Exceptions
tlv::Errorblock does not contain a valid non-negative integer or the number cannot be represented in R

Definition at line 96 of file block-helpers.hpp.

◆ readNonNegativeIntegerAs() [2/2]

template<typename R >
std::enable_if_t<std::is_enum_v<R>, R> ndn::encoding::readNonNegativeIntegerAs ( const Block block)

Read a non-negative integer from a TLV element and cast to the specified type.

Template Parameters
Rresult type, must be an enumeration type
Parameters
blockthe TLV element
Exceptions
tlv::Errorblock does not contain a valid non-negative integer or the number cannot be represented in R
Warning
If R is an unscoped enum type, it must have a fixed underlying type. Otherwise, this function may trigger unspecified behavior.

Definition at line 115 of file block-helpers.hpp.

◆ readString()

std::string ndn::encoding::readString ( const Block block)

Read the TLV-VALUE of a TLV element as a string.

Parameters
blockthe TLV element
Returns
a string, may contain NUL octets
See also
prependStringBlock, makeStringBlock

Definition at line 184 of file block-helpers.cpp.