A DynamicUInt8ArrayLite holds a pointer to an allocated array, the length of the allocated array, and an optional realloc function which can changes its size.
More...
#include <dynamic-uint8-array-lite.hpp>
|
class | TcpTransportLite |
|
class | UdpTransportLite |
|
class | UnixTransportLite |
|
class | ArduinoYunTcpTransportLite |
|
class | Tlv0_1_1WireFormatLite |
|
A DynamicUInt8ArrayLite holds a pointer to an allocated array, the length of the allocated array, and an optional realloc function which can changes its size.
ndn::DynamicUInt8ArrayLite::DynamicUInt8ArrayLite |
( |
uint8_t * |
array, |
|
|
size_t |
length, |
|
|
ndn_ReallocFunction |
reallocFunction |
|
) |
| |
Create a DynamicUInt8ArrayLite with the given array buffer.
- Parameters
-
array | The allocated array buffer. It is the caller's responsibility to free this buffer if necessary when finished with it. |
length | The length of the allocated array buffer. |
reallocFunction | See ensureLength. This may be 0. |
ndn_Error ndn::DynamicUInt8ArrayLite::copy |
( |
const uint8_t * |
value, |
|
|
size_t |
valueLength, |
|
|
size_t |
offset |
|
) |
| |
Copy value into this object's array at offset, using ensureLength to make sure the array has enough length.
- Parameters
-
value | The buffer to copy from. |
valueLength | The length of the value buffer. |
offset | The offset in this object's array to copy to. |
- Returns
- 0 for success, else an error code if need to reallocate the array but can't.
ndn_Error ndn::DynamicUInt8ArrayLite::copyFromBack |
( |
const uint8_t * |
value, |
|
|
size_t |
valueLength, |
|
|
size_t |
offsetFromBack |
|
) |
| |
First call ensureLengthFromBack to make sure this object's array has offsetFromBack bytes.
Then copy value into this object's array starting offsetFromBack bytes from the back of the array.
- Parameters
-
value | The buffer to copy from. |
valueLength | The length of the value buffer. |
offsetFromBack | The offset from the back of the array to start copying. |
- Returns
- 0 for success, else an error code if need to reallocate the array but can't.
Downcast the reference to the ndn_DynamicUInt8ArrayLite struct to a DynamicUInt8ArrayLiteLite.
- Parameters
-
dynamicArray | A reference to the ndn_DynamicUInt8ArrayLite struct. |
- Returns
- The same reference as DynamicUInt8ArrayLiteLite.
ndn_Error ndn::DynamicUInt8ArrayLite::ensureLength |
( |
size_t |
length | ) |
|
Ensure that getLength() is greater than or equal to length.
If it is, just return 0 for success. Otherwise, if the reallocFunction given to the constructor is 0, then return an error. If not 0, call reallocFunction to reallocate this object's array, and update the getLength() (which may be greater than the given length).
- Parameters
-
- Returns
- 0 for success, else an error code if need to reallocate the array but can't.
ndn_Error ndn::DynamicUInt8ArrayLite::ensureLengthFromBack |
( |
size_t |
length | ) |
|
Ensure that getLength() is greater than or equal to the given length.
If it is, just return 0 for success. Otherwise, if the the reallocFunction given to the constructor is 0, then return an error. If not 0, call reallocFunction to reallocate this object's array, and update getLength() (which may be greater than the given length).
- Parameters
-
length | the needed minimum size for self->length |
- Returns
- 0 for success, else an error code if need to reallocate the array but can't.
uint8_t* ndn::DynamicUInt8ArrayLite::getArray |
( |
| ) |
|
|
inline |
Get the current allocated array.
- Returns
- The array.
size_t ndn::DynamicUInt8ArrayLite::getLength |
( |
| ) |
const |
|
inline |
Get the current length of the allocated array.
- Returns
- The array length.
The documentation for this class was generated from the following files: