34 static_assert(std::is_base_of<tlv::Error, NextHopRecord::Error>::value,
35 "NextHopRecord::Error must inherit from tlv::Error");
40 static_assert(std::is_base_of<tlv::Error, FibEntry::Error>::value,
41 "FibEntry::Error must inherit from tlv::Error");
48 : m_faceId(
std::numeric_limits<uint64_t>::max())
74 template<encoding::Tag TAG>
78 size_t totalLength = 0;
87 totalLength += block.prependVarNumber(totalLength);
111 m_wire = buffer.block();
118 m_faceId = std::numeric_limits<uint64_t>::max();
124 std::stringstream error;
125 error <<
"Requested decoding of NextHopRecord, but Block is of a different type: #" 127 BOOST_THROW_EXCEPTION(
Error(error.str()));
133 BOOST_THROW_EXCEPTION(
Error(
"Unexpected end of NextHopRecord"));
136 std::stringstream error;
137 error <<
"Expected FaceId, but Block is of a different type: #" 139 BOOST_THROW_EXCEPTION(
Error(error.str()));
145 BOOST_THROW_EXCEPTION(
Error(
"Unexpected end of NextHopRecord"));
148 std::stringstream error;
149 error <<
"Expected Cost, but Block is of a different type: #" 151 BOOST_THROW_EXCEPTION(
Error(error.str()));
180 m_nextHopRecords.push_back(nextHopRecord);
185 template<encoding::Tag TAG>
189 size_t totalLength = 0;
191 for (
auto i = m_nextHopRecords.rbegin(); i != m_nextHopRecords.rend(); ++i) {
192 totalLength += i->wireEncode(block);
196 totalLength += block.prependVarNumber(totalLength);
221 m_wire = buffer.block();
230 m_nextHopRecords.clear();
235 std::stringstream error;
236 error <<
"Requested decoding of FibEntry, but Block is of a different type: #" 238 BOOST_THROW_EXCEPTION(
Error(error.str()));
245 BOOST_THROW_EXCEPTION(
Error(
"Unexpected end of FibEntry"));
248 std::stringstream error;
249 error <<
"Expected Name, but Block is of a different type: #" 251 BOOST_THROW_EXCEPTION(
Error(error.str()));
258 std::stringstream error;
259 error <<
"Expected NextHopRecords, but Block is of a different type: #" 261 BOOST_THROW_EXCEPTION(
Error(error.str()));
element_const_iterator elements_begin() const
bool hasWire() const
Check if the Block has fully encoded wire.
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.
void wireDecode(const Block &wire)
NextHopRecord & setFaceId(uint64_t faceId)
FibEntry & setPrefix(const Name &prefix)
EncodingImpl< EstimatorTag > EncodingEstimator
element_const_iterator elements_end() const
void parse() const
Parse wire buffer into subblocks.
Class representing a wire element of NDN-TLV packet format.
uint64_t readNonNegativeInteger(const Block &block)
Helper to read a non-negative integer from a block.
void wireDecode(const Block &wire)
EncodingImpl< EncoderTag > EncodingBuffer
Copyright (c) 2011-2015 Regents of the University of California.
element_container::const_iterator element_const_iterator
NextHopRecord & setCost(uint64_t cost)
void reset()
Reset wire buffer of the element.
Name abstraction to represent an absolute name.
FibEntry & addNextHopRecord(const NextHopRecord &nextHopRecord)
const Block & wireEncode() const
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Fast encoding or block size estimation.
void wireDecode(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 ...
void clear()
Clear all the components.
const Block & wireEncode() const