26 BOOST_CONCEPT_ASSERT((boost::EqualityComparable<DelegationList>));
27 BOOST_CONCEPT_ASSERT((WireEncodableWithEncodingBuffer<DelegationList>));
28 BOOST_CONCEPT_ASSERT((WireDecodable<DelegationList>));
49 DelegationList::isValidTlvType(uint32_t type)
60 template<encoding::Tag TAG>
64 if (!isValidTlvType(type)) {
66 " while encoding DelegationList"));
69 if (this->
size() == 0) {
84 for (
auto i = m_dels.rbegin(); i != m_dels.rend(); ++i) {
86 delLen += i->name.wireEncode(encoder);
88 delLen += encoder.prependVarNumber(delLen);
92 totalLen += encoder.prependVarNumber(totalLen);
93 totalLen += encoder.prependVarNumber(type);
98 DelegationList::wireEncode<encoding::EncoderTag>(
EncodingBuffer&, uint32_t)
const;
101 DelegationList::wireEncode<encoding::EstimatorTag>(
EncodingEstimator&, uint32_t)
const;
106 if (!isValidTlvType(block.
type())) {
110 m_isSorted = wantSort;
114 for (
const auto& del : block.
elements()) {
120 auto val = del.elements_begin();
124 uint64_t preference = 0;
133 if (val == del.elements_end() || val->type() !=
tlv::Name) {
144 this->insertImpl(preference, name);
147 if (this->
size() == 0) {
159 std::vector<Delegation> dels;
164 this->insertImpl(del.preference, del.name);
172 switch (onConflict) {
174 this->eraseImpl(
nullopt, name);
175 this->insertImpl(preference, name);
178 this->insertImpl(preference, name);
181 if (!std::any_of(m_dels.begin(), m_dels.end(),
182 [name] (
const Delegation& del) {
return del.name == name; })) {
183 this->insertImpl(preference, name);
188 BOOST_ASSERT_MSG(
false,
"Unknown onConflict");
193 DelegationList::insertImpl(uint64_t preference,
const Name& name)
196 m_dels.push_back({preference, name});
201 auto pos = std::upper_bound(m_dels.begin(), m_dels.end(), del);
202 m_dels.insert(pos, del);
206 DelegationList::eraseImpl(optional<uint64_t> preference,
const Name& name)
209 for (
auto i = m_dels.begin(); i != m_dels.end();) {
210 if ((!preference || i->preference == *preference) &&
225 return lhs.m_dels == rhs.m_dels;
#define NDN_THROW_NESTED(e)
existing delegation(s) with the same name are replaced with the new delegation
const element_container & elements() const
Get container of sub-elements.
size_t prependNonNegativeIntegerBlock(EncodingImpl< TAG > &encoder, uint32_t type, uint64_t value)
Prepend a TLV element containing a non-negative integer.
new delegation is not inserted if an existing delegation has the same name
DelegationList()
construct an empty DelegationList
std::ostream & operator<<(std::ostream &os, const Data &data)
friend bool operator==(const DelegationList &, const DelegationList &)
compare whether two DelegationLists are equal
Represents a TLV element of NDN packet format.
uint64_t readNonNegativeInteger(const Block &block)
Read a non-negative integer from a TLV element.
void wireDecode(const Block &block, bool wantSort=true)
decode a DelegationList
const_iterator end() const noexcept
ostream_joiner< std::decay_t< DelimT >, CharT, Traits > make_ostream_joiner(std::basic_ostream< CharT, Traits > &os, DelimT &&delimiter)
size_t size() const noexcept
Represents an absolute name.
bool insert(uint64_t preference, const Name &name, InsertConflictResolution onConflict=INS_REPLACE)
insert Delegation
InsertConflictResolution
what to do when inserting a duplicate name
void parse() const
Parse TLV-VALUE into sub-elements.
uint32_t type() const
Return the TLV-TYPE of the Block.
void sort()
sort the delegation list
represents a list of Delegations
std::string to_string(const V &v)
void wireDecode(const Block &wire)
Decode name from wire encoding.
multiple delegations with the same name are kept in the DelegationList
EncodingImpl< EncoderTag > EncodingBuffer
const nullopt_t nullopt((nullopt_t::init()))
size_t wireEncode(EncodingImpl< TAG > &encoder, uint32_t type=tlv::ForwardingHint) const
encode into wire format
represents an error in TLV encoding or decoding
EncodingImpl< EstimatorTag > EncodingEstimator
const_iterator begin() const noexcept