22 #ifndef NDN_CXX_LP_FIELD_DECL_HPP 23 #define NDN_CXX_LP_FIELD_DECL_HPP 30 #include "../encoding/block-helpers.hpp" 31 #include "../util/concepts.hpp" 32 #include <boost/concept/requires.hpp> 39 struct NonNegativeIntegerTag;
41 template<
typename TlvType,
typename T>
49 type.wireDecode(wire);
54 template<
typename TlvType>
69 template<
typename TlvType>
79 template<
typename TlvType>
93 template<
typename TlvType>
94 struct DecodeHelper<TlvType,
std::pair<Buffer::const_iterator, Buffer::const_iterator>>
96 static std::pair<Buffer::const_iterator, Buffer::const_iterator>
101 " cannot be empty"));
108 template<
typename encoding::Tag TAG,
typename TlvType,
typename T>
115 return value.wireEncode(encoder);
119 template<
typename encoding::Tag TAG,
typename TlvType>
126 length += encoder.prependVarNumber(0);
127 length += encoder.prependVarNumber(TlvType::value);
132 template<
typename encoding::Tag TAG,
typename TlvType>
142 template<
typename encoding::Tag TAG,
typename TlvType>
148 uint64_t be = htobe64(value);
149 const uint8_t* buf =
reinterpret_cast<const uint8_t*
>(&be);
150 return encoder.prependByteArrayBlock(TlvType::value, buf,
sizeof(be));
154 template<
typename encoding::Tag TAG,
typename TlvType>
155 struct EncodeHelper<TAG, TlvType,
std::pair<Buffer::const_iterator, Buffer::const_iterator>>
161 length += encoder.prependRange(value.first, value.second);
162 length += encoder.prependVarNumber(length);
163 length += encoder.prependVarNumber(TlvType::value);
176 template<
typename LOCATION,
typename VALUE, uint64_t TYPE,
bool REPEATABLE =
false,
177 typename DECODER_TAG = VALUE,
typename ENCODER_TAG = VALUE>
183 typedef std::integral_constant<uint64_t, TYPE>
TlvType;
194 if (wire.
type() != TlvType::value) {
205 template<
typename encoding::Tag TAG>
216 #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::integral_constant< bool, REPEATABLE > IsRepeatable
size_t value_size() const
Get size of TLV-VALUE aka TLV-LENGTH.
static size_t encode(EncodingImpl< TAG > &encoder, uint64_t value)
Represents a TLV element of NDN packet format.
static size_t encode(EncodingImpl< TAG > &encoder, const EmptyValue value)
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)
Buffer::const_iterator value_begin() const
Get begin iterator of TLV-VALUE.
a concept check for TLV abstraction with .wireEncode method
static size_t encode(EncodingImpl< TAG > &encoder, uint64_t value)
Buffer::const_iterator value_end() const
Get end iterator of TLV-VALUE.
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)
static uint64_t decode(const Block &wire)
std::string to_string(const V &v)
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
uint32_t type() const
Get TLV-TYPE.
represents an error in TLV encoding or decoding
static EmptyValue decode(const Block &wire)