28 BOOST_CONCEPT_ASSERT((boost::EqualityComparable<Data>));
32 static_assert(std::is_base_of<tlv::Error, Data::Error>::value,
33 "Data::Error must inherit from tlv::Error");
46 template<encoding::Tag TAG>
57 size_t totalLength = 0;
60 if (!wantUnsignedPortionOnly) {
62 BOOST_THROW_EXCEPTION(
Error(
"Requested wire format, but Data has not been signed"));
64 totalLength += encoder.prependBlock(m_signature.
getValue());
68 totalLength += encoder.prependBlock(m_signature.
getInfo());
71 totalLength += encoder.prependBlock(
getContent());
79 if (!wantUnsignedPortionOnly) {
80 totalLength += encoder.prependVarNumber(totalLength);
81 totalLength += encoder.prependVarNumber(
tlv::Data);
87 Data::wireEncode<encoding::EncoderTag>(
EncodingBuffer&, bool)
const;
95 size_t totalLength = encoder.
size();
96 totalLength += encoder.appendBlock(signatureValue);
98 encoder.prependVarNumber(totalLength);
150 if (m_fullName.
empty()) {
152 BOOST_THROW_EXCEPTION(
Error(
"Cannot compute full name because Data has no wire encoding (not signed)"));
180 m_metaInfo = metaInfo;
188 const_cast<Block&
>(m_content).encode();
228 m_signature = signature;
276 os <<
"Name: " << data.
getName() <<
"\n";
const Block & wireEncode() const
Encode to a wire format.
bool hasWire() const
Check if the Block has fully encoded wire.
Data & setContentType(uint32_t type)
Copyright (c) 2011-2015 Regents of the University of California.
const Name & getName() const
Get name.
void wireDecode(const Block &wire)
Decode from the wire format.
const Block & getContent() const
Get Content.
Data & setSignature(const Signature &signature)
Set Signature.
Data & setName(const Name &name)
Set name.
size_t value_size() const
Get size of TLV-VALUE aka TLV-LENGTH.
std::ostream & operator<<(std::ostream &os, const Data &data)
void setInfo(const Block &info)
Decode SignatureInfo from wire format.
element_container::const_iterator element_const_iterator
Data(const Name &name=Name())
Create a new Data with the given name and empty Content.
Data & setContent(const Block &block)
Set Content from a block.
const uint8_t * wire() const
Get pointer to encoded wire.
void parse() const
Parse TLV-VALUE into sub elements.
void resetWire()
Clear wire encoding and cached FullName.
Represents a TLV element of NDN packet format.
Data & setFreshnessPeriod(const time::milliseconds &freshnessPeriod)
tlv::SignatureTypeValue getType() const
Get SignatureType.
a concept check for TLV abstraction with .wireEncode method
size_t size() const
Get size of encoded wire, including Type-Length-Value.
element_const_iterator elements_end() const
Equivalent to elements().end()
Data & setSignatureValue(const Block &value)
Set SignatureValue.
const Signature & getSignature() const
Get Signature.
const Block & get(uint32_t type) const
Get the first sub element of specified TLV-TYPE.
element_const_iterator find(uint32_t type) const
Find the first sub element of specified TLV-TYPE.
void setValue(const Block &value)
Set SignatureValue.
Block makeBinaryBlock(uint32_t type, const uint8_t *value, size_t length)
Create a TLV block copying TLV-VALUE from raw buffer.
const Block & getInfo() const
Get SignatureInfo as wire format.
const Block & getValue() const
Get SignatureValue.
void reset()
Reset wire buffer of the element.
Represents an absolute name.
const Name & getFullName() const
Get full name including implicit digest.
Component holds a read-only name component value.
const MetaInfo & getMetaInfo() const
Get MetaInfo.
bool empty() const
Check if name is empty.
ConstBufferPtr computeDigest()
Finalize and return the digest based on all previously supplied inputs.
bool operator==(const Data &lhs, const Data &rhs)
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Fast encoding or block size estimation.
Data & setMetaInfo(const MetaInfo &metaInfo)
Set MetaInfo.
Data & setFinalBlockId(const name::Component &finalBlockId)
void wireDecode(const Block &wire)
Decode name from wire encoding.
a concept check for TLV abstraction with .wireEncode method
Represents a Data packet.
a concept check for TLV abstraction with .wireDecode method and constructible from Block ...
void clear()
Remove all components.
EncodingImpl< EncoderTag > EncodingBuffer
uint32_t type() const
Get TLV-TYPE.
Name & appendImplicitSha256Digest(const ConstBufferPtr &digest)
Append an ImplicitSha256Digest component.
EncodingImpl< EstimatorTag > EncodingEstimator
Holds SignatureInfo and SignatureValue in a Data packet.
shared_ptr< const Buffer > ConstBufferPtr