|
ndn-embeds 0.1.0
Lightweight NDN protocol stack for embedded systems
|
#include <ndn/name.hpp>
Public Member Functions | |
| Name ()=default | |
| Default constructor. | |
| uint32_t | hash () const |
| Compute hash value of the Name. | |
Conversion methods | |
| size_t | toUri (char *buf, size_t bufSize) const |
| Convert the Name to a URI string. | |
| Error | encode (uint8_t *buf, size_t bufSize, size_t &encodedLen) const |
| Encode the Name to TLV wire format. | |
Component operations | |
| size_t | componentCount () const |
| Get the number of components. | |
| NameComponent | component (size_t index) const |
| Get the component at a given index. | |
| Error | appendComponent (std::string_view comp) |
| Append a string component. | |
| Error | appendComponent (const uint8_t *value, size_t len) |
| Append a binary component. | |
Comparison methods | |
| int | compare (const Name &other) const |
| Compare with another Name. | |
| bool | equals (const Name &other) const |
| Check equality with another Name. | |
| bool | isPrefixOf (const Name &other) const |
| Check if this Name is a prefix of another Name. | |
State inspection | |
| bool | empty () const |
| Check if the Name is empty. | |
| const uint8_t * | wireValue () const |
| Get pointer to the internal buffer. | |
| size_t | wireLength () const |
| Get the length of the internal buffer. | |
Static Public Member Functions | |
Construction methods | |
| static Result< Name > | fromUri (std::string_view uri) |
| Create a Name from a URI string. | |
| static Result< Name > | fromWire (const uint8_t *buf, size_t len, size_t *bytesRead=nullptr) |
| Decode a Name from TLV wire format. | |
NDN Name class.
A class representing the name of an NDN packet. A name consists of multiple components and can be expressed in URI format (e.g., "/sensor/temperature").
|
default |
Default constructor.
Creates an empty Name.
| Error ndn::Name::appendComponent | ( | const uint8_t * | value, |
| size_t | len | ||
| ) |
Append a binary component.
| value | Pointer to component value |
| len | Size of the component in bytes |
| Error ndn::Name::appendComponent | ( | std::string_view | comp | ) |
Append a string component.
| comp | Component string to append |
Definition at line 228 of file name.cpp.
Referenced by ndn::Certificate::buildName(), and ndn::Certificate::fromData().
| int ndn::Name::compare | ( | const Name & | other | ) | const |
Compare with another Name.
Performs lexicographic comparison according to the NDN specification.
| other | Name to compare with |
Definition at line 279 of file name.cpp.
References component(), ndn::NameComponent::size, and ndn::NameComponent::value.
Referenced by equals(), and ndn::operator<().
| NameComponent ndn::Name::component | ( | size_t | index | ) | const |
Get the component at a given index.
| index | Component index (starting from 0) |
Definition at line 219 of file name.cpp.
References ndn::NameComponent::value.
Referenced by ndn::Certificate::buildName(), compare(), ndn::Certificate::fromData(), isPrefixOf(), and toUri().
|
inline |
Get the number of components.
Definition at line 133 of file name.hpp.
Referenced by ndn::Certificate::buildName(), ndn::Fib::findLongestMatch(), and ndn::Certificate::fromData().
|
inline |
| Error ndn::Name::encode | ( | uint8_t * | buf, |
| size_t | bufSize, | ||
| size_t & | encodedLen | ||
| ) | const |
Encode the Name to TLV wire format.
| buf | Output buffer |
| bufSize | Buffer size |
| encodedLen | Stores the number of encoded bytes |
Definition at line 186 of file name.cpp.
References ndn::tlv::Name, ndn::TlvEncoder::size(), ndn::varNumberSize(), ndn::TlvEncoder::writeBytes(), ndn::TlvEncoder::writeLength(), and ndn::TlvEncoder::writeType().
Referenced by ndn::Interest::encode().
| bool ndn::Name::equals | ( | const Name & | other | ) | const |
Check equality with another Name.
| other | Name to compare with |
Definition at line 309 of file name.cpp.
References compare().
Referenced by ndn::operator!=(), and ndn::operator==().
Create a Name from a URI string.
Parses an NDN URI format string and constructs a Name. The "ndn:" prefix is optional.
| uri | URI string (e.g., "/sensor/temperature" or "ndn:/sensor/temperature") |
Definition at line 25 of file name.cpp.
References ndn::NAME_MAX_LENGTH.
Referenced by ndn::Link::addDelegation(), ndn::Interest::addForwardingHint(), ndn::Forwarder::addRoute(), ndn::Forwarder::registerPrefix(), ndn::Certificate::setIdentityName(), ndn::Data::setName(), ndn::Interest::setName(), and ndn::Link::setName().
|
static |
Decode a Name from TLV wire format.
| buf | Input buffer |
| len | Buffer length |
| bytesRead | Pointer to store the number of bytes read (may be nullptr) |
Definition at line 84 of file name.cpp.
References ndn::TlvDecoder::current(), ndn::tlv::GenericNameComponent, ndn::tlv::Name, ndn::TlvDecoder::position(), ndn::TlvDecoder::readTlvHeader(), ndn::TlvDecoder::remaining(), and ndn::TlvDecoder::skip().
Referenced by ndn::Link::fromData(), ndn::Data::fromWire(), and ndn::Interest::fromWire().
| uint32_t ndn::Name::hash | ( | ) | const |
| bool ndn::Name::isPrefixOf | ( | const Name & | other | ) | const |
Check if this Name is a prefix of another Name.
| other | Name to compare with |
Definition at line 313 of file name.cpp.
References component(), ndn::NameComponent::size, and ndn::NameComponent::value.
| size_t ndn::Name::toUri | ( | char * | buf, |
| size_t | bufSize | ||
| ) | const |
Convert the Name to a URI string.
| buf | Output buffer |
| bufSize | Buffer size |
Definition at line 141 of file name.cpp.
References component(), ndn::NameComponent::size, and ndn::NameComponent::value.
|
inline |
|
inline |