24 #include <boost/endian/conversion.hpp>    29 namespace endian = boost::endian;
    37   size_t valueLength = encoder.prependNonNegativeInteger(value);
    38   size_t totalLength = valueLength;
    39   totalLength += encoder.prependVarNumber(valueLength);
    40   totalLength += encoder.prependVarNumber(type);
    60   return encoder.
block();
    76   size_t totalLength = encoder.prependVarNumber(0);
    77   totalLength += encoder.prependVarNumber(type);
    97   return encoder.
block();
   106   return encoder.prependByteArrayBlock(type, reinterpret_cast<const uint8_t*>(value.data()), value.size());
   124   return std::string(reinterpret_cast<const char*>(block.
value()), block.
value_size());
   129 static_assert(std::numeric_limits<double>::is_iec559, 
"This code requires IEEE-754 doubles");
   136   std::memcpy(&temp, &value, 8);
   137   endian::native_to_big_inplace(temp);
   138   return encoder.prependByteArrayBlock(type, reinterpret_cast<const uint8_t*>(&temp), 8);
   156   return encoder.
block();
   166 #if BOOST_VERSION >= 107100   167   return endian::endian_load<double, 8, endian::order::big>(block.
value());
   170   std::memcpy(&temp, block.
value(), 8);
   171   endian::big_to_native_inplace(temp);
   173   std::memcpy(&d, &temp, 8);
   189   return encoder.
block();
   195   return makeBinaryBlock(type, reinterpret_cast<const uint8_t*>(value), length);
 
EncodingImpl specialization for actual TLV encoding. 
size_t prependNonNegativeIntegerBlock(EncodingImpl< TAG > &encoder, uint32_t type, uint64_t value)
Prepend a TLV element containing a non-negative integer. 
Block makeEmptyBlock(uint32_t type)
Create an empty TLV block. 
size_t prependByteArrayBlock(uint32_t type, const uint8_t *array, size_t arraySize) const noexcept
Prepend TLV block of type type and value from buffer array of size arraySize. 
Block makeDoubleBlock(uint32_t type, double value)
Create a TLV element containing an IEEE 754 double-precision floating-point number. 
template size_t prependEmptyBlock< EstimatorTag >(EncodingImpl< EstimatorTag > &, uint32_t)
template size_t prependNonNegativeIntegerBlock< EstimatorTag >(EncodingImpl< EstimatorTag > &, uint32_t, uint64_t)
template size_t prependNonNegativeIntegerBlock< EncoderTag >(EncodingImpl< EncoderTag > &, uint32_t, uint64_t)
size_t value_size() const noexcept
Return the size of TLV-VALUE, aka TLV-LENGTH. 
Represents a TLV element of NDN packet format. 
uint64_t readNonNegativeInteger(size_t size, Iterator &begin, Iterator end)
Read nonNegativeInteger in NDN-TLV encoding. 
size_t prependStringBlock(EncodingImpl< TAG > &encoder, uint32_t type, const std::string &value)
Prepend a TLV element containing a string. 
std::string readString(const Block &block)
Read TLV-VALUE of a TLV element as a string. 
Block makeNonNegativeIntegerBlock(uint32_t type, uint64_t value)
Create a TLV block containing a non-negative integer. 
uint64_t readNonNegativeInteger(const Block &block)
Read a non-negative integer from a TLV element. 
EncodingImpl specialization for TLV size estimation. 
Buffer::const_iterator value_begin() const
Get begin iterator of TLV-VALUE. 
template size_t prependEmptyBlock< EncoderTag >(EncodingImpl< EncoderTag > &, uint32_t)
template size_t prependStringBlock< EncoderTag >(EncodingImpl< EncoderTag > &, uint32_t, const std::string &)
Block block(bool verifyLength=true) const
Create Block from the underlying buffer. 
size_t prependEmptyBlock(EncodingImpl< TAG > &encoder, uint32_t type)
Prepend an empty TLV element. 
Block makeBinaryBlock(uint32_t type, const uint8_t *value, size_t length)
Create a TLV block copying TLV-VALUE from raw buffer. 
Block makeStringBlock(uint32_t type, const std::string &value)
Create a TLV block containing a string. 
Buffer::const_iterator value_end() const
Get end iterator of TLV-VALUE. 
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. 
double readDouble(const Block &block)
Read TLV-VALUE of a TLV element as an IEEE 754 double-precision floating-point number. 
template size_t prependStringBlock< EstimatorTag >(EncodingImpl< EstimatorTag > &, uint32_t, const std::string &)
template size_t prependDoubleBlock< EncoderTag >(EncodingImpl< EncoderTag > &, uint32_t, double)
template size_t prependDoubleBlock< EstimatorTag >(EncodingImpl< EstimatorTag > &, uint32_t, double)
const uint8_t * value() const noexcept
Return a raw pointer to the beginning of TLV-VALUE. 
size_t prependDoubleBlock(EncodingImpl< TAG > &encoder, uint32_t type, double value)
Prepend a TLV element containing an IEEE 754 double-precision floating-point number. 
represents an error in TLV encoding or decoding