39 if (
auto it = m_info.find(key); it != m_info.end()) {
55 return m_info.find(key) != m_info.end();
61 return m_info.begin();
73 return m_info.begin();
82template<encoding::Tag TAG>
86 size_t totalLength = 0;
88 for (
auto it = m_info.rbegin(); it != m_info.rend(); it++) {
89 size_t entryLength = 0;
92 entryLength += encoder.prependVarNumber(entryLength);
95 totalLength += entryLength;
98 totalLength += encoder.prependVarNumber(totalLength);
111 EncodingEstimator estimator;
114 EncodingBuffer buffer(estimatedSize, 0);
117 m_wire = buffer.block();
132 for (
const auto& e : m_wire.
elements()) {
136 if (e.elements_size() != 2) {
137 NDN_THROW(
Error(
"DescriptionEntry does not have two sub-elements"));
141 NDN_THROW(
Error(
"Missing DescriptionKey or DescriptionValue field"));
143 m_info.insert_or_assign(readString(e.elements()[
KEY_OFFSET]),
149 NDN_THROW(
Error(
"Unrecognized element of critical type " + std::to_string(e.type())));
163 for (
const auto& entry : desc) {
164 join =
"(" + entry.first +
":" + entry.second +
")";
Represents a TLV element of the NDN packet format.
const element_container & elements() const noexcept
Get container of sub-elements.
bool hasWire() const noexcept
Check if the Block contains a fully encoded wire representation.
uint32_t type() const noexcept
Return the TLV-TYPE of the Block.
void parse() const
Parse TLV-VALUE into sub-elements.
Represents an AdditionalDescription TLV element.
std::map< std::string, std::string >::const_iterator const_iterator
bool has(const std::string &key) const
std::map< std::string, std::string >::iterator iterator
const Block & wireEncode() const
Encode ValidityPeriod into TLV block.
const std::string & get(const std::string &key) const
void wireDecode(const Block &wire)
Decode ValidityPeriod from TLV block.
AdditionalDescription()=default
Create an empty AdditionalDescription.
void set(const std::string &key, const std::string &value)
#define NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(ClassName)
Contains the ndn-cxx security framework.
std::ostream & operator<<(std::ostream &os, const AdditionalDescription &desc)
constexpr size_t VALUE_OFFSET
constexpr size_t KEY_OFFSET
constexpr bool isCriticalType(uint32_t type) noexcept
Determine whether a TLV-TYPE is "critical" for evolvability purpose.
ostream_joiner< std::decay_t< DelimT >, CharT, Traits > make_ostream_joiner(std::basic_ostream< CharT, Traits > &os, DelimT &&delimiter)
Backport of ostream_joiner from the Library Fundamentals v2 TS.