24 #ifndef NDN_ENCODING_BLOCK_HPP 25 #define NDN_ENCODING_BLOCK_HPP 52 using tlv::Error::Error;
68 operator=(
const Block&);
77 operator=(
Block&&) noexcept;
104 bool verifyLength =
true);
114 Block(
const Block& block, Buffer::const_iterator begin, Buffer::const_iterator end,
115 bool verifyLength =
true);
126 Buffer::const_iterator begin, Buffer::const_iterator end,
127 Buffer::const_iterator valueBegin, Buffer::const_iterator valueEnd);
135 Block(
const uint8_t*
buf,
size_t bufSize);
141 Block(uint32_t type);
160 fromStream(std::istream& is);
179 fromBuffer(
const uint8_t* buf,
size_t bufSize);
222 resetWire() noexcept;
232 return m_buffer !=
nullptr && m_begin != m_end;
238 Buffer::const_iterator
244 Buffer::const_iterator
289 return m_buffer !=
nullptr;
295 Buffer::const_iterator
304 Buffer::const_iterator
314 value()
const noexcept;
320 value_size()
const noexcept;
323 blockFromValue()
const;
347 get(uint32_t type)
const;
355 find(uint32_t type)
const;
362 remove(uint32_t type);
377 push_back(
const Block& element);
401 return m_elements.begin();
409 return m_elements.end();
417 return m_elements.size();
423 operator boost::asio::const_buffer()
const;
487 Block::Block(
Block&&) noexcept = default;
495 operator==(const
Block& lhs, const
Block& rhs);
500 return !(lhs == rhs);
517 operator "" _block(
const char* input, std::size_t len);
521 #endif // NDN_ENCODING_BLOCK_HPP
shared_ptr< const Buffer > m_buffer
Underlying buffer storing TLV-VALUE and possibly TLV-TYPE and TLV-LENGTH fields.
Buffer::const_iterator m_valueBegin
Buffer::const_iterator m_begin
std::ostream & operator<<(std::ostream &os, const Data &data)
element_container::const_iterator element_const_iterator
element_container m_elements
Contains the sub-elements.
Represents a TLV element of NDN packet format.
bool hasWire() const noexcept
Check if the Block contains a fully encoded wire representation.
bool empty() const noexcept
Check if the Block is empty.
element_const_iterator elements_begin() const
Equivalent to elements().begin()
const element_container & elements() const
Get container of sub-elements.
Buffer::const_iterator value_begin() const
Get begin iterator of TLV-VALUE.
Buffer::const_iterator m_valueEnd
ConstBufferPtr getBuffer() const
Get underlying buffer.
element_const_iterator elements_end() const
Equivalent to elements().end()
#define NDN_CXX_NODISCARD
Buffer::const_iterator value_end() const
Get end iterator of TLV-VALUE.
element_container::iterator element_iterator
size_t elements_size() const
Equivalent to elements().size()
CFReleaser< CFStringRef > fromBuffer(const uint8_t *buf, size_t buflen)
Create a CFString by copying bytes from a raw buffer.
bool isValid() const noexcept
Check if the Block is valid.
bool hasValue() const noexcept
Check if the Block has a non-empty TLV-VALUE.
Buffer::const_iterator m_end
static ParseResult parse(const Data &data)
std::vector< Block > element_container
EncodingImpl< EncoderTag > EncodingBuffer
uint32_t type() const
Return the TLV-TYPE of the Block.
represents an error in TLV encoding or decoding
EncodingImpl< EstimatorTag > EncodingEstimator
shared_ptr< const Buffer > ConstBufferPtr