24 #ifndef NDN_ENCODING_BLOCK_HPP 25 #define NDN_ENCODING_BLOCK_HPP 52 using tlv::Error::Error;
76 operator=(
Block&&) noexcept;
103 bool verifyLength = true);
114 bool verifyLength = true);
126 Buffer::const_iterator valueBegin,
Buffer::const_iterator valueEnd);
134 Block(const uint8_t* buf,
size_t bufSize);
167 static std::tuple<
bool,
Block>
177 static std::tuple<
bool,
Block>
178 fromBuffer(const uint8_t* buf,
size_t bufSize);
189 return m_type == std::numeric_limits<uint32_t>::max();
216 Buffer::const_iterator
222 Buffer::const_iterator
239 shared_ptr<const Buffer>
268 Buffer::const_iterator
277 Buffer::const_iterator
393 operator boost::asio::const_buffer()
const;
429 uint32_t
m_type = std::numeric_limits<uint32_t>::max();
465 operator==(const
Block& lhs, const
Block& rhs);
470 return !(lhs == rhs);
487 operator "" _block(
const char* input, std::size_t len);
491 #endif // NDN_ENCODING_BLOCK_HPP
size_t m_size
total size including Type-Length-Value
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.
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
friend std::ostream & operator<<(std::ostream &os, const Block &block)
Print block to os.
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.
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.
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()
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.
Block & operator=(const Block &)
Copy assignment operator.
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 remove(uint32_t type)
Remove all sub elements of specified TLV-TYPE.
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 hasValue() const
Get begin iterator of TLV-VALUE.
Block()
Create an empty Block.
General-purpose automatically managed/resized buffer.
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