25 #include <ndn-cxx/util/concepts.hpp> 26 #include <ndn-cxx/encoding/block-helpers.hpp> 31 BOOST_CONCEPT_ASSERT((ndn::WireEncodable<NextHop>));
32 BOOST_CONCEPT_ASSERT((ndn::WireDecodable<NextHop>));
33 static_assert(std::is_base_of<ndn::tlv::Error, NextHop::Error>::value,
34 "NextHop::Error must inherit from tlv::Error");
46 template<ndn::encoding::Tag TAG>
50 size_t totalLength = 0;
52 const uint8_t* doubleBytes =
reinterpret_cast<const uint8_t*
>(&m_cost);
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"));
112 m_cost = *
reinterpret_cast<const double*
>(val->value());
116 BOOST_THROW_EXCEPTION(
Error(
"HyperbolicCost: Missing required Double field"));
124 <<
"Uri: " << nexthop.
getUri() <<
", "<<
"Cost: " << nexthop.
getCost() <<
")" << std::endl;
const std::string & getUri() const
Data abstraction for Nexthop.
Copyright (c) 2014-2018, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(Destination)
const ndn::Block & wireEncode() const
void wireDecode(const ndn::Block &wire)
std::ostream & operator<<(std::ostream &os, const AdjacencyLsa &adjacencyLsa)