24 #ifndef NDN_ENCODING_BLOCK_HPP 25 #define NDN_ENCODING_BLOCK_HPP 89 bool verifyLength =
true);
100 bool verifyLength =
true);
111 Buffer::const_iterator
begin, Buffer::const_iterator
end,
112 Buffer::const_iterator valueBegin, Buffer::const_iterator valueEnd);
120 Block(
const uint8_t* buf,
size_t bufSize);
153 static std::tuple<bool, Block>
163 static std::tuple<bool, Block>
164 fromBuffer(
const uint8_t* buf,
size_t bufSize);
175 return m_type == std::numeric_limits<uint32_t>::max();
202 Buffer::const_iterator
208 Buffer::const_iterator
225 shared_ptr<const Buffer>
254 Buffer::const_iterator
263 Buffer::const_iterator
304 get(uint32_t
type)
const;
318 remove(uint32_t
type);
379 operator boost::asio::const_buffer()
const;
433 return !(lhs == rhs);
438 #endif // NDN_ENCODING_BLOCK_HPP
shared_ptr< const Buffer > m_buffer
underlying buffer storing TLV-VALUE and possibly TLV-TYPE and TLV-LENGTH fields
bool hasWire() const
Check if the Block has fully encoded wire.
static Block fromStream(std::istream &is)
Parse Block from an input stream.
Copyright (c) 2011-2015 Regents of the University of California.
Error(const std::string &what)
static std::tuple< bool, Block > fromBuffer(ConstBufferPtr buffer, size_t offset)
Try to parse Block from a wire buffer.
Buffer::const_iterator m_valueBegin
Buffer::const_iterator m_begin
size_t value_size() const
Get size of TLV-VALUE aka TLV-LENGTH.
element_container::const_iterator element_const_iterator
const uint8_t * wire() const
Get pointer to encoded wire.
void parse() const
Parse TLV-VALUE into sub elements.
element_container m_elements
sub elements
Represents a TLV element of NDN packet format.
element_const_iterator elements_begin() const
Equivalent to elements().begin()
element_iterator insert(element_const_iterator pos, const Block &element)
Insert a sub element.
const uint8_t * value() const
Get pointer to TLV-VALUE.
bool operator!=(const Data &lhs, const Data &rhs)
element_iterator erase(element_const_iterator position)
Erase a sub element.
void resetWire()
Reset wire buffer but keep TLV-TYPE and sub elements (if any)
const element_container & elements() const
Get container of sub elements.
uint32_t m_size
total size including Type-Length-Value
Buffer::const_iterator value_begin() const
Get begin iterator of TLV-VALUE.
Table::const_iterator iterator
Buffer::const_iterator m_valueEnd
shared_ptr< const Buffer > getBuffer() const
Get underlying buffer.
bool empty() const
Check if the Block is empty.
size_t size() const
Get size of encoded wire, including Type-Length-Value.
element_const_iterator elements_end() const
Equivalent to elements().end()
element_const_iterator find(uint32_t type) const
Find the first sub element of specified TLV-TYPE.
Buffer::const_iterator value_end() const
Get end iterator of TLV-VALUE.
Buffer::const_iterator begin() const
Get begin iterator of encoded wire.
element_container::iterator element_iterator
void reset()
Reset wire buffer of the element.
void push_back(const Block &element)
Append a sub element.
Buffer::const_iterator end() const
Get end iterator of encoded wire.
size_t elements_size() const
Equivalent to elements().size()
void encode()
Encode sub elements into TLV-VALUE.
Block blockFromValue() const
Buffer::const_iterator m_end
bool operator==(const Data &lhs, const Data &rhs)
bool hasValue() const
Get begin iterator of TLV-VALUE.
Block()
Create an empty Block.
std::vector< Block > element_container
EncodingImpl< EncoderTag > EncodingBuffer
uint32_t type() const
Get TLV-TYPE.
represents an error in TLV encoding or decoding
EncodingImpl< EstimatorTag > EncodingEstimator
shared_ptr< const Buffer > ConstBufferPtr