13 #include "../common.hpp"
70 const Buffer::const_iterator&
begin,
const Buffer::const_iterator&
end,
71 bool verifyLength =
true);
77 Block(
const uint8_t* buffer,
size_t maxlength);
79 Block(
const void* buffer,
size_t maxlength);
85 Block(std::istream& is);
94 const Buffer::const_iterator&
begin,
const Buffer::const_iterator&
end,
95 const Buffer::const_iterator& valueBegin,
const Buffer::const_iterator& valueEnd);
194 get(uint32_t
type)
const;
200 remove(uint32_t
type);
211 Buffer::const_iterator
214 Buffer::const_iterator
223 Buffer::const_iterator
226 Buffer::const_iterator
283 return m_type == std::numeric_limits<uint32_t>::max();
305 m_type = std::numeric_limits<uint32_t>::max();
332 if (i->type() ==
type)
338 throw Error(
"(Block::get) Requested a non-existed type [" +
339 boost::lexical_cast<std::string>(type) +
"] from Block");
349 if (i->type() ==
type)
368 if (i->type() !=
type)
369 newContainer.push_back(*i);
396 inline Buffer::const_iterator
400 throw Error(
"Underlying wire buffer is empty");
405 inline Buffer::const_iterator
409 throw Error(
"Underlying wire buffer is empty");
421 throw Error(
"Block size cannot be determined (undefined block size)");
424 inline Buffer::const_iterator
430 inline Buffer::const_iterator
436 inline const uint8_t*
440 throw Error(
"(Block::wire) Underlying wire buffer is empty");
445 inline const uint8_t*
490 return (this->
size() == other.
size()) &&
504 #endif // NDN_BLOCK_HPP
bool empty() const
Check if the Block is empty.
bool operator!=(const Block &other) const
bool hasValue() const
Check if the Block has value block (no type and length are encoded)
Error(const std::string &what)
Buffer::const_iterator end() const
Buffer::const_iterator m_begin
element_const_iterator find(uint32_t type) const
EncodingImpl< true > EncodingBuffer
element_container::iterator element_iterator
const element_container & elements() const
Get all subelements.
Class representing wire element of the NDN packet.
Buffer::const_iterator value_begin() const
Buffer::const_iterator value_end() const
void resetWire()
Reset wire buffer but keep sub elements (if any)
element_const_iterator elements_end() const
element_const_iterator elements_begin() const
ptr_lib::shared_ptr< const Buffer > ConstBufferPtr
Buffer::const_iterator m_value_end
Block blockFromValue() const
const Block & get(uint32_t type) const
Get the first subelement of the requested type.
element_container::const_iterator element_const_iterator
size_t elements_size() const
void remove(uint32_t type)
void reset()
Reset wire buffer of the element.
void push_back(const Block &element)
size_t value_size() const
void parse() const
Parse wire buffer into subblocks.
std::vector< Block > element_container
void encode()
Encode subblocks into wire buffer.
const uint8_t * wire() const
element_container m_subBlocks
Buffer::const_iterator m_end
bool hasWire() const
Check if the Block has fully encoded wire.
static bool fromBuffer(const ConstBufferPtr &wire, size_t offset, Block &block)
Try to construct block from Buffer, referencing data block pointed by wire.
const uint8_t * value() const
bool operator==(const Block &other) const
Buffer::const_iterator m_value_begin
Block()
Default constructor to create an empty Block.
element_iterator erase(element_iterator position)
Error that can be thrown from Block.
Buffer::const_iterator begin() const