esp8266ndn
NDN Arduino library for ESP8266 and more
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | List of all members
ndnph::Component Class Reference

Name component. More...

#include <component.hpp>

Inherits ndnph::Printable.

Public Member Functions

 Component ()=default
 
 Component (Region &region, uint16_t type, size_t length, const uint8_t *value)
 Construct from T-L-V. More...
 
 Component (Region &region, size_t length, const uint8_t *value)
 Construct GenericNameComponent from L-V. More...
 
 Component (uint8_t *buf, size_t bufLen, uint16_t type, size_t length, const uint8_t *value, bool writeFromBack=false)
 Construct from T-L-V into provided buffer. More...
 
 operator bool () const
 Return true if Component is valid. More...
 
uint16_t type () const
 
size_t length () const
 
const uint8_t * value () const
 
const uint8_t * tlv () const
 
size_t size () const
 
void encodeTo (Encoder &encoder) const
 
bool decodeFrom (const Decoder::Tlv &d)
 
size_t printTo (::Print &p) const final
 
template<typename Convention >
bool is () const
 
template<typename Convention , typename... Arg>
auto as (Arg &&... arg) const -> decltype(Convention::parse(*this, std::forward< Arg >(arg)...))
 
- Public Member Functions inherited from ndnph::Printable
 operator Esp32Printable () const
 

Static Public Member Functions

static Component constant (const uint8_t *tlv, size_t size)
 Construct from const TLV buffer. More...
 
template<typename... Arg>
static Component from (Region &region, uint16_t type, const Arg &... arg)
 Construct from TLV-TYPE, and several arguments to be encoded to TLV-VALUE. More...
 
static Component parse (Region &region, const char *uri)
 Parse from URI. More...
 
static Component parse (Region &region, const char *uri, size_t uriLen)
 
static Component parse (uint8_t *buf, size_t bufLen, const char *uri)
 Parse from URI into provided buffer. More...
 
static Component parse (uint8_t *buf, size_t bufLen, const char *uri, size_t uriLen, bool writeFromBack=false)
 

Detailed Description

Name component.

This type is immutable, except `decodeFrom()` method.

Constructor & Destructor Documentation

◆ Component() [1/4]

ndnph::Component::Component ( )
explicitdefault

◆ Component() [2/4]

ndnph::Component::Component ( Region region,
uint16_t  type,
size_t  length,
const uint8_t *  value 
)
inlineexplicit

Construct from T-L-V.

◆ Component() [3/4]

ndnph::Component::Component ( Region region,
size_t  length,
const uint8_t *  value 
)
inlineexplicit

Construct GenericNameComponent from L-V.

◆ Component() [4/4]

ndnph::Component::Component ( uint8_t *  buf,
size_t  bufLen,
uint16_t  type,
size_t  length,
const uint8_t *  value,
bool  writeFromBack = false 
)
inlineexplicit

Construct from T-L-V into provided buffer.

Parameters
bufbuffer for writing TLV.
bufLensize of buf; if insufficient, !component will be true.
typeTLV-TYPE
lengthTLV-LENGTH
valueTLV-VALUE, may overlap with buf
writeFromBackwrite TLV from back of provided buffer instead of from front.

Member Function Documentation

◆ as()

template<typename Convention , typename... Arg>
auto ndnph::Component::as ( Arg &&...  arg) const -> decltype(Convention::parse(*this, std::forward<Arg>(arg)...))
inline

◆ constant()

static Component ndnph::Component::constant ( const uint8_t *  tlv,
size_t  size 
)
inlinestatic

Construct from const TLV buffer.

◆ decodeFrom()

bool ndnph::Component::decodeFrom ( const Decoder::Tlv d)
inline

◆ encodeTo()

void ndnph::Component::encodeTo ( Encoder encoder) const
inline

◆ from()

template<typename... Arg>
static Component ndnph::Component::from ( Region region,
uint16_t  type,
const Arg &...  arg 
)
inlinestatic

Construct from TLV-TYPE, and several arguments to be encoded to TLV-VALUE.

Template Parameters
Argany Encodable type.

◆ is()

template<typename Convention >
bool ndnph::Component::is ( ) const
inline

◆ length()

size_t ndnph::Component::length ( ) const
inline

◆ operator bool()

ndnph::Component::operator bool ( ) const
inlineexplicit

Return true if Component is valid.

◆ parse() [1/4]

static Component ndnph::Component::parse ( Region region,
const char *  uri 
)
inlinestatic

Parse from URI.

Parameters
regionmemory region; must have 8 + strlen(uri) available room.
uriURI in canonical format; except that `8=` prefix of GenericNameComponent may be omitted.
Returns
component; it's valid if !component is false.
Note
This is a not-so-strict parser. It lets some invalid inputs slip through in exchange for smaller code size. Not recommended on untrusted input.

◆ parse() [2/4]

static Component ndnph::Component::parse ( Region region,
const char *  uri,
size_t  uriLen 
)
inlinestatic

◆ parse() [3/4]

static Component ndnph::Component::parse ( uint8_t *  buf,
size_t  bufLen,
const char *  uri 
)
inlinestatic

Parse from URI into provided buffer.

◆ parse() [4/4]

static Component ndnph::Component::parse ( uint8_t *  buf,
size_t  bufLen,
const char *  uri,
size_t  uriLen,
bool  writeFromBack = false 
)
inlinestatic

◆ printTo()

size_t ndnph::Component::printTo ( ::Print &  p) const
inlinefinalvirtual

Implements ndnph::Printable.

◆ size()

size_t ndnph::Component::size ( ) const
inline

◆ tlv()

const uint8_t* ndnph::Component::tlv ( ) const
inline

◆ type()

uint16_t ndnph::Component::type ( ) const
inline

◆ value()

const uint8_t* ndnph::Component::value ( ) const
inline

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