26 #include <ndn-cxx/util/concepts.hpp> 27 #include <ndn-cxx/encoding/block-helpers.hpp> 32 BOOST_CONCEPT_ASSERT((ndn::WireEncodable<NextHop>));
33 BOOST_CONCEPT_ASSERT((ndn::WireDecodable<NextHop>));
34 static_assert(std::is_base_of<ndn::tlv::Error, NextHop::Error>::value,
35 "NextHop::Error must inherit from tlv::Error");
47 template<ndn::encoding::Tag TAG>
51 size_t totalLength = 0;
55 totalLength += block.prependByteArrayBlock(
58 totalLength += block.prependVarNumber(totalLength);
69 if (m_wire.hasWire()) {
73 ndn::EncodingEstimator estimator;
76 ndn::EncodingBuffer buffer(estimatedSize, 0);
79 m_wire = buffer.block();
93 std::stringstream error;
94 error <<
"Expected NextHop Block, but Block is of a different type: #" 96 BOOST_THROW_EXCEPTION(
Error(error.str()));
101 ndn::Block::element_const_iterator val = m_wire.elements_begin();
104 m_uri.assign(reinterpret_cast<const char*>(val->value()), val->value_size());
108 BOOST_THROW_EXCEPTION(
Error(
"Missing required Uri field"));
118 <<
"Uri: " << nexthop.
getUri() <<
", "<<
"Cost: " << nexthop.
getCost() <<
")" << std::endl;
const std::string & getUri() const
Data abstraction for Nexthop.
double readDouble(const ndn::Block &block)
Read a double from a TLV element.
NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(AdjacencyLsa)
size_t prependDouble(ndn::EncodingImpl< TAG > &encoder, uint32_t type, double value)
Prepend a TLV element containing a double.
Copyright (c) 2014-2018, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
const ndn::Block & wireEncode() const
void wireDecode(const ndn::Block &wire)
std::ostream & operator<<(std::ostream &os, const AdjacencyLsa &adjacencyLsa)