25 #include <ndn-cxx/util/concepts.hpp> 26 #include <ndn-cxx/encoding/block-helpers.hpp> 31 BOOST_CONCEPT_ASSERT((ndn::WireEncodable<NameLsa>));
32 BOOST_CONCEPT_ASSERT((ndn::WireDecodable<NameLsa>));
33 static_assert(std::is_base_of<ndn::tlv::Error, NameLsa::Error>::value,
34 "NameLsa::Error must inherit from tlv::Error");
46 template<ndn::encoding::Tag TAG>
50 size_t totalLength = 0;
52 for (std::list<ndn::Name>::const_reverse_iterator it = m_names.rbegin();
53 it != m_names.rend(); ++it) {
54 totalLength += it->wireEncode(block);
59 totalLength += block.prependVarNumber(totalLength);
70 if (m_wire.hasWire()) {
74 ndn::EncodingEstimator estimator;
77 ndn::EncodingBuffer buffer(estimatedSize, 0);
80 m_wire = buffer.block();
94 BOOST_THROW_EXCEPTION(
Error(
"Expected NameLsa Block, but Block is of a different type: #" +
95 ndn::to_string(m_wire.type())));
100 ndn::Block::element_const_iterator val = m_wire.elements_begin();
107 BOOST_THROW_EXCEPTION(
Error(
"Missing required LsaInfo field"));
110 for (; val != m_wire.elements_end(); ++val) {
111 if (val->type() == ndn::tlv::Name) {
112 m_names.push_back(ndn::Name(*val));
116 BOOST_THROW_EXCEPTION(
Error(
"Expected Name Block, but Block is of a different type: #" +
117 ndn::to_string(m_wire.type())));
128 for (
const auto& name : nameLsa) {
129 os <<
", Name: " << name;
size_t wireEncode(ndn::EncodingImpl< TAG > &block) const
Encodes LSA info using the method in TAG.
void wireDecode(const ndn::Block &wire)
Populate this object by decoding the one contained in the given block.
NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(AdjacencyLsa)
Data abstraction for NameLsa.
Copyright (c) 2014-2018, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
const LsaInfo & getLsaInfo() const
std::ostream & operator<<(std::ostream &os, const AdjacencyLsa &adjacencyLsa)
void wireDecode(const ndn::Block &wire)
Populate this object by decoding the one contained in the given block.
const ndn::Block & wireEncode() const
Create a TLV encoding of this object.