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);
66 NameLsa::wireEncode<ndn::encoding::EncoderTag>(ndn::EncodingImpl<ndn::encoding::EncoderTag>& block)
const;
69 NameLsa::wireEncode<ndn::encoding::EstimatorTag>(ndn::EncodingImpl<ndn::encoding::EstimatorTag>& block)
const;
74 if (m_wire.hasWire()) {
78 ndn::EncodingEstimator estimator;
81 ndn::EncodingBuffer buffer(estimatedSize, 0);
84 m_wire = buffer.block();
98 std::stringstream error;
99 error <<
"Expected NameLsa Block, but Block is of a different type: #" 101 throw Error(error.str());
106 ndn::Block::element_const_iterator val = m_wire.elements_begin();
113 throw Error(
"Missing required LsaInfo field");
116 for (; val != m_wire.elements_end(); ++val) {
117 if (val->type() == ndn::tlv::Name) {
118 m_names.push_back(ndn::Name(*val));
122 std::stringstream error;
123 error <<
"Expected Name Block, but Block is of a different type: #" 125 throw Error(error.str());
136 for (
const auto& name : nameLsa) {
137 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.
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.