22 #ifndef NDN_CXX_LP_FIELD_DECL_HPP 23 #define NDN_CXX_LP_FIELD_DECL_HPP 32 #include <boost/concept/requires.hpp> 33 #include <boost/endian/conversion.hpp> 40 struct NonNegativeIntegerTag;
42 template<
typename TlvType,
typename T>
50 type.wireDecode(wire);
55 template<
typename TlvType>
69 template<
typename TlvType>
79 template<
typename TlvType>
87 " must contain a 64-bit integer"));
90 std::memcpy(&n, wire.
value(),
sizeof(n));
91 return boost::endian::big_to_native(n);
95 template<
typename TlvType>
96 struct DecodeHelper<TlvType,
std::pair<Buffer::const_iterator, Buffer::const_iterator>>
98 static std::pair<Buffer::const_iterator, Buffer::const_iterator>
103 " cannot be empty"));
109 template<
typename encoding::Tag TAG,
typename TlvType,
typename T>
116 return value.wireEncode(encoder);
120 template<
typename encoding::Tag TAG,
typename TlvType>
130 template<
typename encoding::Tag TAG,
typename TlvType>
140 template<
typename encoding::Tag TAG,
typename TlvType>
146 boost::endian::native_to_big_inplace(value);
148 {
reinterpret_cast<const uint8_t*
>(&
value),
sizeof(value)});
152 template<
typename encoding::Tag TAG,
typename TlvType>
153 struct EncodeHelper<TAG, TlvType,
std::pair<Buffer::const_iterator, Buffer::const_iterator>>
159 length += encoder.prependRange(value.first, value.second);
160 length += encoder.prependVarNumber(length);
174 template<
typename LOCATION,
typename VALUE, uint64_t TYPE,
bool REPEATABLE =
false,
175 typename DECODER_TAG = VALUE,
typename ENCODER_TAG = VALUE>
181 typedef std::integral_constant<uint64_t, TYPE>
TlvType;
203 template<
typename encoding::Tag TAG>
214 #endif // NDN_CXX_LP_FIELD_DECL_HPP static ValueType decode(const Block &wire)
Decode a field.
Copyright (c) 2011-2015 Regents of the University of California.
static T decode(const Block &wire)
size_t prependNonNegativeIntegerBlock(EncodingImpl< TAG > &encoder, uint32_t type, uint64_t value)
Prepend a TLV element containing a non-negative integer.
std::string to_string(const T &val)
std::integral_constant< bool, REPEATABLE > IsRepeatable
static size_t encode(EncodingImpl< TAG > &encoder, uint64_t value)
static size_t encode(EncodingImpl< TAG > &encoder, EmptyValue)
const_iterator value_begin() const noexcept
Get begin iterator of TLV-VALUE.
size_t value_size() const noexcept
Return the size of TLV-VALUE, i.e., the TLV-LENGTH.
Represents a TLV element of the NDN packet format.
uint64_t readNonNegativeInteger(const Block &block)
Read a non-negative integer from a TLV element.
static size_t encode(EncodingImpl< TAG > &encoder, const T &value)
a concept check for TLV abstraction with .wireEncode method
static size_t encode(EncodingImpl< TAG > &encoder, uint64_t value)
size_t prependEmptyBlock(EncodingImpl< TAG > &encoder, uint32_t type)
Prepend an empty TLV element.
size_t prependBinaryBlock(EncodingImpl< TAG > &encoder, uint32_t type, span< const uint8_t > value)
Prepend a TLV element containing a sequence of raw bytes.
represents a zero-length TLV-VALUE
static size_t encode(EncodingImpl< TAG > &encoder, const ValueType &value)
Encode a field and prepend to encoder.
static size_t encode(EncodingImpl< TAG > &encoder, const std::pair< Buffer::const_iterator, Buffer::const_iterator > &value)
static std::pair< Buffer::const_iterator, Buffer::const_iterator > decode(const Block &wire)
const uint8_t * value() const noexcept
Return a raw pointer to the beginning of TLV-VALUE.
uint32_t type() const noexcept
Return the TLV-TYPE of the Block.
static uint64_t decode(const Block &wire)
const_iterator value_end() const noexcept
Get end iterator of TLV-VALUE.
a concept check for TLV abstraction with .wireDecode method and constructible from Block ...
static uint64_t decode(const Block &wire)
std::integral_constant< uint64_t, TYPE > TlvType
represents an error in TLV encoding or decoding
static EmptyValue decode(const Block &wire)