44 template<encoding::Tag TAG>
49 length += m_data->wireEncode(encoder);
50 length += encoder.prependVarNumber(length);
71 if (m_data ==
nullptr) {
72 BOOST_THROW_EXCEPTION(
Error(
"Data is unset in PrefixAnnouncement"));
75 const Name& dataName = m_data->getName();
85 if (data ==
nullptr) {
86 BOOST_THROW_EXCEPTION(
Error(
"Unexpected nullptr"));
90 BOOST_THROW_EXCEPTION(
Error(
"Unexpected prefix in name " + data->getName().toUri()));
93 if (!data->getName().get(-1).isVersion()) {
94 BOOST_THROW_EXCEPTION(
Error(
"Last name component of " + data->getName().toUri() +
95 " is not a version"));
98 if (data->getContent().value_size() != 0 ||
99 data->getMetaInfo().wireEncode().value_size() != 0) {
100 BOOST_THROW_EXCEPTION(
Error(
"Both Data MetaInfo and Content must be empty"));
103 m_data = std::move(data);
Copyright (c) 2013-2017 Regents of the University of California.
static const name::Component SELF_LEARNING_PREFIX("self-learning")
Represents a TLV element of NDN packet format.
PrefixAnnouncement & setData(shared_ptr< const Data > data)
Name getAnnouncedName() const
Get announced name.
bool isVersion() const
Check if the component is version per NDN naming conventions.
void wireDecode(const Block &wire)
const Block & get(uint32_t type) const
Get the first sub element of specified TLV-TYPE.
#define NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(ClassName)
size_t size() const
Get number of components.
Represents an absolute name.
size_t wireEncode(EncodingImpl< TAG > &encoder) const
const Component & at(ssize_t i) const
Get the component at the given index.
void parse() const
Parse TLV-VALUE into sub elements.
uint32_t type() const
Get TLV-TYPE.
represents a Prefix Announcement
PartialName getSubName(ssize_t iStartComponent, size_t nComponents=npos) const
Extract some components as a sub-name (PartialName)
std::string to_string(const V &v)