24 #ifndef NDN_CXX_ENCODING_BLOCK_HPP 25 #define NDN_CXX_ENCODING_BLOCK_HPP 56 using tlv::Error::Error;
72 operator=(
const Block&);
81 operator=(
Block&&) noexcept;
90 Block(span<const uint8_t> buffer);
116 bool verifyLength =
true);
127 bool verifyLength =
true);
138 Buffer::const_iterator begin, Buffer::const_iterator end,
139 Buffer::const_iterator valueBegin, Buffer::const_iterator valueEnd);
145 Block(uint32_t type);
183 fromStream(std::istream& is);
213 resetWire() noexcept;
223 return m_buffer !=
nullptr && m_begin != m_end;
293 return m_buffer !=
nullptr;
323 return hasValue() ?
static_cast<size_t>(m_valueEnd - m_valueBegin) : 0;
333 return {m_valueBegin, m_valueEnd};
343 value()
const noexcept;
350 blockFromValue()
const;
374 get(uint32_t type)
const;
382 find(uint32_t type)
const;
389 remove(uint32_t type);
405 push_back(
const Block& element);
411 push_back(
Block&& element);
435 return m_elements.begin();
443 return m_elements.end();
451 return m_elements.size();
457 operator boost::asio::const_buffer()
const;
521 Block::Block(
Block&&) noexcept = default;
529 operator==(const
Block& lhs, const
Block& rhs);
534 return !(lhs == rhs);
551 operator ""_block(
const char* input,
std::size_t len);
555 #endif // NDN_CXX_ENCODING_BLOCK_HPP
shared_ptr< const Buffer > m_buffer
Underlying buffer storing TLV-VALUE and possibly TLV-TYPE and TLV-LENGTH fields.
Copyright (c) 2011-2015 Regents of the University of California.
Buffer::const_iterator m_valueBegin
Buffer::const_iterator m_begin
std::ostream & operator<<(std::ostream &os, const Face &face)
span_CONFIG_SIZE_TYPE size_t
const_iterator value_begin() const noexcept
Get begin iterator of TLV-VALUE.
element_container::const_iterator element_const_iterator
size_t value_size() const noexcept
Return the size of TLV-VALUE, i.e., the TLV-LENGTH.
element_container m_elements
Contains the sub-elements.
Represents a TLV element of the NDN packet format.
bool hasWire() const noexcept
Check if the Block contains a fully encoded wire representation.
element_const_iterator elements_begin() const
Equivalent to elements().begin()
const uint8_t * wire() const
const element_container & elements() const
Get container of sub-elements.
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
element_container::iterator element_iterator
Buffer::value_type value_type
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.
span< const uint8_t > value_bytes() const noexcept
Return a read-only view of TLV-VALUE as a contiguous range of bytes.
bool hasValue() const noexcept
Check if the Block has a non-empty TLV-VALUE.
uint32_t type() const noexcept
Return the TLV-TYPE of the Block.
Buffer::const_iterator m_end
span_constexpr std::size_t size(span< T, Extent > const &spn)
const_iterator value_end() const noexcept
Get end iterator of TLV-VALUE.
static ParseResult parse(const Data &data)
std::vector< Block > element_container
EncodingImpl< EncoderTag > EncodingBuffer
Buffer::const_iterator const_iterator
represents an error in TLV encoding or decoding
EncodingImpl< EstimatorTag > EncodingEstimator
shared_ptr< const Buffer > ConstBufferPtr