28 BOOST_CONCEPT_ASSERT((boost::EqualityComparable<Selectors>));
32 static_assert(std::is_base_of<tlv::Error, Selectors::Error>::value,
33 "Selectors::Error must inherit from tlv::Error");
36 : m_minSuffixComponents(-1)
37 , m_maxSuffixComponents(-1)
39 , m_mustBeFresh(false)
51 return m_minSuffixComponents < 0 &&
52 m_maxSuffixComponents < 0 &&
53 m_publisherPublicKeyLocator.
empty() &&
59 template<encoding::Tag TAG>
63 size_t totalLength = 0;
107 totalLength += encoder.prependVarNumber(totalLength);
126 m_wire = buffer.block();
134 BOOST_THROW_EXCEPTION(
tlv::Error(
"Unexpected TLV type when decoding Selectors"));
144 m_minSuffixComponents = readNonNegativeIntegerAs<int>(*val);
150 m_maxSuffixComponents = readNonNegativeIntegerAs<int>(*val);
168 m_childSelector = readNonNegativeIntegerAs<bool>(*val);
177 m_mustBeFresh =
true;
184 m_minSuffixComponents = minSuffixComponents;
192 m_maxSuffixComponents = maxSuffixComponents;
200 m_publisherPublicKeyLocator = keyLocator;
216 if (childSelector != 0 && childSelector != 1) {
217 BOOST_THROW_EXCEPTION(std::invalid_argument(
"ChildSelector must be 0 or 1"));
219 m_childSelector = childSelector;
227 m_mustBeFresh = mustBeFresh;
void wireDecode(const Block &wire)
Decode the input from wire format.
int getMinSuffixComponents() const
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.
Selectors & setMustBeFresh(bool mustBeFresh)
element_container::const_iterator element_const_iterator
int getMustBeFresh() const
void wireDecode(const Block &wire)
decode from wire encoding
const int DEFAULT_CHILD_SELECTOR
void parse() const
Parse TLV-VALUE into sub elements.
Represents a TLV element of NDN packet format.
int getChildSelector() const
Selectors & setMaxSuffixComponents(int maxSuffixComponents)
Selectors & setExclude(const Exclude &exclude)
Selectors & setChildSelector(int childSelector)
set ChildSelector
Selectors & setMinSuffixComponents(int minSuffixComponents)
a concept check for TLV abstraction with .wireEncode method
void wireDecode(const Block &wire)
Decode from the wire format.
element_const_iterator elements_end() const
Equivalent to elements().end()
const KeyLocator & getPublisherPublicKeyLocator() const
element_const_iterator find(uint32_t type) const
Find the first sub element of specified TLV-TYPE.
size_t prependEmptyBlock(EncodingImpl< TAG > &encoder, uint32_t type)
Prepend an empty TLV element.
const Block & wireEncode() const
Encode to a wire format.
Abstraction implementing Interest selectors.
NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(Exclude)
void reset()
Reset wire buffer of the element.
bool operator==(const Selectors &other) const
int getMaxSuffixComponents() const
size_t wireEncode(EncodingImpl< TAG > &encoder) const
prepend wire encoding
const Exclude & getExclude() const
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Fast encoding or block size estimation.
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Fast encoding or block size estimation.
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
uint32_t type() const
Get TLV-TYPE.
represents an error in TLV encoding or decoding
EncodingImpl< EstimatorTag > EncodingEstimator
Represents Exclude selector in NDN Interest.
Selectors & setPublisherPublicKeyLocator(const KeyLocator &keyLocator)