void Exclude::wireDecode(const Block& wire) { clear(); if (wire.type() != tlv::Exclude) throw tlv::Error("Unexpected TLV type when decoding Exclude"); m_wire = wire; m_wire.parse(); if (m_wire.elements_size() == 0) { throw Error("Exclude element cannot be empty"); } // Exclude ::= EXCLUDE-TYPE TLV-LENGTH Any? (NameComponent (Any)?)+ // Any ::= ANY-TYPE TLV-LENGTH(=0) Block::element_const_iterator i = m_wire.elements_begin(); if (i->type() == tlv::Any) { appendExclude(name::Component(), true); ++i; } while (i != m_wire.elements_end()) { if (i->type() != tlv::NameComponent) throw Error("Incorrect format of Exclude filter"); name::Component excludedComponent(i->value(), i->value_size()); ++i; if (i != m_wire.elements_end()) { if (i->type() == tlv::Any) { appendExclude(excludedComponent, true); ++i; } else { appendExclude(excludedComponent, false); } } else { appendExclude(excludedComponent, false); } } }
void Exclude::wireDecode(const Block& wire) { clear(); if (wire.type() != tlv::Exclude) BOOST_THROW_EXCEPTION(tlv::Error("Unexpected TLV type when decoding Exclude")); m_wire = wire; m_wire.parse(); if (m_wire.elements_size() == 0) { BOOST_THROW_EXCEPTION(Error("Exclude element cannot be empty")); } // Exclude ::= EXCLUDE-TYPE TLV-LENGTH Any? (NameComponent (Any)?)+ // Any ::= ANY-TYPE TLV-LENGTH(=0) Block::element_const_iterator i = m_wire.elements_begin(); if (i->type() == tlv::Any) { appendExclude(name::Component(), true); ++i; } while (i != m_wire.elements_end()) { name::Component excludedComponent; try { excludedComponent = name::Component(*i); } catch (const name::Component::Error&) { BOOST_THROW_EXCEPTION(Error("Incorrect format of Exclude filter")); } ++i; if (i != m_wire.elements_end()) { if (i->type() == tlv::Any) { appendExclude(excludedComponent, true); ++i; } else { appendExclude(excludedComponent, false); } } else { appendExclude(excludedComponent, false); } } }