29 BOOST_CONCEPT_ASSERT((boost::EqualityComparable<KeyLocator>));
30 BOOST_CONCEPT_ASSERT((WireEncodable<KeyLocator>));
31 BOOST_CONCEPT_ASSERT((WireEncodableWithEncodingBuffer<KeyLocator>));
32 BOOST_CONCEPT_ASSERT((WireDecodable<KeyLocator>));
33 static_assert(std::is_base_of<tlv::Error, KeyLocator::Error>::value,
34 "KeyLocator::Error must inherit from tlv::Error");
50 template<encoding::Tag TAG>
57 size_t totalLength = 0;
61 [&] (
const Name& name) { totalLength += name.wireEncode(encoder); },
64 visit(visitor, m_locator);
66 totalLength += encoder.prependVarNumber(totalLength);
85 m_wire = buffer.block();
100 if (element == m_wire.
elements().end()) {
104 switch (element->type()) {
106 m_locator.emplace<
Name>(*element);
109 m_locator.emplace<
Block>(*element);
112 m_locator = element->type();
120 switch (m_locator.index()) {
128 return get<uint32_t>(m_locator);
137 m_locator = monostate{};
146 return get<Name>(m_locator);
148 catch (
const bad_variant_access&) {
165 return get<Block>(m_locator);
167 catch (
const bad_variant_access&) {
178 m_locator = keyDigest;
186 BOOST_ASSERT(keyDigest !=
nullptr);
199 [&] (
const Name& name) {
200 os <<
"Name=" << name;
202 [&] (
const Block& digest) {
209 [&] (uint32_t type) {
210 os <<
"Unknown(" << type <<
")";
212 visit(visitor, keyLocator.m_locator);
#define NDN_CXX_UNREACHABLE
Represents a TLV element of the NDN packet format.
uint32_t type() const
Return the TLV-TYPE of the Block.
bool hasWire() const noexcept
Check if the Block contains a fully encoded wire representation.
element_const_iterator elements_begin() const
Equivalent to elements().begin()
void reset() noexcept
Reset the Block to a default-constructed state.
const element_container & elements() const
Get container of sub-elements.
void parse() const
Parse TLV-VALUE into sub-elements.
const Block & getKeyDigest() const
Get nested KeyDigest element.
const Name & getName() const
Get nested Name element.
KeyLocator()
Construct an empty KeyLocator.
const Block & wireEncode() const
void wireDecode(const Block &wire)
Decode from wire encoding.
KeyLocator & setKeyDigest(const Block &keyDigest)
Set nested KeyDigest element (whole TLV).
KeyLocator & clear()
Reset KeyLocator to its default-constructed state.
KeyLocator & setName(const Name &name)
Set nested Name element.
Represents an absolute name.
#define NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(ClassName)
EncodingImpl< EstimatorTag > EncodingEstimator
Block makeBinaryBlock(uint32_t type, span< const uint8_t > value)
Create a TLV block copying the TLV-VALUE from a byte range.
EncodingImpl< EncoderTag > EncodingBuffer
size_t prependBlock(EncodingImpl< TAG > &encoder, const Block &block)
Prepend a TLV element.
std::string to_string(const errinfo_stacktrace &x)
void printHex(std::ostream &os, uint64_t num, bool wantUpperCase)
Output the hex representation of num to the output stream os.
shared_ptr< const Buffer > ConstBufferPtr
const size_t MAX_KEY_DIGEST_OCTETS_TO_SHOW
constexpr detail::make_overload_t overload
std::ostream & operator<<(std::ostream &os, const Data &data)