|
NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
|
API Documentation
|
Go to the documentation of this file.
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
static size_t encode(EncodingImpl< TAG > &encoder, const EmptyValue value)
size_t value_size() const noexcept
Return the size of TLV-VALUE, aka TLV-LENGTH.
std::integral_constant< uint64_t, TYPE > TlvType
static size_t encode(EncodingImpl< TAG > &encoder, uint64_t value)
static uint64_t decode(const Block &wire)
static size_t encode(EncodingImpl< TAG > &encoder, const T &value)
static ValueType decode(const Block &wire)
Decode a field.
Buffer::const_iterator value_end() const
Get end iterator of TLV-VALUE.
std::integral_constant< bool, REPEATABLE > IsRepeatable
a concept check for TLV abstraction with .wireDecode method and constructible from Block
uint64_t readNonNegativeInteger(const Block &block)
Read a non-negative integer from a TLV element.
uint32_t type() const
Return the TLV-TYPE of the Block.
Buffer::const_iterator value_begin() const
Get begin iterator of TLV-VALUE.
static size_t encode(EncodingImpl< TAG > &encoder, const std::pair< Buffer::const_iterator, Buffer::const_iterator > &value)
static EmptyValue 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.
static uint64_t decode(const Block &wire)
const uint8_t * value() const noexcept
Return a raw pointer to the beginning of TLV-VALUE.
Represents a TLV element of NDN packet format.
static size_t encode(EncodingImpl< TAG > &encoder, uint64_t value)
std::string to_string(const T &val)
static T decode(const Block &wire)
represents an error in TLV encoding or decoding
represents a zero-length TLV-VALUE
a concept check for TLV abstraction with .wireEncode method
Copyright (c) 2011-2015 Regents of the University of California.
static size_t encode(EncodingImpl< TAG > &encoder, const ValueType &value)
Encode a field and prepend to encoder.