22 #ifndef NDN_ENCODING_ENCODER_HPP 23 #define NDN_ENCODING_ENCODER_HPP 25 #include "../common.hpp" 79 template<
class Iterator>
86 template<
class Iterator>
249 block(
bool verifyLength =
true)
const;
252 shared_ptr<Buffer> m_buffer;
264 return m_end - m_begin;
267 inline shared_ptr<Buffer>
276 return m_buffer->size();
291 inline Buffer::const_iterator
297 inline Buffer::const_iterator
309 inline const uint8_t*
315 template<
class Iterator>
319 size_t length = std::distance(first, last);
323 std::copy(first, last, m_begin);
328 template<
class Iterator>
332 size_t length = std::distance(first, last);
335 std::copy(first, last, m_end);
344 #endif // NDN_ENCODING_ENCODER_HPP size_t prependByteArray(const uint8_t *array, size_t length)
Prepend a byte array array of length length.
void reserveFront(size_t size)
Reserve at least isze bytes at the beginning of the underlying buffer.
size_t appendVarNumber(uint64_t varNumber)
Prepend VarNumber varNumber of NDN TLV encoding.
iterator begin()
Get an iterator pointing to the first byte of the encoded buffer.
Copyright (c) 2011-2015 Regents of the University of California.
size_t appendRange(Iterator first, Iterator last)
Append range of bytes from the range [first, last)
size_t prependByte(uint8_t value)
Prepend a byte.
iterator end()
Get an iterator pointing to the past-the-end byte of the encoded buffer.
Class representing a wire element of NDN-TLV packet format.
void reserve(size_t size, bool addInFront)
Reserve size bytes for the underlying buffer.
Buffer::iterator iterator
Buffer::const_iterator const_iterator
Table::const_iterator iterator
void reserveBack(size_t size)
Reserve at least size bytes at the back of the underlying buffer.
size_t prependVarNumber(uint64_t varNumber)
Prepend VarNumber varNumber of NDN TLV encoding.
Block block(bool verifyLength=true) const
Create Block from the underlying buffer.
size_t prependBlock(const Block &block)
Prepend TLV block block.
size_t appendBlock(const Block &block)
Append TLV block block.
size_t prependRange(Iterator first, Iterator last)
Prepend range of bytes from the range [first, last)
Helper class to perform TLV encoding Interface of this class (mostly) matches interface of Estimator ...
shared_ptr< Buffer > getBuffer()
Get underlying buffer.
size_t appendByte(uint8_t value)
Append a byte.
size_t prependByteArrayBlock(uint32_t type, const uint8_t *array, size_t arraySize)
Prepend TLV block of type type and value from buffer array of size arraySize.
Encoder & operator=(const Encoder &)=delete
size_t appendByteArray(const uint8_t *array, size_t length)
Append a byte array array of length length.
uint8_t * buf()
Get a pointer to the first byte of the encoded buffer.
size_t prependNonNegativeInteger(uint64_t integer)
Prepend non-negative integer integer of NDN TLV encoding.
size_t size() const
Get size of the encoded buffer.
size_t appendByteArrayBlock(uint32_t type, const uint8_t *array, size_t arraySize)
Append TLV block of type type and value from buffer array of size arraySize.
size_t appendNonNegativeInteger(uint64_t integer)
Append non-negative integer integer of NDN TLV encoding.
Buffer::value_type value_type
Encoder(size_t totalReserve=MAX_NDN_PACKET_SIZE, size_t reserveFromBack=400)
Create instance of the encoder with the specified reserved sizes.
const size_t MAX_NDN_PACKET_SIZE
practical limit of network layer packet size
size_t capacity() const
Get size of the underlying buffer.