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>
127 length += encoder.prependVarNumber(0);
128 length += encoder.prependVarNumber(TlvType::value);
133 template<
typename encoding::Tag TAG,
typename TlvType>
143 template<
typename encoding::Tag TAG,
typename TlvType>
149 boost::endian::native_to_big_inplace(value);
150 return encoder.prependByteArrayBlock(TlvType::value,
151 reinterpret_cast<const uint8_t*
>(&value),
sizeof(value));
155 template<
typename encoding::Tag TAG,
typename TlvType>
156 struct EncodeHelper<TAG, TlvType, std::pair<Buffer::const_iterator, Buffer::const_iterator>>
162 length += encoder.prependRange(value.first, value.second);
163 length += encoder.prependVarNumber(length);
164 length += encoder.prependVarNumber(TlvType::value);
177 template<
typename LOCATION,
typename VALUE, uint64_t TYPE,
bool REPEATABLE =
false,
178 typename DECODER_TAG = VALUE,
typename ENCODER_TAG = VALUE>
184 typedef std::integral_constant<uint64_t, TYPE>
TlvType;
195 if (wire.
type() != TlvType::value) {
206 template<
typename encoding::Tag TAG>
217 #endif // NDN_CXX_LP_FIELD_DECL_HPP