26 #include <boost/hana/functional/overload.hpp> 30 BOOST_CONCEPT_ASSERT((boost::EqualityComparable<KeyLocator>));
35 "KeyLocator::Error must inherit from tlv::Error");
51 template<encoding::Tag TAG>
58 size_t totalLength = 0;
60 auto visitor = boost::hana::overload(
62 [&] (
const Name&
name) { totalLength +=
name.wireEncode(encoder); },
65 visit(visitor, m_locator);
67 totalLength += encoder.prependVarNumber(totalLength);
86 m_wire = buffer.block();
101 if (element == m_wire.
elements().end()) {
105 switch (element->type()) {
107 m_locator.emplace<
Name>(*element);
110 m_locator.emplace<
Block>(*element);
113 m_locator = element->
type();
121 switch (m_locator.index()) {
129 return get<uint32_t>(m_locator);
138 m_locator = monostate{};
147 return get<Name>(m_locator);
149 catch (
const bad_variant_access&) {
166 return get<Block>(m_locator);
168 catch (
const bad_variant_access&) {
179 m_locator = keyDigest;
187 BOOST_ASSERT(keyDigest !=
nullptr);
196 auto visitor = boost::hana::overload(
201 os <<
"Name=" <<
name;
203 [&] (
const Block& digest) {
210 [&] (uint32_t type) {
211 os <<
"Unknown(" << type <<
")";
213 visit(visitor, keyLocator.m_locator);
Copyright (c) 2011-2015 Regents of the University of California.
std::string to_string(const T &val)
const Block & getKeyDigest() const
Get nested KeyDigest element.
KeyLocator & setName(const Name &name)
Set nested Name element.
const Name & getName() const
Get nested Name element.
void wireDecode(const Block &wire)
Decode from wire encoding.
void parse() const
Parse TLV-VALUE into sub-elements.
KeyLocator & setKeyDigest(const Block &keyDigest)
Set nested KeyDigest element (whole TLV).
Represents a TLV element of the NDN packet format.
bool hasWire() const noexcept
Check if the Block contains a fully encoded wire representation.
element_const_iterator elements_begin() const
Equivalent to elements().begin()
KeyLocator()
Construct an empty KeyLocator.
const Block & wireEncode() const
const element_container & elements() const
Get container of sub-elements.
a concept check for TLV abstraction with .wireEncode method
void reset() noexcept
Reset the Block to a default-constructed state.
const size_t MAX_KEY_DIGEST_OCTETS_TO_SHOW
Represents an absolute name.
NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(Interest)
Block makeBinaryBlock(uint32_t type, span< const uint8_t > value)
Create a TLV block copying the TLV-VALUE from a byte range.
KeyLocator & clear()
Reset KeyLocator to its default-constructed state.
uint32_t type() const noexcept
Return the TLV-TYPE of the Block.
#define NDN_CXX_UNREACHABLE
size_t prependBlock(EncodingImpl< TAG > &encoder, const Block &block)
Prepend a TLV element.
friend std::ostream & operator<<(std::ostream &, const KeyLocator &)
void printHex(std::ostream &os, uint64_t num, bool wantUpperCase)
Output the hex representation of num to the output stream os.
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
EncodingImpl< EstimatorTag > EncodingEstimator
shared_ptr< const Buffer > ConstBufferPtr
R visit(const Visitor &v, V1 const &arg1)