Represents an absolute name. More...
#include <ndn-cxx/name.hpp>
Public Types | |
using | allocator_type = void |
using | Component = name::Component |
using | const_iterator = const Component * |
using | const_pointer = const Component * |
using | const_reference = const Component & |
using | const_reverse_iterator = std::reverse_iterator< const_iterator > |
using | difference_type = std::vector< Component >::difference_type |
using | Error = Component::Error |
using | iterator = const Component * |
using | pointer = Component * |
using | reference = Component & |
using | reverse_iterator = std::reverse_iterator< iterator > |
using | size_type = std::vector< Component >::size_type |
using | value_type = Component |
Public Member Functions | |
Name () | |
Create an empty name. More... | |
Name (const Block &wire) | |
Create Name from wire encoding. More... | |
Name (const char *uri) | |
Create name from NDN URI. More... | |
Name (const std::string &uri) | |
Create name from NDN URI. More... | |
Name (std::string_view uri) | |
Create name from NDN URI. More... | |
Name & | append (Component &&component) |
Append a name component. More... | |
Name & | append (const char *str) |
Append a GenericNameComponent , copying the TLV-VALUE from a null-terminated string. More... | |
Name & | append (const Component &component) |
Append a name component. More... | |
Name & | append (const PartialName &name) |
Append a PartialName. More... | |
template<class Iterator > | |
Name & | append (Iterator first, Iterator last) |
Append a GenericNameComponent , copying the TLV-VALUE from a range. More... | |
Name & | append (span< const uint8_t > value) |
Append a GenericNameComponent , copying the TLV-VALUE from value . More... | |
template<class Iterator > | |
Name & | append (uint32_t type, Iterator first, Iterator last) |
Append a NameComponent of TLV-TYPE type , copying the TLV-VALUE from a range. More... | |
Name & | append (uint32_t type, span< const uint8_t > value) |
Append a NameComponent of TLV-TYPE type , copying the TLV-VALUE from value . More... | |
Name & | appendByteOffset (uint64_t offset) |
Append a byte offset component. More... | |
Name & | appendImplicitSha256Digest (ConstBufferPtr digest) |
Append an ImplicitSha256Digest component. More... | |
Name & | appendImplicitSha256Digest (span< const uint8_t > digestBytes) |
Append an ImplicitSha256Digest component. More... | |
Name & | appendKeyword (span< const uint8_t > keyword) |
Append a keyword component. More... | |
Name & | appendKeyword (std::string_view keyword) |
Append a keyword component. More... | |
Name & | appendNumber (uint64_t number) |
Append a component with a NonNegativeInteger. More... | |
Name & | appendNumberWithMarker (uint8_t marker, uint64_t number) |
Append a component with a marked number. More... | |
Name & | appendParametersSha256Digest (ConstBufferPtr digest) |
Append a ParametersSha256Digest component. More... | |
Name & | appendParametersSha256Digest (span< const uint8_t > digestBytes) |
Append a ParametersSha256Digest component. More... | |
Name & | appendParametersSha256DigestPlaceholder () |
Append a placeholder for a ParametersSha256Digest component. More... | |
Name & | appendSegment (uint64_t segmentNo) |
Append a segment number (sequential) component. More... | |
Name & | appendSequenceNumber (uint64_t seqNo) |
Append a sequence number component. More... | |
Name & | appendTimestamp (const std::optional< time::system_clock::time_point > ×tamp=std::nullopt) |
Append a timestamp component. More... | |
Name & | appendVersion (const std::optional< uint64_t > &version=std::nullopt) |
Append a version component. More... | |
const Component & | at (ssize_t i) const |
Returns an immutable reference to the component at the specified index, with bounds checking. More... | |
const_iterator | begin () const noexcept |
Begin iterator. More... | |
void | clear () |
Remove all components. More... | |
int | compare (const Name &other) const |
Compare this to the other Name using NDN canonical ordering. More... | |
int | compare (size_t pos1, size_t count1, const Name &other, size_t pos2=0, size_t count2=npos) const |
Compares [pos1, pos1+count1) components in this Name to [pos2, pos2+count2) components in other . More... | |
Name | deepCopy () const |
Make a deep copy of the name, reallocating the underlying memory buffer. More... | |
bool | empty () const noexcept |
Checks if the name is empty, i.e., has no components. More... | |
const_iterator | end () const noexcept |
End iterator. More... | |
bool | equals (const Name &other) const noexcept |
Check if this name equals another name. More... | |
void | erase (ssize_t i) |
Erase the component at the specified index. More... | |
const Component & | get (ssize_t i) const noexcept |
Returns an immutable reference to the component at the specified index. More... | |
PartialName | getPrefix (ssize_t nComponents) const |
Returns a prefix of the name. More... | |
PartialName | getSubName (ssize_t iStartComponent, size_t nComponents=npos) const |
Extracts some components as a sub-name (PartialName). More... | |
Name | getSuccessor () const |
Get the successor of a name. More... | |
bool | hasWire () const noexcept |
Check if this instance already has wire encoding. More... | |
bool | isPrefixOf (const Name &other) const noexcept |
Check if this name is a prefix of another name. More... | |
const Component & | operator[] (ssize_t i) const noexcept |
Equivalent to get(). More... | |
const_reverse_iterator | rbegin () const noexcept |
Reverse begin iterator. More... | |
const_reverse_iterator | rend () const noexcept |
Reverse end iterator. More... | |
Name & | set (ssize_t i, Component &&component) |
Replace the component at the specified index. More... | |
Name & | set (ssize_t i, const Component &component) |
Replace the component at the specified index. More... | |
size_t | size () const noexcept |
Returns the number of components. More... | |
std::string | toUri (name::UriFormat format=name::UriFormat::DEFAULT) const |
Get URI representation of the name. More... | |
void | toUri (std::ostream &os, name::UriFormat format=name::UriFormat::DEFAULT) const |
Write URI representation of the name to the output stream. More... | |
void | wireDecode (const Block &wire) |
Decode name from wire encoding. More... | |
const Block & | wireEncode () const |
Perform wire encoding, or return existing (cached) wire encoding. More... | |
template<encoding::Tag TAG> | |
size_t | wireEncode (EncodingImpl< TAG > &encoder) const |
Prepend wire encoding to encoder . More... | |
Static Public Attributes | |
static constexpr size_t | npos = std::numeric_limits<size_t>::max() |
Indicates "until the end" in getSubName() and compare(). More... | |
Friends | |
bool | operator< (const Name &lhs, const Name &rhs) |
std::ostream & | operator<< (std::ostream &os, const Name &name) |
Print the URI representation of a name. More... | |
bool | operator== (const Name &lhs, const Name &rhs) noexcept |
Represents an absolute name.
using ndn::Name::allocator_type = void |
using ndn::Name::Component = name::Component |
using ndn::Name::const_iterator = const Component* |
using ndn::Name::const_pointer = const Component* |
using ndn::Name::const_reference = const Component& |
using ndn::Name::const_reverse_iterator = std::reverse_iterator<const_iterator> |
using ndn::Name::difference_type = std::vector<Component>::difference_type |
using ndn::Name::Error = Component::Error |
using ndn::Name::iterator = const Component* |
using ndn::Name::pointer = Component* |
using ndn::Name::reference = Component& |
using ndn::Name::reverse_iterator = std::reverse_iterator<iterator> |
using ndn::Name::size_type = std::vector<Component>::size_type |
using ndn::Name::value_type = Component |
|
default |
Create an empty name.
|
explicit |
Create Name from wire encoding.
wire | TLV element of type tlv::Name |
This is equivalent to:
tlv::Error | The wire encoding is invalid. |
|
explicit |
Create name from NDN URI.
|
inline |
Create name from NDN URI.
|
inline |
Create name from NDN URI.
std::string
.
|
inline |
Name & ndn::Name::append | ( | const PartialName & | name | ) |
|
inline |
Append a GenericNameComponent
, copying the TLV-VALUE from a range.
Iterator | an InputIterator dereferencing to a one-octet value type. More efficient implementation is available when it is a RandomAccessIterator . |
first | beginning of the range. |
last | past-end of the range. |
|
inline |
|
inline |
Append a NameComponent
of TLV-TYPE type
, copying the TLV-VALUE from a range.
Iterator | an InputIterator dereferencing to a one-octet value type. More efficient implementation is available when it is a RandomAccessIterator . |
type | the TLV-TYPE. |
first | beginning of the range. |
last | past-end of the range. |
|
inline |
|
inline |
Append a byte offset component.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Append a component with a NonNegativeInteger.
|
inline |
Append a component with a marked number.
marker | 1-octet marker |
number | the number |
The component is encoded as a 1-octet marker, followed by a NonNegativeInteger.
|
inline |
|
inline |
Name & ndn::Name::appendParametersSha256DigestPlaceholder | ( | ) |
|
inline |
Append a segment number (sequential) component.
|
inline |
Append a sequence number component.
Name & ndn::Name::appendTimestamp | ( | const std::optional< time::system_clock::time_point > & | timestamp = std::nullopt | ) |
Append a timestamp component.
timestamp | the timestamp to append; if nullopt, the current system time is used |
Name & ndn::Name::appendVersion | ( | const std::optional< uint64_t > & | version = std::nullopt | ) |
Append a version component.
version | the version number to append; if nullopt, the current UNIX time in milliseconds is used |
const name::Component & ndn::Name::at | ( | ssize_t | i | ) | const |
Returns an immutable reference to the component at the specified index, with bounds checking.
i | zero-based index of the component to return; if negative, it is interpreted as offset from the end of the name |
Error | The index is out of bounds. |
|
inlinenoexcept |
void ndn::Name::clear | ( | ) |
|
inline |
Compare this to the other Name using NDN canonical ordering.
If the first components of each name are not equal, this returns a negative value if the first comes before the second using the NDN canonical ordering for name components, or a positive value if it comes after. If they are equal, this compares the second components of each name, etc. If both names are the same up to the size of the shorter name, this returns a negative value if the first name is shorter than the second or a positive value if it is longer. For example, if you std::sort gives: /a/b/d /a/b/cc /c /c/a /bb . This is intuitive because all names with the prefix /a are next to each other. But it may be also be counter-intuitive because /c comes before /bb according to NDN canonical ordering since it is shorter.
other | The other Name to compare with. |
negative | this comes before other in canonical ordering |
zero | this equals other |
positive | this comes after other in canonical ordering |
Name ndn::Name::deepCopy | ( | ) | const |
|
inlinenoexcept |
|
inlinenoexcept |
|
noexcept |
void ndn::Name::erase | ( | ssize_t | i | ) |
|
inlinenoexcept |
Returns an immutable reference to the component at the specified index.
i | zero-based index of the component to return; if negative, it is interpreted as offset from the end of the name |
|
inline |
PartialName ndn::Name::getSubName | ( | ssize_t | iStartComponent, |
size_t | nComponents = npos |
||
) | const |
Extracts some components as a sub-name (PartialName).
iStartComponent | zero-based index of the first component; if negative, size()+iStartComponent is used instead |
nComponents | number of desired components, starting at iStartComponent ; use npos to return all components until the end of the name |
If iStartComponent
is positive and indexes out of bounds, returns an empty PartialName. If iStartComponent
is negative and indexes out of bounds, the sub-name will start from the beginning of the name instead. If nComponents
is out of bounds, returns all components until the end of the name.
Name ndn::Name::getSuccessor | ( | ) | const |
Get the successor of a name.
The successor of a name is defined as follows:
N represents the set of NDN Names, and X,Y ∈ N. Operator < is defined by canonical order on N. Y is the successor of X, if (a) X < Y, and (b) ∄ Z ∈ N s.t. X < Z < Y.
In plain words, successor of a name is the same name, but with its last component advanced to a next possible value.
Examples:
/
is /sha256digest=0000000000000000000000000000000000000000000000000000000000000000
./sha256digest=0000000000000000000000000000000000000000000000000000000000000000
is /sha256digest=0000000000000000000000000000000000000000000000000000000000000001
./sha256digest=ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
is /2=...
./P/A
is /P/B
./Q/FF
is /Q/%00%00
.
|
inlinenoexcept |
|
noexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
Replace the component at the specified index.
i | zero-based index of the component to replace; if negative, it is interpreted as offset from the end of the name |
component | the new component to use as a replacement |
Replace the component at the specified index.
i | zero-based index of the component to replace; if negative, it is interpreted as offset from the end of the name |
component | the new component to use as a replacement |
|
inlinenoexcept |
std::string ndn::Name::toUri | ( | name::UriFormat | format = name::UriFormat::DEFAULT | ) | const |
Get URI representation of the name.
os << name
. void ndn::Name::toUri | ( | std::ostream & | os, |
name::UriFormat | format = name::UriFormat::DEFAULT |
||
) | const |
Write URI representation of the name to the output stream.
void ndn::Name::wireDecode | ( | const Block & | wire | ) |
Decode name from wire encoding.
tlv::Error | The wire encoding is invalid. |
const Block & ndn::Name::wireEncode | ( | ) | const |
size_t ndn::Name::wireEncode | ( | EncodingImpl< TAG > & | encoder | ) | const |
|
friend |
Print the URI representation of a name.
|
staticconstexpr |
Indicates "until the end" in getSubName() and compare().