Represents a TLV element of NDN packet format. More...
#include <ndn-cxx/encoding/block.hpp>
 Inheritance diagram for ndn::Block:
 Inheritance diagram for ndn::Block: Collaboration diagram for ndn::Block:
 Collaboration diagram for ndn::Block:| Classes | |
| class | Error | 
| Public Types | |
| using | element_const_iterator = element_container::const_iterator | 
| using | element_container = std::vector< Block > | 
| using | element_iterator = element_container::iterator | 
| Public Member Functions | |
| Block () | |
| Create an invalid Block.  More... | |
| Block (const Block &) | |
| Copy constructor.  More... | |
| Block (Block &&) noexcept | |
| Move constructor.  More... | |
| Block (const EncodingBuffer &buffer) | |
| Parse Block from an EncodingBuffer.  More... | |
| Block (const ConstBufferPtr &buffer) | |
| Parse Block from a wire Buffer.  More... | |
| Block (ConstBufferPtr buffer, Buffer::const_iterator begin, Buffer::const_iterator end, bool verifyLength=true) | |
| Parse Block within boundaries of a wire Buffer.  More... | |
| Block (const Block &block, Buffer::const_iterator begin, Buffer::const_iterator end, bool verifyLength=true) | |
| Parse Block within boundaries of an existing Block, reusing underlying wire Buffer.  More... | |
| Block (ConstBufferPtr buffer, uint32_t type, Buffer::const_iterator begin, Buffer::const_iterator end, Buffer::const_iterator valueBegin, Buffer::const_iterator valueEnd) | |
| Create a Block from a wire Buffer without parsing.  More... | |
| Block (const uint8_t *buf, size_t bufSize) | |
| Parse Block from a raw buffer.  More... | |
| Block (uint32_t type) | |
| Create a zero-length Block with the specified TLV-TYPE.  More... | |
| Block (uint32_t type, ConstBufferPtr value) | |
| Create a Block with the specified TLV-TYPE and TLV-VALUE.  More... | |
| Block (uint32_t type, const Block &value) | |
| Create a Block with the specified TLV-TYPE and TLV-VALUE.  More... | |
| Buffer::const_iterator | begin () const | 
| Get begin iterator of encoded wire.  More... | |
| Block | blockFromValue () const | 
| const element_container & | elements () const | 
| Get container of sub-elements.  More... | |
| element_const_iterator | elements_begin () const | 
| Equivalent to elements().begin()  More... | |
| element_const_iterator | elements_end () const | 
| Equivalent to elements().end()  More... | |
| size_t | elements_size () const | 
| Equivalent to elements().size()  More... | |
| bool | empty () const noexcept | 
| Check if the Block is empty.  More... | |
| void | encode () | 
| Encode sub-elements into TLV-VALUE.  More... | |
| Buffer::const_iterator | end () const | 
| Get end iterator of encoded wire.  More... | |
| element_iterator | erase (element_const_iterator position) | 
| Erase a sub-element.  More... | |
| element_iterator | erase (element_const_iterator first, element_const_iterator last) | 
| Erase a range of sub-elements.  More... | |
| element_const_iterator | find (uint32_t type) const | 
| Find the first sub-element of the specified TLV-TYPE.  More... | |
| const Block & | get (uint32_t type) const | 
| Return the first sub-element of the specified TLV-TYPE.  More... | |
| ConstBufferPtr | getBuffer () const | 
| Get underlying buffer.  More... | |
| bool | hasValue () const noexcept | 
| Check if the Block has a non-empty TLV-VALUE.  More... | |
| bool | hasWire () const noexcept | 
| Check if the Block contains a fully encoded wire representation.  More... | |
| element_iterator | insert (element_const_iterator pos, const Block &element) | 
| Insert a sub-element.  More... | |
| bool | isValid () const noexcept | 
| Check if the Block is valid.  More... | |
| operator boost::asio::const_buffer () const | |
| Implicit conversion to boost::asio::const_bufferMore... | |
| Block & | operator= (const Block &) | 
| Copy assignment operator.  More... | |
| Block & | operator= (Block &&) noexcept | 
| Move assignment operator.  More... | |
| void | parse () const | 
| Parse TLV-VALUE into sub-elements.  More... | |
| void | push_back (const Block &element) | 
| Append a sub-element.  More... | |
| void | remove (uint32_t type) | 
| Remove all sub-elements of the specified TLV-TYPE.  More... | |
| void | reset () noexcept | 
| Reset the Block to a default-constructed state.  More... | |
| void | resetWire () noexcept | 
| Reset wire buffer but keep TLV-TYPE and sub-elements (if any)  More... | |
| size_t | size () const | 
| Return the size of the encoded wire, i.e.  More... | |
| uint32_t | type () const | 
| Return the TLV-TYPE of the Block.  More... | |
| const uint8_t * | value () const noexcept | 
| Return a raw pointer to the beginning of TLV-VALUE.  More... | |
| Buffer::const_iterator | value_begin () const | 
| Get begin iterator of TLV-VALUE.  More... | |
| Buffer::const_iterator | value_end () const | 
| Get end iterator of TLV-VALUE.  More... | |
| size_t | value_size () const noexcept | 
| Return the size of TLV-VALUE, aka TLV-LENGTH.  More... | |
| const uint8_t * | wire () const | 
| Return a raw pointer to the beginning of the encoded wire.  More... | |
| Static Public Member Functions | |
| static std::tuple< bool, Block > | fromBuffer (ConstBufferPtr buffer, size_t offset) | 
| Try to parse Block from a wire buffer.  More... | |
| static std::tuple< bool, Block > | fromBuffer (const uint8_t *buf, size_t bufSize) | 
| Try to parse Block from a raw buffer.  More... | |
| static Block | fromStream (std::istream &is) | 
| Parse Block from an input stream.  More... | |
| Protected Attributes | |
| Buffer::const_iterator | m_begin | 
| shared_ptr< const Buffer > | m_buffer | 
| Underlying buffer storing TLV-VALUE and possibly TLV-TYPE and TLV-LENGTH fields.  More... | |
| element_container | m_elements | 
| Contains the sub-elements.  More... | |
| Buffer::const_iterator | m_end | 
| size_t | m_size = 0 | 
| Total size including Type-Length-Value.  More... | |
| uint32_t | m_type = tlv::Invalid | 
| TLV-TYPE.  More... | |
| Buffer::const_iterator | m_valueBegin | 
| Buffer::const_iterator | m_valueEnd | 
| Friends | |
| std::ostream & | operator<< (std::ostream &os, const Block &block) | 
| Print blocktoos.  More... | |
Represents a TLV element of NDN packet format.
| using ndn::Block::element_const_iterator = element_container::const_iterator | 
| using ndn::Block::element_container = std::vector<Block> | 
| using ndn::Block::element_iterator = element_container::iterator | 
| 
 | default | 
