24 #ifndef NDN_CXX_ENCODING_BLOCK_HPP
25 #define NDN_CXX_ENCODING_BLOCK_HPP
88 Block(span<const uint8_t> buffer);
114 bool verifyLength = true);
125 bool verifyLength = true);
137 Buffer::const_iterator valueBegin,
Buffer::const_iterator valueEnd);
146 [[deprecated("use the constructor that takes a span<>")]]
147 Block(const uint8_t* buf,
size_t bufSize);
194 [[deprecated("use the
overload that takes a span<>")]]
196 fromBuffer(const uint8_t* buf,
size_t bufSize);
249 Buffer::const_iterator
255 Buffer::const_iterator
306 Buffer::const_iterator
315 Buffer::const_iterator
325 value() const noexcept;
434 operator boost::asio::const_buffer()
const;
506 operator==(const
Block& lhs, const
Block& rhs);
511 return !(lhs == rhs);
528 operator "" _block(
const char* input, std::size_t len);
#define NDN_CXX_NODISCARD
Represents a TLV element of the NDN packet format.
element_container::const_iterator element_const_iterator
size_t elements_size() const
Equivalent to elements().size()
const uint8_t * wire() const
Return a raw pointer to the beginning of the encoded wire.
element_const_iterator find(uint32_t type) const
Find the first sub-element of the specified TLV-TYPE.
uint32_t type() const
Return the TLV-TYPE of the Block.
Block blockFromValue() const
element_iterator erase(element_const_iterator position)
Erase a sub-element.
friend std::ostream & operator<<(std::ostream &os, const Block &block)
Print block to os.
Buffer::const_iterator begin() const
Get begin iterator of encoded wire.
void remove(uint32_t type)
Remove all sub-elements of the specified TLV-TYPE.
size_t size() const
Return the size of the encoded wire, i.e.
bool hasWire() const noexcept
Check if the Block contains a fully encoded wire representation.
Buffer::const_iterator end() const
Get end iterator of encoded wire.
size_t m_size
Total size including Type-Length-Value.
Buffer::const_iterator m_valueEnd
void resetWire() noexcept
Reset wire buffer but keep TLV-TYPE and sub-elements (if any)
element_container m_elements
Contains the sub-elements.
static std::tuple< bool, Block > fromBuffer(ConstBufferPtr buffer, size_t offset=0)
Try to parse Block from a wire buffer.
void push_back(const Block &element)
Append a sub-element.
Block(Block &&) noexcept
Move constructor.
Block & operator=(const Block &)
Copy assignment operator.
Buffer::const_iterator m_end
Buffer::const_iterator m_valueBegin
Block(const Block &)
Copy constructor.
Buffer::const_iterator value_end() const
Get end iterator of TLV-VALUE.
ConstBufferPtr getBuffer() const
Get underlying buffer.
bool hasValue() const noexcept
Check if the Block has a non-empty TLV-VALUE.
bool isValid() const noexcept
Check if the Block is valid.
element_container::iterator element_iterator
void encode()
Encode sub-elements into TLV-VALUE.
Buffer::const_iterator value_begin() const
Get begin iterator of TLV-VALUE.
element_const_iterator elements_end() const
Equivalent to elements().end()
element_const_iterator elements_begin() const
Equivalent to elements().begin()
static Block fromStream(std::istream &is)
Parse Block from an input stream.
void reset() noexcept
Reset the Block to a default-constructed state.
Buffer::const_iterator m_begin
shared_ptr< const Buffer > m_buffer
Underlying buffer storing TLV-VALUE and possibly TLV-TYPE and TLV-LENGTH fields.
std::vector< Block > element_container
const element_container & elements() const
Get container of sub-elements.
void parse() const
Parse TLV-VALUE into sub-elements.
const Block & get(uint32_t type) const
Return the first sub-element of the specified TLV-TYPE.
size_t value_size() const noexcept
Return the size of TLV-VALUE, aka TLV-LENGTH.
Block()
Create an invalid Block.
element_iterator insert(element_const_iterator pos, const Block &element)
Insert a sub-element.
const uint8_t * value() const noexcept
Return a raw pointer to the beginning of TLV-VALUE.
General-purpose automatically managed/resized buffer.
represents an error in TLV encoding or decoding
Error(const char *expectedType, uint32_t actualType)
EncodingImpl< EstimatorTag > EncodingEstimator
EncodingImpl< EncoderTag > EncodingBuffer
shared_ptr< const Buffer > ConstBufferPtr
constexpr detail::make_overload_t overload