24 #include <boost/endian/conversion.hpp> 
   29 namespace endian = boost::endian;
 
   37   size_t length = encoder.prependNonNegativeInteger(value);
 
   38   length += encoder.prependVarNumber(length);
 
   39   length += encoder.prependVarNumber(type);
 
   59   return encoder.
block();
 
   75   size_t length = encoder.prependVarNumber(0);
 
   76   length += encoder.prependVarNumber(type);
 
   96   return encoder.
block();
 
  105   return prependBinaryBlock(encoder, type, {
reinterpret_cast<const uint8_t*
>(value.data()), value.size()});
 
  123   return std::string(
reinterpret_cast<const char*
>(block.
value()), block.
value_size());
 
  128 static_assert(std::numeric_limits<double>::is_iec559, 
"This code requires IEEE-754 doubles");
 
  135   std::memcpy(&temp, &value, 8);
 
  136   endian::native_to_big_inplace(temp);
 
  137   return prependBinaryBlock(encoder, type, {
reinterpret_cast<const uint8_t*
>(&temp), 8});
 
  155   return encoder.
block();
 
  165 #if BOOST_VERSION >= 107100 
  166   return endian::endian_load<double, 8, endian::order::big>(block.
value());
 
  169   std::memcpy(&temp, block.
value(), 8);
 
  170   endian::big_to_native_inplace(temp);
 
  172   std::memcpy(&d, &temp, 8);
 
  183   size_t length = encoder.prependBytes(value);
 
  184   length += encoder.prependVarNumber(length);
 
  185   length += encoder.prependVarNumber(type);
 
  205   return encoder.
block();
 
  215     return encoder.prependBytes({block.
wire(), block.
size()});
 
Represents a TLV element of the NDN packet format.
 
const uint8_t * wire() const
Return a raw pointer to the beginning of the encoded wire.
 
uint32_t type() const
Return the TLV-TYPE of the Block.
 
size_t size() const
Return the size of the encoded wire, i.e.
 
bool hasWire() const noexcept
Check if the Block contains a fully encoded wire representation.
 
Buffer::const_iterator value_end() const
Get end iterator of TLV-VALUE.
 
Buffer::const_iterator value_begin() const
Get begin iterator of TLV-VALUE.
 
size_t value_size() const noexcept
Return the size of TLV-VALUE, aka TLV-LENGTH.
 
const uint8_t * value() const noexcept
Return a raw pointer to the beginning of TLV-VALUE.
 
Block block(bool verifyLength=true) const
Create Block from the underlying buffer.
 
EncodingImpl specialization for actual TLV encoding.
 
EncodingImpl specialization for TLV size estimation.
 
represents an error in TLV encoding or decoding
 
template size_t prependEmptyBlock< EstimatorTag >(EncodingImpl< EstimatorTag > &, uint32_t)
 
template size_t prependDoubleBlock< EstimatorTag >(EncodingImpl< EstimatorTag > &, uint32_t, double)
 
template size_t prependBinaryBlock< EncoderTag >(EncodingImpl< EncoderTag > &, uint32_t, span< const uint8_t >)
 
uint64_t readNonNegativeInteger(const Block &block)
Read a non-negative integer from a TLV element.
 
template size_t prependStringBlock< EncoderTag >(EncodingImpl< EncoderTag > &, uint32_t, const std::string &)
 
size_t prependNonNegativeIntegerBlock(EncodingImpl< TAG > &encoder, uint32_t type, uint64_t value)
Prepend a TLV element containing a non-negative integer.
 
size_t prependStringBlock(EncodingImpl< TAG > &encoder, uint32_t type, const std::string &value)
Prepend a TLV element containing a string.
 
template size_t prependBlock< EncoderTag >(EncodingImpl< EncoderTag > &, const Block &)
 
template size_t prependBinaryBlock< EstimatorTag >(EncodingImpl< EstimatorTag > &, uint32_t, span< const uint8_t >)
 
template size_t prependDoubleBlock< EncoderTag >(EncodingImpl< EncoderTag > &, uint32_t, double)
 
Block makeNonNegativeIntegerBlock(uint32_t type, uint64_t value)
Create a TLV block containing a non-negative integer.
 
Block makeEmptyBlock(uint32_t type)
Create an empty TLV block.
 
template size_t prependBlock< EstimatorTag >(EncodingImpl< EstimatorTag > &, const Block &)
 
template size_t prependNonNegativeIntegerBlock< EstimatorTag >(EncodingImpl< EstimatorTag > &, uint32_t, uint64_t)
 
size_t prependEmptyBlock(EncodingImpl< TAG > &encoder, uint32_t type)
Prepend an empty TLV element.
 
template size_t prependNonNegativeIntegerBlock< EncoderTag >(EncodingImpl< EncoderTag > &, uint32_t, uint64_t)
 
double readDouble(const Block &block)
Read TLV-VALUE of a TLV element as an IEEE 754 double-precision floating-point number.
 
template size_t prependEmptyBlock< EncoderTag >(EncodingImpl< EncoderTag > &, uint32_t)
 
template size_t prependStringBlock< EstimatorTag >(EncodingImpl< EstimatorTag > &, uint32_t, const std::string &)
 
Block makeBinaryBlock(uint32_t type, span< const uint8_t > value)
Create a TLV block copying the TLV-VALUE from a byte range.
 
size_t prependBinaryBlock(EncodingImpl< TAG > &encoder, uint32_t type, span< const uint8_t > value)
Prepend a TLV element containing a sequence of raw bytes.
 
std::string readString(const Block &block)
Read TLV-VALUE of a TLV element as a string.
 
size_t prependBlock(EncodingImpl< TAG > &encoder, const Block &block)
Prepend a TLV element.
 
Block makeStringBlock(uint32_t type, const std::string &value)
Create a TLV block containing a string.
 
Block makeDoubleBlock(uint32_t type, double value)
Create a TLV element containing an IEEE 754 double-precision floating-point number.
 
size_t prependDoubleBlock(EncodingImpl< TAG > &encoder, uint32_t type, double value)
Prepend a TLV element containing an IEEE 754 double-precision floating-point number.
 
uint64_t readNonNegativeInteger(size_t size, Iterator &begin, Iterator end)
Read a NonNegativeInteger in NDN-TLV encoding.