25 #include <boost/range/adaptor/reversed.hpp>
40 template<encoding::Tag TAG>
50 for (
const Block& element : boost::adaptors::reverse(m_wire.
elements())) {
51 length += encoder.prependBlock(element);
54 length += encoder.prependVarNumber(length);
61 Packet::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>& encoder)
const;
64 Packet::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>& encoder)
const;
75 if (elements.size() == 1 && elements.front().type() == FragmentField::TlvType::value) {
76 elements.front().parse();
77 elements.front().elements().front().parse();
78 return elements.front().elements().front();
87 m_wire = buffer.block();
96 add<FragmentField>(make_pair(wire.
begin(), wire.
end()));
111 if (!info.isRecognized && !info.canIgnore) {
112 BOOST_THROW_EXCEPTION(
Error(
"unrecognized field " +
to_string(element.type()) +
" cannot be ignored"));
116 if (info.tlvType == prev.
tlvType && !info.isRepeatable) {
117 BOOST_THROW_EXCEPTION(
Error(
"non-repeatable field " +
to_string(element.type()) +
" cannot be repeated"));
121 BOOST_THROW_EXCEPTION(
Error(
"fields are not in correct sort order"));
133 Packet::comparePos(
const Block& first,
const uint64_t second)
Copyright (c) 2013-2016 Regents of the University of California.
Buffer::const_iterator end() const
EncodingImpl< EstimatorTag > EncodingEstimator
const element_container & elements() const
Get all subelements.
Class representing a wire element of NDN-TLV packet format.
bool compareFieldSortOrder(const FieldInfo &first, const FieldInfo &second)
void wireDecode(const Block &wire)
decode packet from wire format
EncodingImpl< EncoderTag > EncodingBuffer
Block wireEncode() const
encode packet into wire format
void parse() const
Parse wire buffer into subblocks.
std::vector< Block > element_container
bool hasWire() const
Check if the Block has fully encoded wire.
std::string to_string(const V &v)
uint64_t tlvType
TLV-TYPE of the field; 0 if field does not exist.
Buffer::const_iterator begin() const