Copy constructor.
| 
 | inlinedefaultnoexcept | 
Move constructor.
| 
 | explicit | 
Parse Block from an EncodingBuffer.
| buffer | an EncodingBuffer containing one TLV element | 
| tlv::Error | Type-Length parsing fails, or TLV-LENGTH does not match size of TLV-VALUE | 
| 
 | explicit | 
| ndn::Block::Block | ( | ConstBufferPtr | buffer, | 
| Buffer::const_iterator | begin, | ||
| Buffer::const_iterator | end, | ||
| bool | verifyLength = true | ||
| ) | 
Parse Block within boundaries of a wire Buffer.
| buffer | a Buffer containing a TLV element at [ begin,end) | 
| begin | begin position of the TLV element within buffer | 
| end | end position of the TLV element within buffer | 
| verifyLength | if true, check TLV-LENGTH equals size of TLV-VALUE | 
| std::invalid_argument | bufferis empty, or [begin,end) range is not withinbuffer | 
| tlv::Error | Type-Length parsing fails, or TLV-LENGTH does not match size of TLV-VALUE | 
| ndn::Block::Block | ( | const Block & | block, | 
| Buffer::const_iterator | begin, | ||
| Buffer::const_iterator | end, | ||
| bool | verifyLength = true | ||
| ) | 
Parse Block within boundaries of an existing Block, reusing underlying wire Buffer.
| block | a Block whose buffer contains a TLV element at [ begin,end) | 
| begin | begin position of the TLV element within block | 
| end | end position of the TLV element within block | 
| verifyLength | if true, check TLV-LENGTH equals size of TLV-VALUE | 
| std::invalid_argument | [ begin,end) range is not withinblock | 
| tlv::Error | Type-Length parsing fails, or TLV-LENGTH does not match size of TLV-VALUE | 
| ndn::Block::Block | ( | ConstBufferPtr | buffer, | 
| uint32_t | type, | ||
| Buffer::const_iterator | begin, | ||
| Buffer::const_iterator | end, | ||
| Buffer::const_iterator | valueBegin, | ||
| Buffer::const_iterator | valueEnd | ||
| ) | 
Create a Block from a wire Buffer without parsing.
| buffer | a Buffer containing a TLV element at [ begin,end) | 
| type | TLV-TYPE | 
| begin | begin position of the TLV element within buffer | 
| end | end position of the TLV element within buffer | 
| valueBegin | begin position of TLV-VALUE within buffer | 
| valueEnd | end position of TLV-VALUE within buffer | 
| ndn::Block::Block | ( | const uint8_t * | buf, | 
| size_t | bufSize | ||
| ) | 
Parse Block from a raw buffer.
| buf | pointer to the first octet of a TLV element | 
| bufSize | size of the raw buffer; may be greater than the actual size of the TLV element | 
| tlv::Error | Type-Length parsing fails, or size of TLV-VALUE exceeds bufSize | 
| 
 | explicit | 
