22 #ifndef NDN_ENCODING_ENCODER_HPP 23 #define NDN_ENCODING_ENCODER_HPP 25 #include "../common.hpp" 45 Encoder(
size_t totalReserve = 8800,
size_t reserveFromBack = 400);
79 template<
class Iterator>
86 template<
class Iterator>
248 block(
bool verifyLength =
true)
const;
251 shared_ptr<Buffer> m_buffer;
263 return m_end - m_begin;
266 inline shared_ptr<Buffer>
275 return m_buffer->size();
290 inline Buffer::const_iterator
296 inline Buffer::const_iterator
308 inline const uint8_t*
314 template<
class Iterator>
318 size_t length = std::distance(first, last);
322 std::copy(first, last, m_begin);
327 template<
class Iterator>
331 size_t length = std::distance(first, last);
334 std::copy(first, last, m_end);
343 #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 capacity() const
Get size of the underlying buffer.
size_t size() const
Get size of the encoded buffer.
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.
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.
Block block(bool verifyLength=true) const
Create Block from the 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 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=8800, size_t reserveFromBack=400)
Create instance of the encoder with the specified reserved sizes.