28 BOOST_CONCEPT_ASSERT((boost::EqualityComparable<KeyLocator>));
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);
91 m_wire = buffer.block();
99 BOOST_THROW_EXCEPTION(
Error(
"Unexpected TLV type during KeyLocator decoding"));
138 BOOST_THROW_EXCEPTION(
Error(
"KeyLocator type is not Name"));
156 BOOST_THROW_EXCEPTION(
Error(
"KeyLocator type is not KeyDigest"));
165 BOOST_THROW_EXCEPTION(
Error(
"expecting KeyDigest block"));
169 m_keyDigest = keyDigest;
192 switch (keyLocator.
getType()) {
194 return os <<
"Name=" << keyLocator.
getName();
197 const size_t MAX_DIGEST_OCTETS_TO_SHOW = 5;
199 os <<
"KeyDigest=" <<
toHex(digest.
value(), digest.
value_size()).substr(0, MAX_DIGEST_OCTETS_TO_SHOW * 2);
200 if (digest.
value_size() > MAX_DIGEST_OCTETS_TO_SHOW) {
209 return os <<
"Unknown";
212 return os <<
"Unknown";
size_t wireEncode(EncodingImpl< TAG > &encoder) const
prepend wire encoding
Copyright (c) 2011-2015 Regents of the University of California.
const element_container & elements() const
Get container of sub elements.
std::string toHex(const uint8_t *buffer, size_t length, bool wantUpperCase)
Return a string containing the hex representation of the bytes in buffer.
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
KeyLocator & setKeyDigest(const Block &keyDigest)
set KeyDigest element
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Fast encoding or block size estimation.
Represents a TLV element of NDN packet format.
KeyLocator()
construct an empty KeyLocator
indicates KeyLocator contains a Name
const Name & getName() const
get Name element
a concept check for TLV abstraction with .wireEncode method
const Block & getKeyDigest() const
get KeyDigest element
Block makeBinaryBlock(uint32_t type, const uint8_t *value, size_t length)
Create a TLV block copying TLV-VALUE from raw buffer.
indicates KeyLocator is empty (internal use only)
NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(Exclude)
void reset()
Reset wire buffer of the element.
Represents an absolute name.
size_t value_size() const
Get size of TLV-VALUE aka TLV-LENGTH.
indicates KeyLocator contains an unknown element
void parse() const
Parse TLV-VALUE into sub elements.
uint32_t type() const
Get TLV-TYPE.
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
Get pointer to TLV-VALUE.
bool operator==(const KeyLocator &other) const
element_const_iterator elements_begin() const
Equivalent to elements().begin()
void wireDecode(const Block &wire)
Decode name from wire encoding.
a concept check for TLV abstraction with .wireEncode method
a concept check for TLV abstraction with .wireDecode method and constructible from Block ...
void clear()
Remove all components.
EncodingImpl< EncoderTag > EncodingBuffer
EncodingImpl< EstimatorTag > EncodingEstimator
shared_ptr< const Buffer > ConstBufferPtr