A Name holds an array of Name::Component and represents an NDN name. More...
#include <name.hpp>
Classes | |
struct | BreadthFirstLess |
class | Component |
A Name::Component holds a read-only name component value. More... | |
Public Types | |
typedef std::vector< Component >::const_iterator | const_iterator |
typedef std::vector< Component >::const_reverse_iterator | const_reverse_iterator |
typedef Component | partial_type |
Public Member Functions | |
Name () | |
Create a new Name with no components. | |
Name (const std::vector< Component > &components) | |
Create a new Name, copying the name components. More... | |
Name (const char *uri) | |
Parse the uri according to the NDN URI Scheme and create the name with the components. More... | |
Name (const std::string &uri) | |
Parse the uri according to the NDN URI Scheme and create the name with the components. More... | |
void | get (NameLite &nameLite) const |
Set nameLite to point to the components in this name, without copying any memory. More... | |
void | set (const NameLite &nameLite) |
Clear this name, and set the components by copying from nameLite. More... | |
void | set (const char *uri) |
Parse the uri according to the NDN URI Scheme and set the name with the components. More... | |
void | set (const std::string &uri) |
Parse the uri according to the NDN URI Scheme and set the name with the components. More... | |
Name & | append (const uint8_t *value, size_t valueLength) |
Append a new component, copying from value of length valueLength. More... | |
Name & | append (const std::vector< uint8_t > &value) |
Append a new component, copying from value. More... | |
Name & | append (const Blob &value) |
Name & | append (const Component &value) |
Name & | append (const char *value) |
Append a new component, copying the bytes from the value string. More... | |
Name & | append (const std::string &value) |
Append a new component, copying the bytes from the value string. More... | |
Name & | append (const Name &name) |
Append the components of the given name to this name. More... | |
Name &DEPRECATED_IN_NDN_CPP | appendComponent (const uint8_t *value, size_t valueLength) |
Name &DEPRECATED_IN_NDN_CPP | appendComponent (const std::vector< uint8_t > &value) |
Name &DEPRECATED_IN_NDN_CPP | appendComponent (const Blob &value) |
Name &DEPRECATED_IN_NDN_CPP | addComponent (const uint8_t *value, size_t valueLength) |
Name &DEPRECATED_IN_NDN_CPP | addComponent (const std::vector< uint8_t > &value) |
Name &DEPRECATED_IN_NDN_CPP | addComponent (const Blob &value) |
void | clear () |
Clear all the components. | |
size_t DEPRECATED_IN_NDN_CPP | getComponentCount () const |
const Component &DEPRECATED_IN_NDN_CPP | getComponent (size_t i) const |
Name | getSubName (int iStartComponent, size_t nComponents) const |
Get a new name, constructed as a subset of components. More... | |
Name | getSubName (int iStartComponent) const |
Get a new name, constructed as a subset of components starting at iStartComponent until the end of the name. More... | |
Name | getPrefix (int nComponents) const |
Return a new Name with the first nComponents components of this Name. More... | |
std::string | toUri (bool includeScheme=false) const |
Encode this name as a URI. More... | |
std::string DEPRECATED_IN_NDN_CPP | to_uri () const |
Name & | appendSegment (uint64_t segment) |
Append a component with the encoded segment number according to NDN naming conventions for "Segment number" (marker 0x00). More... | |
Name & | appendSegmentOffset (uint64_t segmentOffset) |
Append a component with the encoded segment byte offset according to NDN naming conventions for segment "Byte offset" (marker 0xFB). More... | |
Name &DEPRECATED_IN_NDN_CPP | appendFinalSegment (uint64_t segment) |
Name & | appendVersion (uint64_t version) |
Append a component with the encoded version number according to NDN naming conventions for "Versioning" (marker 0xFD). More... | |
Name & | appendTimestamp (uint64_t timestamp) |
Append a component with the encoded timestamp according to NDN naming conventions for "Timestamp" (marker 0xFC). More... | |
Name & | appendSequenceNumber (uint64_t sequenceNumber) |
Append a component with the encoded sequence number according to NDN naming conventions for "Sequencing" (marker 0xFE). More... | |
bool | equals (const Name &name) const |
Check if this name has the same component count and components as the given name. More... | |
Name | getSuccessor () const |
Get the successor of this name which is defined as follows. More... | |
bool | match (const Name &name) const |
Check if the N components of this name are the same as the first N components of the given name. More... | |
bool | isPrefixOf (const Name &name) const |
Check if the N components of this name are the same as the first N components of the given name. More... | |
size_t | size () const |
Get the number of components. More... | |
Blob | wireEncode (WireFormat &wireFormat=*WireFormat::getDefaultWireFormat()) const |
Encode this Name for a particular wire format. More... | |
void | wireDecode (const uint8_t *input, size_t inputLength, WireFormat &wireFormat=*WireFormat::getDefaultWireFormat()) |
Decode the input using a particular wire format and update this Name. More... | |
void | wireDecode (const std::vector< uint8_t > &input, WireFormat &wireFormat=*WireFormat::getDefaultWireFormat()) |
Decode the input using a particular wire format and update this Name. More... | |
void | wireDecode (const Blob &input, WireFormat &wireFormat=*WireFormat::getDefaultWireFormat()) |
Decode the input using a particular wire format and update this Name. More... | |
const Component & | get (int i) const |
Get the component at the given index. More... | |
uint64_t | getChangeCount () const |
Get the change count, which is incremented each time this object is changed. More... | |
int | compare (const Name &other) const |
Compare this to the other Name using NDN canonical ordering. More... | |
int | compare (int iStartComponent, size_t nComponents, const Name &other, int iOtherStartComponent, size_t nOtherComponents) const |
Compare a subset of this name to a subset of the other name, equivalent to this->getSubName(iStartComponent, nComponents).compare (other.getSubName(iOtherStartComponent, nOtherComponents)). More... | |
int | compare (int iStartComponent, size_t nComponents, const Name &other, int iOtherStartComponent=0) const |
Compare a subset of this name to a subset of the other name, equivalent to this->getSubName(iStartComponent, nComponents).compare (other.getSubName(iOtherStartComponent)), getting all components of other from iOtherStartComponent to the end of the name. More... | |
const Component & | operator[] (int i) const |
template<class T > | |
void | push_back (const T &component) |
Append the component. More... | |
bool | operator== (const Name &name) const |
Check if this name has the same component count and components as the given name. More... | |
bool | operator!= (const Name &name) const |
Check if this name has the same component count and components as the given name. More... | |
bool | operator<= (const Name &other) const |
Return true if this is less than or equal to the other Name in the NDN canonical ordering. More... | |
bool | operator< (const Name &other) const |
Return true if this is less than the other Name in the NDN canonical ordering. More... | |
bool | operator>= (const Name &other) const |
Return true if this is less than or equal to the other Name in the NDN canonical ordering. More... | |
bool | operator> (const Name &other) const |
Return true if this is greater than the other Name in the NDN canonical ordering. More... | |
const_iterator | begin () const |
Begin iterator (const). | |
const_iterator | end () const |
End iterator (const). | |
const_reverse_iterator | rbegin () const |
Reverse begin iterator (const). | |
const_reverse_iterator | rend () const |
Reverse end iterator (const). | |
Static Public Member Functions | |
static Blob | fromEscapedString (const char *escapedString, size_t beginOffset, size_t endOffset) |
Make a Blob value by decoding the escapedString between beginOffset and endOffset according to the NDN URI Scheme. More... | |
static Blob | fromEscapedString (const char *escapedString) |
Make a Blob value by decoding the escapedString according to the NDN URI Scheme. More... | |
static Blob | fromEscapedString (const std::string &escapedString) |
Make a Blob value by decoding the escapedString according to the NDN URI Scheme. More... | |
static void | toEscapedString (const std::vector< uint8_t > &value, std::ostringstream &result) |
Write the value to result, escaping characters according to the NDN URI Scheme. More... | |
static std::string | toEscapedString (const std::vector< uint8_t > &value) |
Convert the value by escaping characters according to the NDN URI Scheme. More... | |
static bool DEPRECATED_IN_NDN_CPP | breadthFirstLess (const Name &name1, const Name &name2) |
A Name holds an array of Name::Component and represents an NDN name.
|
inline |
|
inline |
Parse the uri according to the NDN URI Scheme and create the name with the components.
uri | The URI string. |
|
inline |
Parse the uri according to the NDN URI Scheme and create the name with the components.
uri | The URI string. |
|
inline |
|
inline |
|
inline |
Append a new component, copying from value of length valueLength.
|
inline |
Append a new component, copying from value.
|
inline |
Append a new component, copying the bytes from the value string.
NOTE: This does not escape XX values. If you need to escape, use Name::fromEscapedString. Also, if the string has "/", this does not split into separate components. If you need that then use Name(value).
value | A null-terminated string with the bytes to copy. |
|
inline |
Append a new component, copying the bytes from the value string.
NOTE: This does not escape XX values. If you need to escape, use Name::fromEscapedString. Also, if the string has "/", this does not split into separate components. If you need that then use Name(value).
value | A string with the bytes to copy. |
Append the components of the given name to this name.
name | The Name with components to append. |
|
inline |
|
inline |
|
inline |
|
inline |
Append a component with the encoded segment number according to NDN naming conventions for "Segment number" (marker 0x00).
http://named-data.net/doc/tech-memos/naming-conventions.pdf
segment | The segment number. |
|
inline |
Append a component with the encoded segment byte offset according to NDN naming conventions for segment "Byte offset" (marker 0xFB).
http://named-data.net/doc/tech-memos/naming-conventions.pdf
segmentOffset | The segment byte offset. |
|
inline |
Append a component with the encoded sequence number according to NDN naming conventions for "Sequencing" (marker 0xFE).
http://named-data.net/doc/tech-memos/naming-conventions.pdf
sequenceNumber | The sequence number. |
|
inline |
Append a component with the encoded timestamp according to NDN naming conventions for "Timestamp" (marker 0xFC).
http://named-data.net/doc/tech-memos/naming-conventions.pdf
timestamp | The number of microseconds since the UNIX epoch (Thursday, 1 January 1970) not counting leap seconds. |
|
inline |
Append a component with the encoded version number according to NDN naming conventions for "Versioning" (marker 0xFD).
http://named-data.net/doc/tech-memos/naming-conventions.pdf Note that this encodes the exact value of version without converting from a time representation.
version | The version number. |
|
inlinestatic |
|
inline |
Compare this to the other Name using NDN canonical ordering.
If the first components of each name are not equal, this returns -1 if the first comes before the second using the NDN canonical ordering for name components, or 1 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 -1 if the first name is shorter than the second or 1 if it is longer. For example, 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. |
int ndn::Name::compare | ( | int | iStartComponent, |
size_t | nComponents, | ||
const Name & | other, | ||
int | iOtherStartComponent, | ||
size_t | nOtherComponents | ||
) | const |
Compare a subset of this name to a subset of the other name, equivalent to this->getSubName(iStartComponent, nComponents).compare (other.getSubName(iOtherStartComponent, nOtherComponents)).
iStartComponent | The index if the first component of this name to get. If iStartComponent is -N then return return components starting from name.size() - N. |
nComponents | The number of components starting at iStartComponent. If greater than the size of this name, get until the end of the name. |
other | The other Name to compare with. |
iOtherStartComponent | The index if the first component of the other name to get. If iOtherStartComponent is -N then return return components starting from other.size() - N. |
nOtherComponents | The number of components starting at iOtherStartComponent. If greater than the size of the other name, get until the end of the name. |
|
inline |
Compare a subset of this name to a subset of the other name, equivalent to this->getSubName(iStartComponent, nComponents).compare (other.getSubName(iOtherStartComponent)), getting all components of other from iOtherStartComponent to the end of the name.
iStartComponent | The index if the first component of this name to get. If iStartComponent is -N then return return components starting from name.size() - N. |
nComponents | The number of components starting at iStartComponent. If greater than the size of this name, get until the end of the name. |
other | The other Name to compare with. |
iOtherStartComponent | (optional) The index if the first component of the other name to get. If iOtherStartComponent is -N then return return components starting from other.size() - N. If omitted, use 0. |
bool ndn::Name::equals | ( | const Name & | name | ) | const |
Check if this name has the same component count and components as the given name.
name | The Name to check. |
|
static |
Make a Blob value by decoding the escapedString between beginOffset and endOffset according to the NDN URI Scheme.
If the escaped string is "", "." or ".." then return a Blob with a null pointer, which means the component should be skipped in a URI name.
escapedString | The escaped string. It does not need to be null-terminated because we only scan to endOffset. |
beginOffset | The offset in escapedString of the beginning of the portion to decode. |
endOffset | The offset in escapedString of the end of the portion to decode. |
|
static |
|
inlinestatic |
void ndn::Name::get | ( | NameLite & | nameLite | ) | const |
Set nameLite to point to the components in this name, without copying any memory.
WARNING: The resulting pointers in nameLite are invalid after a further use of this object which could reallocate memory.
nameLite | A NameLite where the components array is already allocated. |
const Name::Component & ndn::Name::get | ( | int | i | ) | const |
Get the component at the given index.
i | The index of the component, starting from 0. However, if i is negative, return the component at size() - (-i). |
runtime_error | If index is out of range. |
|
inline |
Get the change count, which is incremented each time this object is changed.
|
inline |
|
inline |
|
inline |
Name ndn::Name::getSubName | ( | int | iStartComponent, |
size_t | nComponents | ||
) | const |
Get a new name, constructed as a subset of components.
iStartComponent | The index if the first component to get. If iStartComponent is -N then return return components starting from name.size() - N. |
nComponents | The number of components starting at iStartComponent. If greater than the size of this name, get until the end of the name. |
|
inline |
Get a new name, constructed as a subset of components starting at iStartComponent until the end of the name.
iStartComponent | The index if the first component to get. If iStartComponent is -N then return return components starting from name.size() - N. |
Name ndn::Name::getSuccessor | ( | ) | const |
Get the successor of this name which is defined as follows.
N represents the set of NDN Names, and X,Y ∈ N. Operator < is defined by the NDN 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, the successor of a name is the same name, but with its last component advanced to a next possible value.
Examples:
|
inline |
Check if the N components of this name are the same as the first N components of the given name.
name | The Name to check. |
bool ndn::Name::match | ( | const Name & | name | ) | const |
Check if the N components of this name are the same as the first N components of the given name.
name | The Name to check. |
|
inline |
Check if this name has the same component count and components as the given name.
name | The Name to check. |
|
inline |
|
inline |
|
inline |
Check if this name has the same component count and components as the given name.
name | The Name to check. |
|
inline |
|
inline |
|
inline |
Append the component.
component | The component of type T. |
void ndn::Name::set | ( | const NameLite & | nameLite | ) |
Clear this name, and set the components by copying from nameLite.
nameLite | A NameLite object. |
void ndn::Name::set | ( | const char * | uri | ) |
Parse the uri according to the NDN URI Scheme and set the name with the components.
uri | The null-terminated URI string. |
|
inline |
Parse the uri according to the NDN URI Scheme and set the name with the components.
uri | The URI string. |
|
inline |
Get the number of components.
|
inline |
|
static |
Write the value to result, escaping characters according to the NDN URI Scheme.
This also adds "..." to a value with zero or more ".".
value | the buffer with the value to escape |
result | the string stream to write to. |
|
static |
Convert the value by escaping characters according to the NDN URI Scheme.
This also adds "..." to a value with zero or more ".".
value | the buffer with the value to escape |
string ndn::Name::toUri | ( | bool | includeScheme = false | ) | const |
Encode this name as a URI.
includeScheme | (optional) If true, include the "ndn:" scheme in the URI, e.g. "ndn:/example/name". If false, just return the path, e.g. "/example/name". If ommitted, then just return the path which is the default case where toUri() is used for display. |
|
inline |
Decode the input using a particular wire format and update this Name.
input | The input byte array to be decoded. |
inputLength | The length of input. |
wireFormat | (optional) A WireFormat object used to decode the input. If omitted, use WireFormat::getDefaultWireFormat(). |
|
inline |
Decode the input using a particular wire format and update this Name.
input | The input byte array to be decoded. |
wireFormat | (optional) A WireFormat object used to decode the input. If omitted, use WireFormat::getDefaultWireFormat(). |
|
inline |
Decode the input using a particular wire format and update this Name.
input | The input byte array to be decoded as an immutable Blob. |
wireFormat | (optional) A WireFormat object used to decode the input. If omitted, use WireFormat::getDefaultWireFormat(). |
|
inline |
Encode this Name for a particular wire format.
wireFormat | (optional) A WireFormat object used to encode this Name. If omitted, use WireFormat::getDefaultWireFormat(). |