22 #ifndef NDN_CXX_LP_DETAIL_FIELD_DECL_HPP
23 #define NDN_CXX_LP_DETAIL_FIELD_DECL_HPP
25 #include "../field.hpp"
28 #include "../../encoding/block-helpers.hpp"
29 #include "../../util/concepts.hpp"
30 #include <boost/concept/requires.hpp>
36 template<
typename TlvType,
typename T>
41 decode(const
Block& wire)
44 type.wireDecode(wire);
49 template<
typename TlvType>
59 template<
typename TlvType>
60 struct DecodeHelper<TlvType,
std::pair<Buffer::const_iterator, Buffer::const_iterator>>
62 static std::pair<Buffer::const_iterator, Buffer::const_iterator>
73 template<
typename encoding::Tag TAG,
typename TlvType,
typename T>
78 encode(EncodingImpl<TAG>& encoder,
const T&
value)
80 return value.wireEncode(encoder);
84 template<
typename encoding::Tag TAG,
typename TlvType>
94 template<
typename encoding::Tag TAG,
typename TlvType>
95 struct EncodeHelper<TAG, TlvType,
std::pair<Buffer::const_iterator, Buffer::const_iterator>>
98 encode(EncodingImpl<TAG>& encoder,
const std::pair<Buffer::const_iterator, Buffer::const_iterator>&
value)
101 length += encoder.prependRange(value.first, value.second);
102 length += encoder.prependVarNumber(length);
103 length += encoder.prependVarNumber(TlvType::value);
108 template<
typename LOCATION,
typename VALUE, u
int64_t TYPE,
bool REPEATABLE = false>
114 typedef std::integral_constant<uint64_t, TYPE>
TlvType;
124 if (wire.
type() != TlvType::value) {
135 template<
typename encoding::Tag TAG,
typename T>
137 encode(EncodingImpl<TAG>& encoder,
const T& value)
147 #endif // NDN_CXX_LP_DETAIL_FIELD_DECL_HPP
Copyright (c) 2013-2016 Regents of the University of California.
size_t prependNonNegativeIntegerBlock(EncodingImpl< TAG > &encoder, uint32_t type, uint64_t value)
Helper to prepend TLV block type type containing non-negative integer value.
static std::pair< Buffer::const_iterator, Buffer::const_iterator > decode(const Block &wire)
Class representing a wire element of NDN-TLV packet format.
std::integral_constant< uint64_t, TYPE > TlvType
Buffer::const_iterator value_begin() const
Buffer::const_iterator value_end() const
uint64_t readNonNegativeInteger(const Block &block)
Helper to read a non-negative integer from a block.
static BOOST_CONCEPT_REQUIRES(((WireDecodable< T >)),(T)) decode(const Block &wire)
static size_t encode(EncodingImpl< TAG > &encoder, const T &value)
encodes a field and prepends to encoder its Block with top-level type TYPE
static uint64_t decode(const Block &wire)
size_t value_size() const
static size_t encode(EncodingImpl< TAG > &encoder, const uint64_t value)
static BOOST_CONCEPT_REQUIRES(((WireEncodable< T >)),(size_t)) encode(EncodingImpl< TAG > &encoder
static size_t encode(EncodingImpl< TAG > &encoder, const std::pair< Buffer::const_iterator, Buffer::const_iterator > &value)
std::integral_constant< bool, REPEATABLE > IsRepeatable
std::string to_string(const V &v)
a concept check for TLV abstraction with .wireEncode method
a concept check for TLV abstraction with .wireDecode method and constructible from Block ...
static ValueType decode(const Block &wire)
decodes a field
represents an error in TLV encoding or decoding