28 BOOST_CONCEPT_ASSERT((boost::EqualityComparable<KeyLocator>));
32 static_assert(std::is_base_of<tlv::Error, KeyLocator::Error>::value,
33 "KeyLocator::Error must inherit from tlv::Error");
36 : m_type(KeyLocator_None)
50 template<encoding::Tag TAG>
57 size_t totalLength = 0;
66 totalLength += encoder.prependBlock(m_keyDigest);
69 BOOST_THROW_EXCEPTION(
Error(
"Unsupported KeyLocator type"));
72 totalLength += encoder.prependVarNumber(totalLength);
78 KeyLocator::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>& encoder)
const;
81 KeyLocator::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>& encoder)
const;
95 m_wire = buffer.block();
103 BOOST_THROW_EXCEPTION(
Error(
"Unexpected TLV type during KeyLocator decoding"));
142 BOOST_THROW_EXCEPTION(
Error(
"KeyLocator type is not Name"));
160 BOOST_THROW_EXCEPTION(
Error(
"KeyLocator type is not KeyDigest"));
169 BOOST_THROW_EXCEPTION(
Error(
"expecting KeyDigest block"));
173 m_keyDigest = keyDigest;
196 switch (keyLocator.
getType()) {
198 return os <<
"Name=" << keyLocator.
getName();
201 const size_t MAX_DIGEST_OCTETS_TO_SHOW = 5;
203 os <<
"KeyDigest=" <<
toHex(digest.
value(), digest.
value_size()).substr(0, MAX_DIGEST_OCTETS_TO_SHOW * 2);
204 if (digest.
value_size() > MAX_DIGEST_OCTETS_TO_SHOW) {
213 return os <<
"Unknown";
216 return os <<
"Unknown";
size_t wireEncode(EncodingImpl< TAG > &encoder) const
prepend wire encoding
Copyright (c) 2013-2016 Regents of the University of California.
EncodingImpl< EstimatorTag > EncodingEstimator
std::ostream & operator<<(std::ostream &os, const Data &data)
KeyLocator & setName(const Name &name)
set Name element
void wireDecode(const Block &wire)
decode from wire encoding
const element_container & elements() const
Get all subelements.
KeyLocator & setKeyDigest(const Block &keyDigest)
set KeyDigest element
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Fast encoding or block size estimation.
Class representing a wire element of NDN-TLV packet format.
KeyLocator()
construct an empty KeyLocator
indicates KeyLocator contains a Name
const Name & getName() const
get Name element
element_const_iterator elements_begin() const
a concept check for TLV abstraction with .wireEncode method
const Block & getKeyDigest() const
get KeyDigest element
EncodingImpl< EncoderTag > EncodingBuffer
Block makeBinaryBlock(uint32_t type, const uint8_t *value, size_t length)
Create a TLV block type type with value from a buffer value of size length.
indicates KeyLocator is empty (internal use only)
std::string toHex(const uint8_t *buffer, size_t length, bool isUpperCase)
Return the hex representation of the bytes in array.
void reset()
Reset wire buffer of the element.
Name abstraction to represent an absolute name.
size_t value_size() const
indicates KeyLocator contains an unknown element
void parse() const
Parse wire buffer into subblocks.
KeyLocator & clear()
clear KeyLocator
const Block & wireEncode() const
indicates KeyLocator contains a KeyDigest
bool hasWire() const
Check if the Block has fully encoded wire.
const uint8_t * value() const
bool operator==(const KeyLocator &other) const
shared_ptr< const Buffer > ConstBufferPtr
void wireDecode(const Block &wire)
a concept check for TLV abstraction with .wireEncode method
a concept check for TLV abstraction with .wireDecode method and constructible from Block ...
void clear()
Clear all the components.