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);
97 Data::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>& encoder,
98 bool unsignedPortion)
const;
101 Data::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>& encoder,
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;
336 return !(*
this == other);
342 os <<
"Name: " << data.
getName() <<
"\n";
bool empty() const
Check if the Block is empty.
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)
Data()
Create an empty Data object.
Data & setSignature(const Signature &signature)
Set the signature to a copy of the given signature.
EncodingImpl< EstimatorTag > EncodingEstimator
element_const_iterator find(uint32_t type) const
Data & setName(const Name &name)
Set name to a copy of the given Name.
std::ostream & operator<<(std::ostream &os, const Data &data)
void setInfo(const Block &info)
Set SignatureInfo from a block.
Data & setContent(const uint8_t *buffer, size_t bufferSize)
Set the content from the buffer (buffer will be copied)
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Fast encoding or block size estimation.
Class representing a wire element of NDN-TLV packet format.
const Block & getValue() const
Get SignatureValue in the wire format.
const MetaInfo & getMetaInfo() const
Get MetaInfo block from Data packet.
bool operator!=(const Data &other) const
Data & setFreshnessPeriod(const time::milliseconds &freshnessPeriod)
const Name & getName() const
Get name of the Data packet.
element_const_iterator elements_end() const
void onChanged()
Clear the wire encoding.
uint32_t getType() const
Get signature type.
a concept check for TLV abstraction with .wireEncode method
Data & setSignatureValue(const Block &value)
EncodingImpl< EncoderTag > EncodingBuffer
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 & get(uint32_t type) const
Get the first subelement of the requested type.
element_container::const_iterator element_const_iterator
void reset()
Reset wire buffer of the element.
Name abstraction to represent an absolute name.
size_t value_size() const
const Block & wireEncode() const
Encode to a wire format.
void parse() const
Parse wire buffer into subblocks.
const Signature & getSignature() const
Component holds a read-only name component value.
const Block & getInfo() const
Get SignatureInfo in the wire format.
void encode()
Encode subblocks into wire buffer.
const Block & getContent() const
Get content Block.
bool operator==(const Data &other) const
const uint8_t * wire() const
bool empty() const
Check if name is emtpy.
bool hasWire() const
Check if the Block has fully encoded wire.
Data & setMetaInfo(const MetaInfo &metaInfo)
Set metaInfo to a copy of the given MetaInfo.
Data & setIncomingFaceId(uint64_t incomingFaceId)
shared_ptr< const Buffer > ConstBufferPtr
ConstBufferPtr sha256(const uint8_t *data, size_t dataLength)
Compute the sha-256 digest of data.
const Name & getFullName() const
Get full name of Data packet, including the implicit digest.
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.
nfd::LocalControlHeader & getLocalControlHeader()
A Signature is storage for the signature-related information (info and value) in a Data packet...
Data & setCachingPolicy(nfd::LocalControlHeader::CachingPolicy cachingPolicy)
Name & appendImplicitSha256Digest(const ConstBufferPtr &digest)
Append ImplicitSha256Digest.