22 #ifndef NDN_CXX_ENCODING_ENCODER_HPP 23 #define NDN_CXX_ENCODING_ENCODER_HPP 55 template<
class Iterator>
62 template<
class Iterator>
154 return m_buffer->size();
227 return static_cast<size_t>(std::distance(m_begin, m_end));
238 block(
bool verifyLength =
true)
const;
241 shared_ptr<Buffer> m_buffer;
249 template<
class Iterator>
253 using ValueType =
typename std::iterator_traits<Iterator>::value_type;
256 size_t length = std::distance(first, last);
259 std::advance(m_begin, -length);
260 std::copy(first, last, m_begin);
264 template<
class Iterator>
268 using ValueType =
typename std::iterator_traits<Iterator>::value_type;
271 size_t length = std::distance(first, last);
274 std::copy(first, last, m_end);
275 std::advance(m_end, length);
282 #endif // NDN_CXX_ENCODING_ENCODER_HPP void reserveFront(size_t size)
Reserve at least isze bytes at the beginning of the underlying buffer.
Copyright (c) 2011-2015 Regents of the University of California.
iterator begin() noexcept
Returns 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 prependBytes(span< const uint8_t > bytes)
Prepend a sequence of bytes.
const uint8_t * data() const noexcept
Returns a pointer to the first byte of the encoded buffer.
Represents a TLV element of the NDN packet format.
void reserve(size_t size, bool addInFront)
Reserve size bytes for the underlying buffer.
size_t prependVarNumber(uint64_t number)
Prepend number encoded as a VAR-NUMBER in NDN-TLV format.
const_iterator begin() const noexcept
Returns an iterator pointing to the first byte of the encoded buffer.
uint8_t * data() noexcept
Returns a pointer to the first byte of the encoded buffer.
size_t size() const noexcept
Returns the size of the encoded buffer.
void reserveBack(size_t size)
Reserve at least size bytes at the back of the underlying buffer.
Block block(bool verifyLength=true) const
Create Block from the underlying buffer.
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.
shared_ptr< Buffer > getBuffer() const noexcept
Get underlying buffer.
iterator end() noexcept
Returns an iterator pointing to the past-the-end byte of the encoded buffer.
size_t capacity() const noexcept
Get size of the underlying buffer.
const_iterator end() const noexcept
Returns an iterator pointing to the past-the-end byte of the encoded buffer.
size_t prependNonNegativeInteger(uint64_t integer)
Prepend integer encoded as a NonNegativeInteger in NDN-TLV format.
size_t appendNonNegativeInteger(uint64_t integer)
Append integer encoded as a NonNegativeInteger in NDN-TLV format.
size_t appendVarNumber(uint64_t number)
Append number encoded as a VAR-NUMBER in NDN-TLV format.
Encoder(size_t totalReserve=MAX_NDN_PACKET_SIZE, size_t reserveFromBack=400)
Create instance of the encoder with the specified reserved sizes.
size_t appendBytes(span< const uint8_t > bytes)
Append a sequence of bytes.
const size_t MAX_NDN_PACKET_SIZE
Practical size limit of a network-layer packet.