Represents an absolute name. More...
#include <ndn-cxx/name.hpp>
Public Types | |
using | allocator_type = void |
using | Component = name::Component |
using | component_container = std::vector< 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 = component_container::difference_type |
using | Error = name::Component::Error |
using | iterator = const Component * |
using | pointer = Component * |
using | reference = Component & |
using | reverse_iterator = std::reverse_iterator< iterator > |
using | size_type = component_container::size_type |
using | value_type = Component |
Public Member Functions | |
Name () | |
Create an empty name. More... | |
Name (const Block &wire) | |
Decode Name from wire encoding. More... | |
Name (const char *uri) | |
Parse name from NDN URI. More... | |
Name (std::string uri) | |
Create name from NDN URI. More... | |
Name & | append (const Component &component) |
Append a component. More... | |
Name & | append (uint32_t type, const uint8_t *value, size_t count) |
Append a NameComponent of TLV-TYPE type , copying count bytes at value as TLV-VALUE. More... | |
Name & | append (const uint8_t *value, size_t count) |
Append a GenericNameComponent, copying count bytes at value as TLV-VALUE. More... | |
template<class Iterator > | |
Name & | append (uint32_t type, Iterator first, Iterator last) |
Append a NameComponent of TLV-TYPE type , copying TLV-VALUE from a range. More... | |
template<class Iterator > | |
Name & | append (Iterator first, Iterator last) |
Append a GenericNameComponent, copying TLV-VALUE from a range. More... | |
Name & | append (const char *str) |
Append a GenericNameComponent, copying TLV-VALUE from a null-terminated string. More... | |
Name & | append (const Block &value) |
Append a GenericNameComponent from a TLV element. More... | |
Name & | append (const PartialName &name) |
Append a PartialName. More... | |
Name & | appendByteOffset (uint64_t offset) |
Append a byte offset component. More... | |
Name & | appendImplicitSha256Digest (ConstBufferPtr digest) |
Append an ImplicitSha256Digest component. More... | |
Name & | appendImplicitSha256Digest (const uint8_t *digest, size_t digestSize) |
Append an ImplicitSha256Digest 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 & | appendSegment (uint64_t segmentNo) |
Append a segment number (sequential) component. More... | |
Name & | appendSegmentOffset (uint64_t offset) |
Name & | appendSequenceNumber (uint64_t seqNo) |
Append a sequence number component. More... | |
Name & | appendTimestamp (optional< time::system_clock::TimePoint > timestamp=nullopt) |
Append a timestamp component. More... | |
Name & | appendVersion (optional< uint64_t > version=nullopt) |
Append a version component. More... | |
const Component & | at (ssize_t i) const |
Get the component at the given index. More... | |
const_iterator | begin () const |
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 |
Check if name is empty. More... | |
const_iterator | end () const |
End iterator. More... | |
bool | equals (const Name &other) const |
Check if this name equals another name. More... | |
const Component & | get (ssize_t i) const |
Get the component at the given index. More... | |
PartialName | getPrefix (ssize_t nComponents) const |
Extract a prefix of the name. More... | |
PartialName | getSubName (ssize_t iStartComponent, size_t nComponents=npos) const |
Extract some components as a sub-name (PartialName) More... | |
Name | getSuccessor () const |
Get the successor of a name. More... | |
bool | hasWire () const |
Check if this Name instance already has wire encoding. More... | |
bool | isPrefixOf (const Name &other) const |
Check if this name is a prefix of another name. More... | |
const Component & | operator[] (ssize_t i) const |
Equivalent to get(i) More... | |
template<class T > | |
void | push_back (const T &component) |
Append a component. More... | |
const_reverse_iterator | rbegin () const |
Reverse begin iterator. More... | |
const_reverse_iterator | rend () const |
Reverse end iterator. More... | |
size_t | size () const |
Get number of components. More... | |
std::string | toUri () const |
Get URI representation of the name. More... | |
void | wireDecode (const Block &wire) |
Decode name from wire encoding. More... | |
template<encoding::Tag TAG> | |
size_t | wireEncode (EncodingImpl< TAG > &encoder) const |
Fast encoding or block size estimation. More... | |
const Block & | wireEncode () const |
Perform wire encoding, or return existing wire encoding. More... | |
Static Public Attributes | |
static const size_t | npos = std::numeric_limits<size_t>::max() |
indicates "until the end" in getSubName and compare More... | |
using ndn::Name::allocator_type = void |
using ndn::Name::Component = name::Component |
using ndn::Name::component_container = std::vector<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 = component_container::difference_type |
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 = component_container::size_type |
using ndn::Name::value_type = Component |
ndn::Name::Name | ( | ) |
|
explicit |
Decode Name from wire encoding.
tlv::Error | wire encoding is invalid |
This is a more efficient equivalent for
ndn::Name::Name | ( | const char * | uri | ) |
Parse name from NDN URI.
uri | a null-terminated URI string |
ndn::Name::Name | ( | std::string | uri | ) |
Create name from NDN URI.
uri | a URI string |
|
inline |
|
inline |
|
inline |
Append a NameComponent of TLV-TYPE type
, copying 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 |
Append a GenericNameComponent, copying 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 |
Append a GenericNameComponent from a TLV element.
value | a TLV element. If its type is tlv::GenericNameComponent , it is used as is. Otherwise, it is encapsulated into a GenericNameComponent. |
Name & ndn::Name::append | ( | const PartialName & | name | ) |
|
inline |
Append a byte offset component.
|
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 |
Append a segment number (sequential) component.
|
inline |
|
inline |
Append a sequence number component.
Name & ndn::Name::appendTimestamp | ( | optional< time::system_clock::TimePoint > | timestamp = nullopt | ) |
Append a timestamp component.
timestamp | the timestamp to append; if nullopt, the current system time is used |
Name & ndn::Name::appendVersion | ( | optional< uint64_t > | version = 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 |
Get the component at the given index.
i | zero-based index; if negative, size()+i is used instead |
Name::Error | index is out of bounds |
|
inline |
|
inline |
|
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 |
|
inline |
|
inline |
bool ndn::Name::equals | ( | const Name & | other | ) | const |
|
inline |
|
inline |
PartialName ndn::Name::getSubName | ( | ssize_t | iStartComponent, |
size_t | nComponents = npos |
||
) | const |
Extract 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 components starting at iStartComponent. Use npos to get the PartialName until the end of this Name. |
If iStartComponent is positive and indexes out of bounds, returns an empty PartialName. If iStartComponent is negative and indexes out of bounds, returns components starting from the beginning of the Name. If nComponents is out of bounds, returns the components until the end of this 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
.
|
inline |
bool ndn::Name::isPrefixOf | ( | const Name & | other | ) | const |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
std::string ndn::Name::toUri | ( | ) | const |
Get URI representation of the name.
os << name
. void ndn::Name::wireDecode | ( | const Block & | wire | ) |
Decode name from wire encoding.
tlv::Error | wire encoding is invalid |
size_t ndn::Name::wireEncode | ( | EncodingImpl< TAG > & | encoder | ) | const |
const Block & ndn::Name::wireEncode | ( | ) | const |