A TlvEncoder extends a C ndn_TlvEncoder struct and wraps related functions.
More...
#include <tlv-encoder.hpp>
|
| | TlvEncoder (size_t initialLength=16) |
| | Initialize the base ndn_TlvEncoder struct with the initialLength. More...
|
| |
| Blob | finish () |
| | Resize the output vector to the correct encoding length, transfer the bytes to a Blob and return the Blob. More...
|
| |
|
void | writeTypeAndLength (unsigned int type, size_t length) |
| |
|
void | writeNonNegativeInteger (uint64_t value) |
| |
|
void | writeBlobTlv (unsigned int type, struct ndn_Blob *value) |
| |
| void | writeRawStringTlv (unsigned int type, const std::string &value) |
| | Call writeBlobTlv using the raw string bytes. More...
|
| |
|
void | writeNonNegativeIntegerTlv (unsigned int type, uint64_t value) |
| |
|
void | writeNestedTlv (unsigned int type, ndn_Error(*writeValue)(const void *context, struct ndn_TlvEncoder *encoder), const void *context, bool omitZeroLength=false) |
| |
| void | writeNestedTlv (unsigned int type, void(*writeValue)(const void *context, TlvEncoder &encoder), const void *context, bool omitZeroLength=false) |
| | Call writeNestedTlv so that it calls writeValue(context, *this). More...
|
| |
A TlvEncoder extends a C ndn_TlvEncoder struct and wraps related functions.
| ndn::TlvEncoder::TlvEncoder |
( |
size_t |
initialLength = 16 | ) |
|
|
inline |
Initialize the base ndn_TlvEncoder struct with the initialLength.
Use simpleRealloc.
- Parameters
-
| initialLength | The initial size of the output. If omitted, use 16. |
| Blob ndn::TlvEncoder::finish |
( |
| ) |
|
|
inline |
Resize the output vector to the correct encoding length, transfer the bytes to a Blob and return the Blob.
This clear the internal pointer to the output vector, and further calls to write to it will throw an exception.
- Parameters
-
| size | The final size of the allocated vector. |
- Returns
- A new Blob with the bytes from the vector.
| void ndn::TlvEncoder::writeNestedTlv |
( |
unsigned int |
type, |
|
|
void(*)(const void *context, TlvEncoder &encoder) |
writeValue, |
|
|
const void * |
context, |
|
|
bool |
omitZeroLength = false |
|
) |
| |
|
inline |
Call writeNestedTlv so that it calls writeValue(context, *this).
- Parameters
-
| type | The TLV type for writeNestedTlv. |
| writeValue | The callback to write the TLV value. This calls writeValue(context, *this). |
| context | The context to pass to writeValue. |
| omitZeroLength | The omitZeroLength flag for writeNestedTlv. |
| void ndn::TlvEncoder::writeRawStringTlv |
( |
unsigned int |
type, |
|
|
const std::string & |
value |
|
) |
| |
|
inline |
Call writeBlobTlv using the raw string bytes.
- Parameters
-
| type | The type of the TLV. |
| value | The raw string. |
The documentation for this class was generated from the following file: