TLV encoder that accepts items in reverse order.
More...
#include <encoder.hpp>
Inherited by ndnph::ScopedEncoder.
|
| Encoder (uint8_t *buf, size_t capacity) |
| Create over given buffer.
|
|
| Encoder (Region ®ion) |
| Create over remaining space in a Region.
|
|
| operator bool () const |
| Return true if no errors were encountered, such as running out of space.
|
|
const uint8_t * | begin () const |
| Get output begin.
|
|
const uint8_t * | end () const |
| Get output end.
|
|
size_t | size () const |
| Get output size.
|
|
size_t | availableHeadroom () const |
| Get available headroom.
|
|
void | trim () const |
| Release unused space to the Region.
|
|
void | discard () |
| Release all space to the Region.
|
|
void | resetFront (uint8_t *pos) |
| Reset front to given position.
|
|
uint8_t * | prependRoom (size_t size) |
| Make room to prepend an object.
|
|
bool | prependTypeLength (uint32_t type, size_t length) |
| Prepend TLV-TYPE and TLV-LENGTH.
|
|
template<typename First , typename... Arg> |
bool | prepend (const First &first, const Arg &... arg) |
| Prepend a sequence of values.
|
|
template<typename... Arg> |
bool | prependTlv (uint32_t type, OmitEmptyTag omitEmpty, const Arg &... arg) |
| Prepend TLV, measuring TLV-LENGTH automatically.
|
|
template<typename First , typename... Arg> |
std::enable_if<!std::is_same< First, OmitEmptyTag >::value, bool >::type | prependTlv (uint32_t type, const First &first, const Arg &... arg) |
| Prepend TLV, measuring TLV-LENGTH automatically.
|
|
bool | prependTlv (uint32_t type) |
| Prepend TLV with zero TLV-LENGTH.
|
|
void | setError () |
| Indicate an error has occurred.
|
|
TLV encoder that accepts items in reverse order.
◆ OmitEmptyTag
Enumerator |
---|
NoOmitEmpty | |
OmitEmpty | |
◆ Encoder() [1/2]
ndnph::Encoder::Encoder |
( |
uint8_t * |
buf, |
|
|
size_t |
capacity |
|
) |
| |
|
inlineexplicit |
Create over given buffer.
◆ Encoder() [2/2]
ndnph::Encoder::Encoder |
( |
Region & |
region | ) |
|
|
inlineexplicit |
Create over remaining space in a Region.
After encoding, unused space can be released with trim().
◆ availableHeadroom()
size_t ndnph::Encoder::availableHeadroom |
( |
| ) |
const |
|
inline |
◆ begin()
const uint8_t * ndnph::Encoder::begin |
( |
| ) |
const |
|
inline |
◆ discard()
void ndnph::Encoder::discard |
( |
| ) |
|
|
inline |
Release all space to the Region.
- Postcondition
- Output is empty.
This function has no effect if Encoder was not created from a Region.
◆ end()
const uint8_t * ndnph::Encoder::end |
( |
| ) |
const |
|
inline |
◆ operator bool()
ndnph::Encoder::operator bool |
( |
| ) |
const |
|
inlineexplicit |
Return true if no errors were encountered, such as running out of space.
◆ prepend()
template<typename First , typename... Arg>
bool ndnph::Encoder::prepend |
( |
const First & |
first, |
|
|
const Arg &... |
arg |
|
) |
| |
|
inline |
Prepend a sequence of values.
- Template Parameters
-
First | either `[] (Encoder&) -> void {}` or a class with `void encoderTo(Encoder&) const {}` method. |
Arg | same as First. |
- Returns
- whether success.
◆ prependRoom()
uint8_t * ndnph::Encoder::prependRoom |
( |
size_t |
size | ) |
|
|
inline |
Make room to prepend an object.
- Returns
- room to write object.
- Return values
-
nullptr | no room available. |
◆ prependTlv() [1/3]
bool ndnph::Encoder::prependTlv |
( |
uint32_t |
type | ) |
|
|
inline |
Prepend TLV with zero TLV-LENGTH.
◆ prependTlv() [2/3]
template<typename First , typename... Arg>
std::enable_if<!std::is_same< First, OmitEmptyTag >::value, bool >::type ndnph::Encoder::prependTlv |
( |
uint32_t |
type, |
|
|
const First & |
first, |
|
|
const Arg &... |
arg |
|
) |
| |
|
inline |
Prepend TLV, measuring TLV-LENGTH automatically.
◆ prependTlv() [3/3]
template<typename... Arg>
bool ndnph::Encoder::prependTlv |
( |
uint32_t |
type, |
|
|
OmitEmptyTag |
omitEmpty, |
|
|
const Arg &... |
arg |
|
) |
| |
|
inline |
Prepend TLV, measuring TLV-LENGTH automatically.
- Template Parameters
-
Arg | same as arguments of prepend(). |
- Parameters
-
type | TLV-TYPE number. |
omitEmpty | if OmitEmpty, omit the TLV altogether if TLV-LENGTH is zero. |
arg | zero or more items in TLV-VALUE. |
- Returns
- whether success.
◆ prependTypeLength()
bool ndnph::Encoder::prependTypeLength |
( |
uint32_t |
type, |
|
|
size_t |
length |
|
) |
| |
|
inline |
Prepend TLV-TYPE and TLV-LENGTH.
- Returns
- whether success.
◆ resetFront()
void ndnph::Encoder::resetFront |
( |
uint8_t * |
pos | ) |
|
|
inline |
Reset front to given position.
◆ setError()
void ndnph::Encoder::setError |
( |
| ) |
|
|
inline |
Indicate an error has occurred.
◆ size()
size_t ndnph::Encoder::size |
( |
| ) |
const |
|
inline |
◆ trim()
void ndnph::Encoder::trim |
( |
| ) |
const |
|
inline |
Release unused space to the Region.
This function has no effect if Encoder was not created from a Region.
The documentation for this class was generated from the following file:
- /home/runner/work/esp8266ndn/NDNph/src/ndnph/tlv/encoder.hpp