| ndn::Block::Block | ( | uint32_t | type, | 
| ConstBufferPtr | value | ||
| ) | 
| ndn::Block::Block | ( | uint32_t | type, | 
| const Block & | value | ||
| ) | 
| Buffer::const_iterator ndn::Block::begin | ( | ) | const | 
| 
 | inline | 
| 
 | inline | 
Equivalent to elements().begin()
| 
 | inline | 
Equivalent to elements().end()
| 
 | inline | 
Equivalent to elements().size()
| 
 | inlinenoexcept | 
| void ndn::Block::encode | ( | ) | 
Encode sub-elements into TLV-VALUE.
| Buffer::const_iterator ndn::Block::end | ( | ) | const | 
| Block::element_iterator ndn::Block::erase | ( | Block::element_const_iterator | position | ) | 
| Block::element_iterator ndn::Block::erase | ( | Block::element_const_iterator | first, | 
| Block::element_const_iterator | last | ||
| ) | 
| Block::element_const_iterator ndn::Block::find | ( | uint32_t | type | ) | const | 
Find the first sub-element of the specified TLV-TYPE.
| 
 | static | 
| 
 | static | 
Try to parse Block from a raw buffer.
| buf | pointer to the first octet of a TLV element | 
| bufSize | size of the raw buffer; may be greater than the actual size of the TLV element | 
| 
 | static | 
Parse Block from an input stream.
| tlv::Error | TLV-LENGTH is zero or exceeds upper bound | 
| const Block & ndn::Block::get | ( | uint32_t | type | ) | const | 
Return the first sub-element of the specified TLV-TYPE.
| tlv::Error | a sub-element of the specified type does not exist | 
| 
 | inline | 
| 
 | inlinenoexcept | 
Check if the Block has a non-empty TLV-VALUE.
This property reflects whether the underlying buffer contains a TLV-VALUE. If this is false, TLV-VALUE has zero-length. If this is true, TLV-VALUE may be zero-length.
| 
 | inlinenoexcept | 
| Block::element_iterator ndn::Block::insert | ( | Block::element_const_iterator | pos, | 
| const Block & | element | ||
| ) | 
Insert a sub-element.
| pos | position of the new sub-element | 
| element | new sub-element to insert | 
| 
 | inlinenoexcept | 
| ndn::Block::operator boost::asio::const_buffer | ( | ) | const | 
| void ndn::Block::parse | ( | ) | const | 
Parse TLV-VALUE into sub-elements.
| tlv::Error | TLV-VALUE is not a sequence of TLV elements | 
| void ndn::Block::push_back | ( | const Block & | element | ) | 
| void ndn::Block::remove | ( | uint32_t | type | ) | 
Remove all sub-elements of the specified TLV-TYPE.
find(type) == elements_end() | 
 | noexcept | 
| 
 | noexcept | 
Reset wire buffer but keep TLV-TYPE and sub-elements (if any)
hasWire() == false hasValue() == false | size_t ndn::Block::size | ( | ) | const | 
Return the size of the encoded wire, i.e.
of the whole TLV
isValid() == true | 
 | inline | 
Return the TLV-TYPE of the Block.
| 
 | noexcept | 
| 
 | inline | 
Get begin iterator of TLV-VALUE.
hasValue() == true | 
 | inline | 
Get end iterator of TLV-VALUE.
hasValue() == true | 
 | noexcept | 
| const uint8_t * ndn::Block::wire | ( | ) | const | 
| 
 | friend | 
Print block to os. 
Default-constructed Block is printed as: [invalid]. Zero-length Block is printed as: TT[empty], where TT is TLV-TYPE in decimal. Non-zero-length Block on which parse() has not been called is printed as: TT[LL]=VVVV, where LL is TLV-LENGTH in decimal, and VVVV is TLV-VALUE in hexadecimal. Block on which parse() has been called is printed as: TT[LL]={SUB,SUB}, where each SUB is a sub-element printed using this format. 
| 
 | protected | 
| 
 | protected | 
Underlying buffer storing TLV-VALUE and possibly TLV-TYPE and TLV-LENGTH fields.
If m_buffer is nullptr, this is an invalid or zero-length Block with TLV-TYPE given in m_type. Otherwise,
| 
 | mutableprotected | 
| 
 | protected | 
| 
 | protected | 
| 
 | protected | 
| 
 | protected |