22 #ifndef NDN_CXX_ENCODING_ENCODER_HPP 
   23 #define NDN_CXX_ENCODING_ENCODER_HPP 
   56   [[deprecated(
"use prependBytes()")]]
 
   67   [[deprecated(
"use appendBytes()")]]
 
   78   [[deprecated(
"use prependBytes()")]]
 
   89   [[deprecated(
"use appendBytes()")]]
 
   99   template<
class Iterator>
 
  106   template<
class Iterator>
 
  142   [[deprecated(
"use encoding::prependBinaryBlock()")]]
 
  158   [[deprecated(
"use encoding::prependBlock()")]]
 
  230     return m_buffer->size();
 
  300   [[deprecated(
"use data()")]]
 
  310   [[deprecated(
"use data()")]]
 
  323     return static_cast<size_t>(std::distance(m_begin, m_end));
 
  334   block(
bool verifyLength = 
true) 
const;
 
  337   shared_ptr<Buffer> m_buffer;
 
  345 template<
class Iterator>
 
  349   using ValueType = 
typename std::iterator_traits<Iterator>::value_type;
 
  350   static_assert(
sizeof(ValueType) == 1 && !std::is_same<ValueType, bool>::value, 
"");
 
  352   size_t length = std::distance(first, last);
 
  355   std::advance(m_begin, -length);
 
  356   std::copy(first, last, m_begin);
 
  360 template<
class Iterator>
 
  364   using ValueType = 
typename std::iterator_traits<Iterator>::value_type;
 
  365   static_assert(
sizeof(ValueType) == 1 && !std::is_same<ValueType, bool>::value, 
"");
 
  367   size_t length = std::distance(first, last);
 
  370   std::copy(first, last, m_end);
 
  371   std::advance(m_end, length);
 
Represents a TLV element of the NDN packet format.
 
Helper class to perform TLV encoding.
 
void reserve(size_t size, bool addInFront)
Reserve size bytes for the underlying buffer.
 
size_t size() const noexcept
Returns the size of the encoded buffer.
 
Encoder(size_t totalReserve=MAX_NDN_PACKET_SIZE, size_t reserveFromBack=400)
Create instance of the encoder with the specified reserved sizes.
 
Buffer::value_type value_type
 
size_t appendBytes(span< const uint8_t > bytes)
Append a sequence of bytes.
 
const_iterator end() const noexcept
Returns an iterator pointing to the past-the-end byte of the encoded buffer.
 
void reserveFront(size_t size)
Reserve at least isze bytes at the beginning of the underlying buffer.
 
size_t appendByte(uint8_t value)
Append a byte.
 
Buffer::const_iterator const_iterator
 
Block block(bool verifyLength=true) const
Create Block from the underlying buffer.
 
shared_ptr< Buffer > getBuffer() const noexcept
Get underlying buffer.
 
const uint8_t * buf() const noexcept
 
size_t prependBytes(span< const uint8_t > bytes)
Prepend a sequence of bytes.
 
size_t capacity() const noexcept
Get size of the underlying buffer.
 
size_t prependRange(Iterator first, Iterator last)
Prepend range of bytes from the range [first, last)
 
size_t prependByteArray(const uint8_t *array, size_t length)
Prepend a byte array array of length length.
 
iterator begin() noexcept
Returns an iterator pointing to the first byte of the encoded buffer.
 
size_t prependVarNumber(uint64_t number)
Prepend number encoded as a VAR-NUMBER in NDN-TLV format.
 
size_t prependNonNegativeInteger(uint64_t integer)
Prepend integer encoded as a NonNegativeInteger in NDN-TLV format.
 
Buffer::iterator iterator
 
const_iterator begin() const noexcept
Returns an iterator pointing to the first byte 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 prependByte(uint8_t value)
Prepend a byte.
 
const uint8_t * data() const noexcept
Returns a pointer to the first byte of the encoded buffer.
 
size_t appendBlock(const Block &block)
Append TLV block block.
 
size_t appendNonNegativeInteger(uint64_t integer)
Append integer encoded as a NonNegativeInteger in NDN-TLV format.
 
size_t appendRange(Iterator first, Iterator last)
Append range of bytes from the range [first, last)
 
size_t appendVarNumber(uint64_t number)
Append number encoded as a VAR-NUMBER in NDN-TLV format.
 
size_t appendByteArray(const uint8_t *array, size_t length)
Append a byte array array of length length.
 
void reserveBack(size_t size)
Reserve at least size bytes at the back of the underlying buffer.
 
uint8_t * data() noexcept
Returns a pointer to the first byte of the encoded buffer.
 
size_t prependBlock(const Block &block)
Prepend TLV block block.
 
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.
 
iterator end() noexcept
Returns an iterator pointing to the past-the-end byte of the encoded buffer.
 
const size_t MAX_NDN_PACKET_SIZE
Practical size limit of a network-layer packet.