22 #ifndef NDN_ENCODING_ENCODER_HPP 23 #define NDN_ENCODING_ENCODER_HPP 78 template<
class Iterator>
85 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 using ValueType =
typename std::iterator_traits<Iterator>::value_type;
319 static_assert(
sizeof(ValueType) == 1 && !std::is_same<ValueType, bool>::value,
"");
321 size_t length = std::distance(first, last);
325 std::copy(first, last, m_begin);
330 template<
class Iterator>
334 using ValueType =
typename std::iterator_traits<Iterator>::value_type;
335 static_assert(
sizeof(ValueType) == 1 && !std::is_same<ValueType, bool>::value,
"");
337 size_t length = std::distance(first, last);
340 std::copy(first, last, m_end);
349 #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.
Represents a TLV element of NDN packet format.
void reserve(size_t size, bool addInFront)
Reserve size bytes for the underlying buffer.
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.
Buffer::iterator iterator
Buffer::value_type value_type
Buffer::const_iterator const_iterator
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.
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.