Public Member Functions | List of all members
ndn::DynamicUInt8Vector Class Reference

A DynamicUInt8Vector extends ndn_DynamicUInt8Array to hold a shared_ptr<vector<uint8_t> > for use with C functions which need an ndn_DynamicUInt8Array. More...

#include <dynamic-uint8-vector.hpp>

Inheritance diagram for ndn::DynamicUInt8Vector:
ndn_DynamicUInt8Array

Public Member Functions

 DynamicUInt8Vector (size_t initialLength)
 Create a new DynamicUInt8Vector with an initial length. More...
 
void ensureLength (size_t length)
 Ensure that the vector size is greater than or equal to length. More...
 
size_t copy (const uint8_t *value, size_t valueLength, size_t offset)
 Copy value into the vector at offset, using ensureLength to make sure the vector has enough size. More...
 
size_t copy (const std::vector< uint8_t > &value, size_t offset)
 Copy value into the vector at offset, using ensureLength to make sure the vector has enough size. More...
 
void ensureLengthFromBack (size_t length)
 Ensure that the vector size is greater than or equal to length. More...
 
void copyFromBack (const uint8_t *value, size_t valueLength, size_t offsetFromBack)
 First call ensureLengthFromBack to make sure the vector has offsetFromBack bytes. More...
 
ptr_lib::shared_ptr< std::vector< uint8_t > > & get ()
 Get the shared_ptr to the allocated vector. More...
 
Blob finish (size_t size)
 Resize the allocated vector to the given size, transfer the bytes to a Blob and return the Blob. More...
 
uint8_t & operator[] (size_t i)
 
const uint8_t & operator[] (size_t i) const
 

Additional Inherited Members

- Public Attributes inherited from ndn_DynamicUInt8Array
uint8_t * array
 the allocated array buffer
 
size_t length
 the length of the allocated array buffer
 
ndn_ReallocFunction realloc
 a pointer to a function that reallocates array and returns a new pointer to a buffer of length bytes, or 0 for error. More...
 

Detailed Description

A DynamicUInt8Vector extends ndn_DynamicUInt8Array to hold a shared_ptr<vector<uint8_t> > for use with C functions which need an ndn_DynamicUInt8Array.

Constructor & Destructor Documentation

ndn::DynamicUInt8Vector::DynamicUInt8Vector ( size_t  initialLength)

Create a new DynamicUInt8Vector with an initial length.

Parameters
initialLengthThe initial size of the allocated vector.

Member Function Documentation

size_t ndn::DynamicUInt8Vector::copy ( const uint8_t *  value,
size_t  valueLength,
size_t  offset 
)
inline

Copy value into the vector at offset, using ensureLength to make sure the vector has enough size.

Parameters
valueThe buffer to copy from.
valueLengthThe length of the value buffer.
offsetThe offset in the vector to copy to.
Returns
The new offset which is offset + valueLength.
size_t ndn::DynamicUInt8Vector::copy ( const std::vector< uint8_t > &  value,
size_t  offset 
)
inline

Copy value into the vector at offset, using ensureLength to make sure the vector has enough size.

Parameters
valueThe buffer to copy from.
offsetThe offset in the vector to copy to.
Returns
The new offset which is offset + value.size().
void ndn::DynamicUInt8Vector::copyFromBack ( const uint8_t *  value,
size_t  valueLength,
size_t  offsetFromBack 
)
inline

First call ensureLengthFromBack to make sure the vector has offsetFromBack bytes.

Then copy value into the vector starting offsetFromBack bytes from the back of the vector.

Parameters
valueThe buffer to copy from.
valueLengthThe length of the value buffer.
offsetFromBackThe offset from the back of the array to start copying.
void ndn::DynamicUInt8Vector::ensureLength ( size_t  length)
inline

Ensure that the vector size is greater than or equal to length.

If it is, just return. Otherwise, resize the vector (copying as needed). (The new vector size may be greater than length.)

Parameters
lengthThe minimum size of the vector.
void ndn::DynamicUInt8Vector::ensureLengthFromBack ( size_t  length)
inline

Ensure that the vector size is greater than or equal to length.

If it is, just return. Otherwise, resize the vector and shift existing data to the back. (The new vector size may be greater than length.)

Parameters
lengthThe minimum size of the vector.
Blob ndn::DynamicUInt8Vector::finish ( size_t  size)
inline

Resize the allocated vector to the given size, transfer the bytes to a Blob and return the Blob.

Further calls to get() will return a null pointer.

Parameters
sizeThe final size of the allocated vector.
Returns
A new Blob with the bytes from the vector.
ptr_lib::shared_ptr<std::vector<uint8_t> >& ndn::DynamicUInt8Vector::get ( )
inline

Get the shared_ptr to the allocated vector.

Returns
The shared_ptr to the allocated vector.

The documentation for this class was generated from the following files: