22 #ifndef NDN_CXX_LP_DETAIL_FIELD_DECL_HPP 23 #define NDN_CXX_LP_DETAIL_FIELD_DECL_HPP 25 #include "../../common.hpp" 27 #include "../field.hpp" 28 #include "../sequence.hpp" 29 #include "../cache-policy.hpp" 30 #include "../nack.hpp" 33 #include <boost/concept/requires.hpp> 39 template<
typename TlvType,
typename T>
46 if (wire.type() != TlvType::value) {
47 BOOST_THROW_EXCEPTION(
ndn::tlv::Error(
"Unexpected TLV type " + std::to_string(wire.type())));
51 type.wireDecode(wire);
56 template<
typename TlvType>
62 if (wire.
type() != TlvType::value) {
63 BOOST_THROW_EXCEPTION(
ndn::tlv::Error(
"Unexpected TLV type " + std::to_string(wire.
type())));
70 template<
typename TlvType>
71 struct DecodeHelper<TlvType,
std::pair<Buffer::const_iterator, Buffer::const_iterator>>
73 static std::pair<Buffer::const_iterator, Buffer::const_iterator>
76 if (wire.
type() != TlvType::value) {
77 BOOST_THROW_EXCEPTION(
ndn::tlv::Error(
"Unexpected TLV type " + std::to_string(wire.
type())));
88 template<
typename encoding::Tag TAG,
typename TlvType,
typename T>
93 encode(EncodingImpl<TAG>& encoder, const T& value)
95 return value.wireEncode(encoder);
99 template<
typename encoding::Tag TAG,
typename TlvType>
103 encode(EncodingImpl<TAG>& encoder,
const uint64_t value)
109 template<
typename encoding::Tag TAG,
typename TlvType>
110 struct EncodeHelper<TAG, TlvType,
std::pair<Buffer::const_iterator, Buffer::const_iterator>>
113 encode(EncodingImpl<TAG>& encoder,
const std::pair<Buffer::const_iterator, Buffer::const_iterator>& value)
116 length += encoder.prependRange(value.first, value.second);
117 length += encoder.prependVarNumber(length);
118 length += encoder.prependVarNumber(TlvType::value);
123 template<
typename LOCATION,
typename VALUE, u
int64_t TYPE,
bool REPEATABLE = false>
129 typedef std::integral_constant<uint64_t, TYPE>
TlvType;
138 template<
typename encoding::Tag TAG,
typename T>
140 encode(EncodingImpl<TAG>& encoder,
const T& value)
150 #endif // NDN_CXX_LP_DETAIL_FIELD_DECL_HPP Copyright (c) 2011-2015 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
static size_t encode(EncodingImpl< TAG > &encoder, const T &value)
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 size_t encode(EncodingImpl< TAG > &encoder, const T &value)
static uint64_t decode(const Block &wire)
size_t value_size() const
static size_t encode(EncodingImpl< TAG > &encoder, const uint64_t value)
static size_t encode(EncodingImpl< TAG > &encoder, const std::pair< Buffer::const_iterator, Buffer::const_iterator > &value)
std::integral_constant< bool, REPEATABLE > IsRepeatable
static T decode(const Block &wire)
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)
represents an error in TLV encoding or decoding