Class representing a wire element of NDN-TLV packet format. More...
#include <block.hpp>
Data Structures | |
class | Error |
Public Types | |
typedef std::vector< Block > | element_container |
typedef element_container::iterator | element_iterator |
typedef element_container::const_iterator | element_const_iterator |
Public Member Functions | |
Block () | |
Create an empty Block. More... | |
Block (const EncodingBuffer &buffer) | |
Create a Block based on EncodingBuffer object. More... | |
Block (const ConstBufferPtr &buffer) | |
Create a Block from the raw buffer with Type-Length parsing. More... | |
Block (const ConstBufferPtr &buffer, const Buffer::const_iterator &begin, const Buffer::const_iterator &end, bool verifyLength=true) | |
Create a Block from a buffer, directly specifying boundaries of the block within the buffer. More... | |
Block (const Block &block, const Buffer::const_iterator &begin, const Buffer::const_iterator &end, bool verifyLength=true) | |
Create a Block from existing block (reusing the underlying buffer), directly specifying boundaries of the block within the buffer. More... | |
Block (const uint8_t *buffer, size_t maxlength) | |
Create a Block from the raw buffer with Type-Length parsing. More... | |
Block (const void *buffer, size_t maxlength) | |
Create a Block from the raw buffer with Type-Length parsing. More... | |
Block (const ConstBufferPtr &wire, uint32_t type, const Buffer::const_iterator &begin, const Buffer::const_iterator &end, const Buffer::const_iterator &valueBegin, const Buffer::const_iterator &valueEnd) | |
Create a Block from the wire buffer (no parsing) More... | |
Block (uint32_t type) | |
Create Block of a specific type with empty wire buffer. More... | |
Block (uint32_t type, const ConstBufferPtr &value) | |
Create a Block of a specific type with the specified value. More... | |
Block (uint32_t type, const Block &value) | |
Create a nested Block of a specific type with the specified value. More... | |
bool | empty () const |
Check if the Block is empty. More... | |
bool | hasWire () const |
Check if the Block has fully encoded wire. More... | |
void | reset () |
Reset wire buffer of the element. More... | |
void | resetWire () |
Reset wire buffer but keep sub elements (if any) More... | |
Buffer::const_iterator | begin () const |
Buffer::const_iterator | end () const |
const uint8_t * | wire () const |
size_t | size () const |
uint32_t | type () const |
bool | hasValue () const |
Check if the Block has value block (no type and length are encoded) More... | |
Buffer::const_iterator | value_begin () const |
Buffer::const_iterator | value_end () const |
const uint8_t * | value () const |
size_t | value_size () const |
void | parse () const |
Parse wire buffer into subblocks. More... | |
void | encode () |
Encode subblocks into wire buffer. More... | |
const Block & | get (uint32_t type) const |
Get the first subelement of the requested type. More... | |
element_const_iterator | find (uint32_t type) const |
void | remove (uint32_t type) |
remove all subelements of type More... | |
element_iterator | erase (element_const_iterator position) |
element_iterator | erase (element_const_iterator first, element_const_iterator last) |
void | push_back (const Block &element) |
element_iterator | insert (element_const_iterator pos, const Block &element) |
insert Insert a new element in a specific position More... | |
const element_container & | elements () const |
Get all subelements. More... | |
element_const_iterator | elements_begin () const |
element_const_iterator | elements_end () const |
size_t | elements_size () const |
Block | blockFromValue () const |
shared_ptr< const Buffer > | getBuffer () const |
Get underlying buffer. More... | |
bool | operator== (const Block &other) const |
bool | operator!= (const Block &other) const |
operator boost::asio::const_buffer () const | |
Static Public Member Functions | |
static Block | fromStream (std::istream &is) |
Create a Block from an input stream. More... | |
static std::tuple< bool, Block > | fromBuffer (ConstBufferPtr buffer, size_t offset) |
Try to construct block from Buffer. More... | |
static std::tuple< bool, Block > | fromBuffer (const uint8_t *buffer, size_t maxSize) |
Try to construct block from raw buffer. More... | |
Protected Attributes | |
shared_ptr< const Buffer > | m_buffer |
uint32_t | m_type |
Buffer::const_iterator | m_begin |
Buffer::const_iterator | m_end |
uint32_t | m_size |
Buffer::const_iterator | m_value_begin |
Buffer::const_iterator | m_value_end |
element_container | m_subBlocks |
Class representing a wire element of NDN-TLV packet format.
typedef element_container::const_iterator ndn::Block::element_const_iterator |
typedef std::vector<Block> ndn::Block::element_container |
typedef element_container::iterator ndn::Block::element_iterator |
|
explicit |
|
explicit |
ndn::Block::Block | ( | const ConstBufferPtr & | buffer, |
const Buffer::const_iterator & | begin, | ||
const Buffer::const_iterator & | end, | ||
bool | verifyLength = true |
||
) |
ndn::Block::Block | ( | const Block & | block, |
const Buffer::const_iterator & | begin, | ||
const Buffer::const_iterator & | end, | ||
bool | verifyLength = true |
||
) |
ndn::Block::Block | ( | const uint8_t * | buffer, |
size_t | maxlength | ||
) |
ndn::Block::Block | ( | const void * | buffer, |
size_t | maxlength | ||
) |
ndn::Block::Block | ( | const ConstBufferPtr & | wire, |
uint32_t | type, | ||
const Buffer::const_iterator & | begin, | ||
const Buffer::const_iterator & | end, | ||
const Buffer::const_iterator & | valueBegin, | ||
const Buffer::const_iterator & | valueEnd | ||
) |
|
explicit |
ndn::Block::Block | ( | uint32_t | type, |
const ConstBufferPtr & | value | ||
) |
ndn::Block::Block | ( | uint32_t | type, |
const Block & | value | ||
) |
|
inline |
Block::element_const_iterator ndn::Block::elements_begin | ( | ) | const |
Block::element_const_iterator ndn::Block::elements_end | ( | ) | const |
bool ndn::Block::empty | ( | ) | const |
void ndn::Block::encode | ( | ) |
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 |
|
static |
Try to construct block from Buffer.
buffer | the buffer to construct block from |
offset | offset from beginning of buffer to construct Block from |
This method does not throw upon decoding error. This method does not copy the bytes.
|
static |
Try to construct block from raw buffer.
buffer | the raw buffer to copy bytes from |
maxSize | the maximum size of constructed block; buffer must have a size of at least maxSize |
This method does not throw upon decoding error. This method copies the bytes into a new Buffer.
|
static |
const Block & ndn::Block::get | ( | uint32_t | type | ) | const |
|
inline |
bool ndn::Block::hasValue | ( | ) | const |
bool ndn::Block::hasWire | ( | ) | const |
Block::element_iterator ndn::Block::insert | ( | Block::element_const_iterator | pos, |
const Block & | element | ||
) |
void ndn::Block::parse | ( | ) | const |
void ndn::Block::remove | ( | uint32_t | type | ) |
void ndn::Block::reset | ( | ) |
void ndn::Block::resetWire | ( | ) |
|
inline |
|
inline |
|
mutableprotected |
|
protected |