28 BOOST_CONCEPT_ASSERT((boost::EqualityComparable<MetaInfo>));
32 static_assert(std::is_base_of<tlv::Error, MetaInfo::Error>::value,
33 "MetaInfo::Error must inherit from tlv::Error");
57 if (freshnessPeriod < time::milliseconds::zero()) {
58 BOOST_THROW_EXCEPTION(std::invalid_argument(
"FreshnessPeriod must be >= 0"));
61 m_freshnessPeriod = freshnessPeriod;
69 m_finalBlockId = std::move(finalBlockId);
73 const std::list<Block>&
82 for (
const auto& block : info) {
83 if (block.type() < 128 || block.type() > 252)
84 BOOST_THROW_EXCEPTION(
Error(
"AppMetaInfo block has type outside the application range [128, 252]"));
95 if (!(128 <= block.
type() && block.
type() <= 252))
96 BOOST_THROW_EXCEPTION(
Error(
"AppMetaInfo block has type outside the application range " 100 m_appMetaInfo.push_back(block);
107 for (
auto it = m_appMetaInfo.begin(); it != m_appMetaInfo.end(); ++it) {
110 m_appMetaInfo.erase(it);
120 auto it = std::find_if(m_appMetaInfo.begin(), m_appMetaInfo.end(),
122 return it != m_appMetaInfo.end() ? &*it :
nullptr;
125 template<encoding::Tag TAG>
135 size_t totalLength = 0;
137 for (
auto it = m_appMetaInfo.rbegin(); it != m_appMetaInfo.rend(); ++it) {
138 totalLength += encoder.prependBlock(*it);
142 if (m_finalBlockId) {
149 static_cast<uint64_t>(m_freshnessPeriod.count()));
157 totalLength += encoder.prependVarNumber(totalLength);
176 m_wire = buffer.block();
196 m_type = readNonNegativeIntegerAs<uint32_t>(*val);
214 m_finalBlockId.emplace(val->blockFromValue());
222 for (; val != m_wire.
elements().end(); ++val) {
223 m_appMetaInfo.push_back(*val);
231 os <<
"ContentType: " << info.
getType();
240 os <<
", FinalBlockId: ";
246 os <<
", AppMetaInfoTlvType: " << block.type();
bool hasWire() const
Check if the Block has fully encoded wire.
Copyright (c) 2011-2015 Regents of the University of California.
size_t prependNonNegativeIntegerBlock(EncodingImpl< TAG > &encoder, uint32_t type, uint64_t value)
Prepend a TLV element containing a non-negative integer.
std::ostream & operator<<(std::ostream &os, const Data &data)
size_t prependNestedBlock(EncodingImpl< TAG > &encoder, uint32_t type, const U &value)
Prepend a TLV element containing a nested TLV element.
void parse() const
Parse TLV-VALUE into sub elements.
Represents a TLV element of NDN packet format.
element_const_iterator elements_begin() const
Equivalent to elements().begin()
uint64_t readNonNegativeInteger(const Block &block)
Read a non-negative integer from a TLV element.
const element_container & elements() const
Get container of sub elements.
a concept check for TLV abstraction with .wireEncode method
const time::milliseconds DEFAULT_FRESHNESS_PERIOD
element_const_iterator elements_end() const
Equivalent to elements().end()
NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(Exclude)
void reset()
Reset wire buffer of the element.
uint64_t tlvType
TLV-TYPE of the field; 0 if field does not exist.
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
const nullopt_t nullopt((nullopt_t::init()))
uint32_t type() const
Get TLV-TYPE.
EncodingImpl< EstimatorTag > EncodingEstimator