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

Namespaces

 detail
 

Classes

class  Encoder
 Helper class to perform TLV encoding Interface of this class (mostly) matches interface of Estimator class. 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 Interface of this class (mostly) matches interface of Encoder class. More...
 

Typedefs

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

Enumerations

enum  Tag { EncoderTag = true, EstimatorTag = false }
 

Functions

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< EstimatorTag > (EncodingImpl< EstimatorTag > &, uint32_t, uint64_t)
 
template size_t prependNonNegativeIntegerBlock< EncoderTag > (EncodingImpl< EncoderTag > &, uint32_t, uint64_t)
 
Block makeNonNegativeIntegerBlock (uint32_t type, uint64_t value)
 Create a TLV block containing a non-negative integer. More...
 
uint64_t readNonNegativeInteger (const Block &block)
 Read a non-negative integer from a TLV element. More...
 
template<Tag TAG>
size_t prependEmptyBlock (EncodingImpl< TAG > &encoder, uint32_t type)
 Prepend an empty TLV element. More...
 
template size_t prependEmptyBlock< EstimatorTag > (EncodingImpl< EstimatorTag > &, uint32_t)
 
template size_t prependEmptyBlock< EncoderTag > (EncodingImpl< EncoderTag > &, uint32_t)
 
Block makeEmptyBlock (uint32_t type)
 Create an empty TLV block. More...
 
template<Tag TAG>
size_t prependStringBlock (EncodingImpl< TAG > &encoder, uint32_t type, const std::string &value)
 Prepend a TLV element containing a string. More...
 
template size_t prependStringBlock< EstimatorTag > (EncodingImpl< EstimatorTag > &, uint32_t, const std::string &)
 
template size_t prependStringBlock< EncoderTag > (EncodingImpl< EncoderTag > &, uint32_t, const std::string &)
 
Block makeStringBlock (uint32_t type, const std::string &value)
 Create a TLV block containing a string. More...
 
std::string readString (const Block &block)
 Read TLV-VALUE of a TLV element as a string. More...
 
Block makeBinaryBlock (uint32_t type, const uint8_t *value, size_t length)
 Create a TLV block copying TLV-VALUE from raw buffer. More...
 
Block makeBinaryBlock (uint32_t type, const char *value, size_t length)
 Create a TLV block copying TLV-VALUE from raw buffer. More...
 
template<typename R >
std::enable_if< std::is_integral< R >::value, R >::type 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< std::is_enum< R >::value, R >::type readNonNegativeIntegerAs (const Block &block)
 Read a non-negative integer from a TLV element and cast to the specified type. More...
 
template<class Iterator >
Block makeBinaryBlock (uint32_t type, Iterator first, Iterator last)
 Create a TLV block copying TLV-VALUE from iterators. More...
 
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<class U >
Block makeNestedBlock (uint32_t type, const U &value)
 Create a TLV block containing a nested TLV element. More...
 

Typedef Documentation

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

Enumeration Type Documentation

Enumerator
EncoderTag 

Tag for EncodingImpl to indicate that Encoder is requested.

EstimatorTag 

Tag for EncodingImpl to indicate that Estimator is requested.

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

Function Documentation

template size_t ndn::encoding::prependNonNegativeIntegerBlock< EstimatorTag > ( EncodingImpl< EstimatorTag > &  ,
uint32_t  ,
uint64_t   
)
template size_t ndn::encoding::prependNonNegativeIntegerBlock< EncoderTag > ( EncodingImpl< EncoderTag > &  ,
uint32_t  ,
uint64_t   
)
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 48 of file block-helpers.cpp.

References ndn::encoding::Encoder::block(), and prependNonNegativeIntegerBlock().

Referenced by ndn::name::Component::fromNumber(), makeNestedBlock(), ns3::ndn::Producer::OnInterest(), and ndn::mgmt::ControlResponse::wireEncode().

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 70 of file block-helpers.cpp.

References prependEmptyBlock< EncoderTag >(), and prependEmptyBlock< EstimatorTag >().

Referenced by makeEmptyBlock(), readNonNegativeIntegerAs(), ndn::Selectors::wireEncode(), and ndn::Exclude::wireEncode().

template size_t ndn::encoding::prependEmptyBlock< EncoderTag > ( EncodingImpl< EncoderTag > &  ,
uint32_t   
)
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 85 of file block-helpers.cpp.

References ndn::encoding::Encoder::block(), and prependEmptyBlock().

Referenced by makeNestedBlock(), and readNonNegativeIntegerAs().

template<Tag TAG>
size_t ndn::encoding::prependStringBlock ( EncodingImpl< TAG > &  encoder,
uint32_t  type,
const std::string &  value 
)
template size_t ndn::encoding::prependStringBlock< EstimatorTag > ( EncodingImpl< EstimatorTag > &  ,
uint32_t  ,
const std::string &   
)
template size_t ndn::encoding::prependStringBlock< EncoderTag > ( EncodingImpl< EncoderTag > &  ,
uint32_t  ,
const std::string &   
)
Block ndn::encoding::makeStringBlock ( uint32_t  type,
const std::string &  value 
)

Create a TLV block containing a string.

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

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

References makeBinaryBlock().

Referenced by makeNestedBlock(), readNonNegativeIntegerAs(), and ndn::mgmt::ControlResponse::wireEncode().

Block ndn::encoding::makeBinaryBlock ( uint32_t  type,
const uint8_t *  value,
size_t  length 
)
Block ndn::encoding::makeBinaryBlock ( uint32_t  type,
const char *  value,
size_t  length 
)

Create a TLV block copying TLV-VALUE from raw buffer.

Parameters
typeTLV-TYPE number
valueraw buffer as TLV-VALUE
lengthlength of value buffer
See also
Encoder::prependByteArrayBlock

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

References makeBinaryBlock().

template<typename R >
std::enable_if<std::is_integral<R>::value, R>::type 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 72 of file block-helpers.hpp.

References readNonNegativeInteger(), ndn::to_string(), and ndn::Block::type().

Referenced by makeNestedBlock().

template<typename R >
std::enable_if<std::is_enum<R>::value, R>::type 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 92 of file block-helpers.hpp.

References makeBinaryBlock(), makeEmptyBlock(), makeStringBlock(), prependEmptyBlock(), prependEmptyBlock< EncoderTag >(), prependEmptyBlock< EstimatorTag >(), prependStringBlock(), prependStringBlock< EncoderTag >(), prependStringBlock< EstimatorTag >(), and readString().

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 dereferencable to an 1-octet type; faster implementation is available for RandomAccessIterator
Parameters
typeTLV-TYPE number
firstbegin iterator
lastpast-the-end iterator

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

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 252 of file block-helpers.hpp.

Referenced by makeNestedBlock(), ndn::nfd::StrategyChoice::wireEncode(), ndn::MetaInfo::wireEncode(), and ndn::nfd::ControlParameters::wireEncode().

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 272 of file block-helpers.hpp.

References ndn::encoding::Encoder::block(), makeBinaryBlock(), makeEmptyBlock(), makeNonNegativeIntegerBlock(), makeStringBlock(), prependNestedBlock(), readNonNegativeInteger(), readNonNegativeIntegerAs(), and readString().