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");
50 template<encoding::Tag TAG>
54 size_t totalLength = 0;
64 if (!unsignedPortion && !m_signature)
66 BOOST_THROW_EXCEPTION(
Error(
"Requested wire format, but data packet has not been signed yet"));
72 totalLength += encoder.prependBlock(m_signature.
getValue());
76 totalLength += encoder.prependBlock(m_signature.
getInfo());
79 totalLength += encoder.prependBlock(
getContent());
89 totalLength += encoder.prependVarNumber(totalLength);
90 totalLength += encoder.prependVarNumber(
tlv::Data);
98 bool unsignedPortion)
const;
102 bool unsignedPortion)
const;
108 size_t totalLength = encoder.
size();
109 totalLength += encoder.appendBlock(signatureValue);
111 encoder.prependVarNumber(totalLength);
181 if (m_fullName.
empty()) {
183 BOOST_THROW_EXCEPTION(
Error(
"Full name requested, but Data packet does not have wire format " 184 "(e.g., not signed)"));
197 m_metaInfo = metaInfo;
232 if (m_content.
empty())
278 m_signature = signature;
316 return !(*
this == other);
322 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.
void wireDecode(const Block &wire)
Decode from the wire format.
Block makeEmptyBlock(uint32_t type)
Create a TLV block type type containing no value (i.e., a boolean block)
const Block & getContent() const
Get content Block.
Data()
Create an empty Data object.
Data & setSignature(const Signature &signature)
Set the signature to a copy of the given signature.
EncodingImpl< EstimatorTag > EncodingEstimator
Data & setName(const Name &name)
Set name to a copy of the given Name.
size_t value_size() const
const Name & getName() const
Get name of the Data packet.
std::ostream & operator<<(std::ostream &os, const Data &data)
void setInfo(const Block &info)
Set SignatureInfo from a block.
element_const_iterator elements_end() const
const uint8_t * wire() const
Data & setContent(const uint8_t *buffer, size_t bufferSize)
Set the content from the buffer (buffer will be copied)
void parse() const
Parse wire buffer into subblocks.
Class representing a wire element of NDN-TLV packet format.
bool operator!=(const Data &other) const
bool operator==(const Data &other) const
Data & setFreshnessPeriod(const time::milliseconds &freshnessPeriod)
void onChanged()
Clear the wire encoding.
bool empty() const
Check if the Block is empty.
a concept check for TLV abstraction with .wireEncode method
Data & setSignatureValue(const Block &value)
const Block & get(uint32_t type) const
Get the first subelement of the requested type.
EncodingImpl< EncoderTag > EncodingBuffer
element_const_iterator find(uint32_t type) const
void setValue(const Block &value)
Get SignatureValue from a block.
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.
const Block & getInfo() const
Get SignatureInfo in the wire format.
const Block & getValue() const
Get SignatureValue in the wire format.
const MetaInfo & getMetaInfo() const
Get MetaInfo block from Data packet.
element_container::const_iterator element_const_iterator
void reset()
Reset wire buffer of the element.
Name abstraction to represent an absolute name.
const Name & getFullName() const
Get full name of Data packet, including the implicit digest.
Component holds a read-only name component value.
void encode()
Encode subblocks into wire buffer.
ConstBufferPtr computeSha256Digest(const uint8_t *data, size_t dataLength)
Compute the sha-256 digest of data.
bool empty() const
Check if name is emtpy.
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Fast encoding or block size estimation.
Data & setMetaInfo(const MetaInfo &metaInfo)
Set metaInfo to a copy of the given MetaInfo.
uint32_t getType() const
Get signature type.
const Signature & getSignature() const
shared_ptr< const Buffer > ConstBufferPtr
Data & setFinalBlockId(const name::Component &finalBlockId)
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.
A Signature is storage for the signature-related information (info and value) in a Data packet...
Name & appendImplicitSha256Digest(const ConstBufferPtr &digest)
Append ImplicitSha256Digest.