22 #ifndef NDN_ENCODING_ENCODER_HPP 23 #define NDN_ENCODING_ENCODER_HPP 65 template<
class Iterator>
72 template<
class Iterator>
235 size() const noexcept;
245 block(
bool verifyLength = true) const;
248 shared_ptr<
Buffer> m_buffer;
259 return m_end - m_begin;
262 inline shared_ptr<Buffer>
271 return m_buffer->size();
274 inline Buffer::iterator
280 inline Buffer::iterator
286 inline Buffer::const_iterator
292 inline Buffer::const_iterator
304 inline const uint8_t*
310 template<
class Iterator>
314 using ValueType =
typename std::iterator_traits<Iterator>::value_type;
315 static_assert(
sizeof(ValueType) == 1 && !std::is_same<ValueType, bool>::value,
"");
317 size_t length = std::distance(first, last);
321 std::copy(first, last, m_begin);
325 template<
class Iterator>
329 using ValueType =
typename std::iterator_traits<Iterator>::value_type;
330 static_assert(
sizeof(ValueType) == 1 && !std::is_same<ValueType, bool>::value,
"");
332 size_t length = std::distance(first, last);
335 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.
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.
size_t size() const noexcept
Get the size of the encoded buffer.
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.
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() const noexcept
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.
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 capacity() const noexcept
Get size of the underlying 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.
General-purpose automatically managed/resized buffer.
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