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

Name. More...

#include <name.hpp>

Inherits ndnph::Printable.

Classes

class  Iterator
 Iterator over name components. More...
 

Public Types

enum  CompareResult {
  CMP_LT = -2 , CMP_LPREFIX = -1 , CMP_EQUAL = 0 , CMP_RPREFIX = +1 ,
  CMP_GT = +2
}
 Name compare result. More...
 

Public Member Functions

 Name (const uint8_t *value=nullptr, size_t length=0)
 Construct referencing TLV-VALUE.
 
template<typename It >
 Name (Region &region, It first, It last)
 Construct from TLV-VALUE.
 
 Name (Region &region, std::initializer_list< uint8_t > value)
 Construct from TLV-VALUE.
 
 operator bool () const
 Return true if Name is non-empty.
 
size_t length () const
 
const uint8_t * value () const
 
size_t size () const
 Get number of components.
 
Iterator begin () const
 
Iterator end () const
 
Component operator[] (int i) const
 Access i-th component.
 
Name slice (int first=0, int last=0) const
 Get sub name [first, last).
 
Name getPrefix (int n=0) const
 Get prefix of n components.
 
template<typename... C>
Name append (Region &region, const C &... comps) const
 Append a sequence of components.
 
Name clone (Region &region) const
 Clone TLV-VALUE into given region.
 
CompareResult compare (const Name &other) const
 Compare with other name.
 
bool isPrefixOf (const Name &other) const
 Determine if this name is a prefix of other.
 
void encodeTo (Encoder &encoder) const
 
bool decodeFrom (const Decoder::Tlv &d)
 
size_t printTo (::Print &p) const final
 Print name as URI.
 
- Public Member Functions inherited from ndnph::Printable
 operator Esp32Printable () const
 

Static Public Member Functions

static Name parse (Region &region, const char *uri)
 Parse from URI.
 

Detailed Description

Name.

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

Member Enumeration Documentation

◆ CompareResult

Name compare result.

Enumerator
CMP_LT 

lhs is less than, but not a prefix of rhs

CMP_LPREFIX 

lhs is a prefix of rhs

CMP_EQUAL 

lhs and rhs are equal

CMP_RPREFIX 

rhs is a prefix of lhs

CMP_GT 

rhs is less than, but not a prefix of lhs

Constructor & Destructor Documentation

◆ Name() [1/3]

ndnph::Name::Name ( const uint8_t *  value = nullptr,
size_t  length = 0 
)
inlineexplicit

Construct referencing TLV-VALUE.

◆ Name() [2/3]

template<typename It >
ndnph::Name::Name ( Region region,
It  first,
It  last 
)
inlineexplicit

Construct from TLV-VALUE.

◆ Name() [3/3]

ndnph::Name::Name ( Region region,
std::initializer_list< uint8_t >  value 
)
inlineexplicit

Construct from TLV-VALUE.

Member Function Documentation

◆ append()

template<typename... C>
Name ndnph::Name::append ( Region region,
const C &...  comps 
) const
inline

Append a sequence of components.

Parameters
compsa mix of Components and Convention+argument pairs.
Returns
new Name that copies TLV-VALUE of this name and all components.
Return values
Name()any Component is invalid or allocation error.

If you need to append multiple components, it's recommended to append them all at once, so that memory allocation and copying occur only once.

Name segmentName = prefix.append(filename, convention::Segment(), 5);
Name.
Definition name.hpp:14
Name append(Region &region, const C &... comps) const
Append a sequence of components.
Definition name.hpp:183
Definition convention.hpp:111

◆ begin()

Iterator ndnph::Name::begin ( ) const
inline

◆ clone()

Name ndnph::Name::clone ( Region region) const
inline

Clone TLV-VALUE into given region.

Returns
new Name that does not reference memory of this Name, or invalid Name if allocation fails.

◆ compare()

CompareResult ndnph::Name::compare ( const Name other) const
inline

Compare with other name.

◆ decodeFrom()

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

◆ encodeTo()

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

◆ end()

Iterator ndnph::Name::end ( ) const
inline

◆ getPrefix()

Name ndnph::Name::getPrefix ( int  n = 0) const
inline

Get prefix of n components.

Parameters
nnumber of component; if non-positive, count from end.

◆ isPrefixOf()

bool ndnph::Name::isPrefixOf ( const Name other) const
inline

Determine if this name is a prefix of other.

◆ length()

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

◆ operator bool()

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

Return true if Name is non-empty.

◆ operator[]()

Component ndnph::Name::operator[] ( int  i) const
inline

Access i-th component.

◆ parse()

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

Parse from URI.

Parameters
regionmemory region; must have 2*strlen(uri) available room.
uriURI in canonical format; scheme and authority must be omitted; `8=` prefix of GenericNameComponent may be omitted.
Returns
name; it's valid if !name 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.

◆ printTo()

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

Print name as URI.

Implements ndnph::Printable.

◆ size()

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

Get number of components.

◆ slice()

Name ndnph::Name::slice ( int  first = 0,
int  last = 0 
) const
inline

Get sub name [first, last).

Parameters
firstinclusive first component index; if negative, count from end.
lastexclusive last component index; if non-positive, count from end.

◆ value()

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

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