23 #include "../../util/concepts.hpp" 24 #include "../../encoding/block-helpers.hpp" 30 BOOST_CONCEPT_ASSERT((boost::EqualityComparable<AdditionalDescription>));
35 "AdditionalDescription::Error must inherit from tlv::Error");
48 auto it = m_info.find(key);
49 if (it == m_info.end())
50 BOOST_THROW_EXCEPTION(
Error(
"Entry does not exist for key (" + key +
")"));
64 return (m_info.find(key) != m_info.end());
70 return m_info.begin();
82 return m_info.begin();
91 template<encoding::Tag TAG>
95 size_t totalLength = 0;
97 for (
auto it = m_info.rbegin(); it != m_info.rend(); it++) {
98 size_t entryLength = 0;
101 entryLength += encoder.prependVarNumber(entryLength);
104 totalLength += entryLength;
107 totalLength += encoder.prependVarNumber(totalLength);
126 m_wire = buffer.block();
136 BOOST_THROW_EXCEPTION(
Error(
"The supplied block does not contain wire format"));
143 BOOST_THROW_EXCEPTION(
Error(
"Unexpected TLV type when decoding AdditionalDescription"));
147 const Block& entry = *it;
151 BOOST_THROW_EXCEPTION(
Error(
"Unexpected TLV type when decoding DescriptionEntry"));
154 BOOST_THROW_EXCEPTION(
Error(
"DescriptionEntry does not have two sub-TLVs"));
158 BOOST_THROW_EXCEPTION(
Error(
"Invalid DescriptionKey or DescriptionValue field"));
168 return (m_info == other.m_info);
174 return !(*
this == other);
182 for (
const auto& entry : other) {
185 os <<
"(" << entry.first <<
":" << entry.second <<
")";
bool has(const std::string &key) const
Copyright (c) 2011-2015 Regents of the University of California.
std::map< std::string, std::string >::const_iterator const_iterator
bool operator==(const AdditionalDescription &other) const
static const size_t VALUE_OFFSET
const element_container & elements() const
Get container of sub elements.
Abstraction of AdditionalDescription.
const Block & wireEncode() const
Encode ValidityPeriod into TLV block.
static const size_t KEY_OFFSET
void wireDecode(const Block &wire)
Decode ValidityPeriod from TLV block.
element_container::const_iterator element_const_iterator
const std::string & get(const std::string &key) const
Represents a TLV element of NDN packet format.
size_t prependStringBlock(EncodingImpl< TAG > &encoder, uint32_t type, const std::string &value)
Prepend a TLV element containing a string.
void set(const std::string &key, const std::string &value)
std::string readString(const Block &block)
Read TLV-VALUE of a TLV element as a string.
std::map< std::string, std::string >::iterator iterator
Catch-all error for security policy errors that don't fit in other categories.
bool operator!=(const AdditionalDescription &other) const
a concept check for TLV abstraction with .wireEncode method
size_t elements_size() const
Equivalent to elements().size()
AdditionalDescription()=default
Create an empty AdditionalDescription.
void parse() const
Parse TLV-VALUE into sub elements.
uint32_t type() const
Get TLV-TYPE.
std::ostream & operator<<(std::ostream &os, const AdditionalDescription &other)
bool hasWire() const
Check if the Block has fully encoded wire.
element_const_iterator elements_end() const
Equivalent to elements().end()
element_const_iterator elements_begin() const
Equivalent to elements().begin()
NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(AdditionalDescription)
a concept check for TLV abstraction with .wireEncode method
a concept check for TLV abstraction with .wireDecode method and constructible from Block ...
EncodingImpl< EncoderTag > EncodingBuffer
EncodingImpl< EstimatorTag > EncodingEstimator