26 #include <boost/hana/functional/overload.hpp>
44 template<encoding::Tag TAG>
51 size_t totalLength = 0;
53 std::visit(boost::hana::overload(
54 [] (std::monostate) {},
55 [&] (
const Name& name) { totalLength += name.wireEncode(encoder); },
60 totalLength += encoder.prependVarNumber(totalLength);
79 m_wire = buffer.block();
94 if (element == m_wire.
elements().end()) {
98 switch (element->type()) {
100 m_locator.emplace<
Name>(*element);
103 m_locator.emplace<
Block>(*element);
106 m_locator = element->type();
114 switch (m_locator.index()) {
122 return std::get<uint32_t>(m_locator);
131 m_locator = std::monostate{};
140 return std::get<Name>(m_locator);
142 catch (
const std::bad_variant_access&) {
159 return std::get<Block>(m_locator);
161 catch (
const std::bad_variant_access&) {
172 m_locator = keyDigest;
180 BOOST_ASSERT(keyDigest !=
nullptr);
187 KeyLocator::print(std::ostream& os)
const
189 std::visit(boost::hana::overload(
190 [&] (std::monostate) {
193 [&] (
const Name& name) {
194 os <<
"Name=" << name;
196 [&] (
const Block& digest) {
203 [&] (uint32_t type) {
204 os <<
"Unknown(" << type <<
")";
#define NDN_CXX_UNREACHABLE
Represents a TLV element of the NDN packet format.
element_const_iterator elements_begin() const noexcept
Equivalent to elements().begin().
const element_container & elements() const noexcept
Get container of sub-elements.
bool hasWire() const noexcept
Check if the Block contains a fully encoded wire representation.
uint32_t type() const noexcept
Return the TLV-TYPE of the Block.
void reset() noexcept
Reset the Block to a default-constructed state.
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.
constexpr size_t MAX_KEY_DIGEST_OCTETS_TO_SHOW
std::shared_ptr< const Buffer > ConstBufferPtr