NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
ndn::Name Class Reference

Represents an absolute name. More...

#include <name.hpp>

Collaboration diagram for ndn::Name:

Public Types

using Error = name::Component::Error
 
using Component = name::Component
 
using component_container = std::vector< Component >
 
using value_type = Component
 
using allocator_type = void
 
using reference = Component &
 
using const_reference = const Component &
 
using pointer = Component *
 
using const_pointer = const Component *
 
using iterator = const Component *
 
using const_iterator = const Component *
 
using reverse_iterator = std::reverse_iterator< iterator >
 
using const_reverse_iterator = std::reverse_iterator< const_iterator >
 
using difference_type = component_container::difference_type
 
using size_type = component_container::size_type
 

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...
 
void toUri (std::ostream &os, name::UriFormat format=name::UriFormat::DEFAULT) const
 Write URI representation of the name to the output stream. More...
 
std::string toUri (name::UriFormat format=name::UriFormat::DEFAULT) const
 Get URI representation of the name. More...
 
bool hasWire () const
 Check if this Name instance already has wire encoding. More...
 
template<encoding::Tag TAG>
size_t wireEncode (EncodingImpl< TAG > &encoder) const
 Fast encoding or block size estimation. More...
 
const BlockwireEncode () const
 Perform wire encoding, or return existing wire encoding. More...
 
void wireDecode (const Block &wire)
 Decode name from wire encoding. More...
 
Name deepCopy () const
 Make a deep copy of the name, reallocating the underlying memory buffer. More...
 
NDN_CXX_NODISCARD bool empty () const
 Checks if the name is empty, i.e. More...
 
size_t size () const
 Returns the number of components. More...
 
const Componentget (ssize_t i) const
 Returns an immutable reference to the component at the specified index. More...
 
const Componentoperator[] (ssize_t i) const
 Equivalent to get(i). More...
 
const Componentat (ssize_t i) const
 Returns an immutable reference to the component at the specified index, with bounds checking. More...
 
PartialName getSubName (ssize_t iStartComponent, size_t nComponents=npos) const
 Extracts some components as a sub-name (PartialName). More...
 
PartialName getPrefix (ssize_t nComponents) const
 Returns a prefix of the name. More...
 
const_iterator begin () const
 Begin iterator. More...
 
const_iterator end () const
 End iterator. More...
 
const_reverse_iterator rbegin () const
 Reverse begin iterator. More...
 
const_reverse_iterator rend () const
 Reverse end iterator. More...
 
Nameset (ssize_t i, const Component &component)
 Replace the component at the specified index. More...
 
Nameset (ssize_t i, Component &&component)
 Replace the component at the specified index. More...
 
Nameappend (const Component &component)
 Append a component. More...
 
Nameappend (Component &&component)
 Append a component. More...
 
Nameappend (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...
 
Nameappend (const uint8_t *value, size_t count)
 Append a GenericNameComponent, copying count bytes at value as TLV-VALUE. More...
 
template<class Iterator >
Nameappend (uint32_t type, Iterator first, Iterator last)
 Append a NameComponent of TLV-TYPE type, copying TLV-VALUE from a range. More...
 
template<class Iterator >
Nameappend (Iterator first, Iterator last)
 Append a GenericNameComponent, copying TLV-VALUE from a range. More...
 
Nameappend (const char *str)
 Append a GenericNameComponent, copying TLV-VALUE from a null-terminated string. More...
 
Nameappend (Block value)
 Append a GenericNameComponent from a TLV element. More...
 
Nameappend (const PartialName &name)
 Append a PartialName. More...
 
NameappendNumber (uint64_t number)
 Append a component with a nonNegativeInteger. More...
 
NameappendNumberWithMarker (uint8_t marker, uint64_t number)
 Append a component with a marked number. More...
 
NameappendVersion (optional< uint64_t > version=nullopt)
 Append a version component. More...
 
NameappendSegment (uint64_t segmentNo)
 Append a segment number (sequential) component. More...
 
NameappendByteOffset (uint64_t offset)
 Append a byte offset component. More...
 
NameappendSegmentOffset (uint64_t offset)
 
NameappendTimestamp (optional< time::system_clock::TimePoint > timestamp=nullopt)
 Append a timestamp component. More...
 
NameappendSequenceNumber (uint64_t seqNo)
 Append a sequence number component. More...
 
NameappendImplicitSha256Digest (ConstBufferPtr digest)
 Append an ImplicitSha256Digest component. More...
 
NameappendImplicitSha256Digest (const uint8_t *digest, size_t digestSize)
 Append an ImplicitSha256Digest component. More...
 
NameappendParametersSha256Digest (ConstBufferPtr digest)
 Append a ParametersSha256Digest component. More...
 
NameappendParametersSha256Digest (const uint8_t *digest, size_t digestSize)
 Append a ParametersSha256Digest component. More...
 
NameappendParametersSha256DigestPlaceholder ()
 Append a placeholder for a ParametersSha256Digest component. More...
 
template<class T >
void push_back (const T &component)
 Append a component. More...
 
void erase (ssize_t i)
 Erase the component at the specified index. More...
 
void clear ()
 Remove all components. More...
 
Name getSuccessor () const
 Get the successor of a name. More...
 
bool isPrefixOf (const Name &other) const
 Check if this name is a prefix of another name. More...
 
bool equals (const Name &other) const
 Check if this name equals another name. 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...
 

Static Public Attributes

static const 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)
 
bool operator!= (const Name &lhs, const Name &rhs)
 
bool operator< (const Name &lhs, const Name &rhs)
 
bool operator<= (const Name &lhs, const Name &rhs)
 
bool operator> (const Name &lhs, const Name &rhs)
 
bool operator>= (const Name &lhs, const Name &rhs)
 
std::ostream & operator<< (std::ostream &os, const Name &name)
 Print URI representation of a name. More...
 

Detailed Description

Represents an absolute name.

Definition at line 43 of file name.hpp.

Member Typedef Documentation

◆ Error

Definition at line 46 of file name.hpp.

◆ Component

Definition at line 48 of file name.hpp.

◆ component_container

Definition at line 49 of file name.hpp.

◆ value_type

Definition at line 52 of file name.hpp.

◆ allocator_type

Definition at line 53 of file name.hpp.

◆ reference

Definition at line 54 of file name.hpp.

◆ const_reference

Definition at line 55 of file name.hpp.

◆ pointer

Definition at line 56 of file name.hpp.

◆ const_pointer

Definition at line 57 of file name.hpp.

◆ iterator

Definition at line 58 of file name.hpp.

◆ const_iterator

Definition at line 59 of file name.hpp.

◆ reverse_iterator

using ndn::Name::reverse_iterator = std::reverse_iterator<iterator>

Definition at line 60 of file name.hpp.

◆ const_reverse_iterator

using ndn::Name::const_reverse_iterator = std::reverse_iterator<const_iterator>

Definition at line 61 of file name.hpp.

◆ difference_type

using ndn::Name::difference_type = component_container::difference_type

Definition at line 62 of file name.hpp.

◆ size_type

using ndn::Name::size_type = component_container::size_type

Definition at line 63 of file name.hpp.

Constructor & Destructor Documentation

◆ Name() [1/4]

ndn::Name::Name ( )

Create an empty name.

Postcondition
empty() == true

Definition at line 54 of file name.cpp.

◆ Name() [2/4]

ndn::Name::Name ( const Block wire)
explicit

Decode Name from wire encoding.

Exceptions
tlv::Errorwire encoding is invalid

This is a more efficient equivalent for

name.wireDecode(wire);

Definition at line 59 of file name.cpp.

References ndn::Block::parse().

◆ Name() [3/4]

ndn::Name::Name ( const char *  uri)

Parse name from NDN URI.

Parameters
uria null-terminated URI string
See also
https://named-data.net/doc/NDN-packet-spec/current/name.html#ndn-uri-scheme

Definition at line 65 of file name.cpp.

◆ Name() [4/4]

ndn::Name::Name ( std::string  uri)

Create name from NDN URI.

Parameters
uria URI string
See also
https://named-data.net/doc/NDN-packet-spec/current/name.html#ndn-uri-scheme

Definition at line 70 of file name.cpp.

References append(), and ndn::name::Component::fromEscapedString().

Member Function Documentation

◆ toUri() [1/2]

void ndn::Name::toUri ( std::ostream &  os,
name::UriFormat  format = name::UriFormat::DEFAULT 
) const

Write URI representation of the name to the output stream.

See also
https://named-data.net/doc/NDN-packet-spec/current/name.html#ndn-uri-scheme

Definition at line 348 of file name.cpp.

References empty().

Referenced by ndn::security::pib::CertificateContainer::add(), ndn::security::pib::KeyContainer::add(), ndn::security::v2::KeyChain::addCertificate(), ndn::security::v2::ValidationPolicySimpleHierarchy::checkPolicy(), ndn::security::tpm::BackEnd::createKey(), ndn::security::v2::KeyChain::deleteCertificate(), ndn::security::v2::KeyChain::deleteKey(), ndn::security::tpm::BackEnd::exportKey(), ndn::security::v2::KeyChain::exportSafeBag(), ndn::security::v2::extractIdentityFromCertName(), ndn::security::v2::extractIdentityFromKeyName(), ndn::security::v2::extractKeyNameFromCertName(), nfd::ManagerBase::extractRequester(), ndn::security::pib::CertificateContainer::get(), ndn::security::pib::KeyContainer::get(), ndn::security::pib::PibMemory::getCertificate(), ndn::security::pib::PibSqlite3::getCertificate(), ndn::security::pib::PibMemory::getDefaultCertificateOfKey(), ndn::security::pib::PibSqlite3::getDefaultCertificateOfKey(), ndn::security::pib::PibMemory::getDefaultKeyOfIdentity(), ndn::security::pib::PibSqlite3::getDefaultKeyOfIdentity(), ndn::security::pib::PibMemory::getKeyBits(), ndn::security::pib::PibSqlite3::getKeyBits(), ndn::security::tpm::getKeyRef(), ndn::security::pib::detail::IdentityImpl::IdentityImpl(), ndn::security::tpm::BackEnd::importKey(), ndn::security::v2::KeyChain::importPrivateKey(), ndn::security::v2::KeyChain::importSafeBag(), ndn::MetadataObject::makeData(), ndn::MetadataObject::MetadataObject(), ndn::security::pib::CertificateContainer::remove(), ndn::security::pib::KeyContainer::remove(), ndn::security::pib::PibMemory::setDefaultCertificateOfKey(), ndn::security::pib::PibSqlite3::setDefaultCertificateOfKey(), ndn::security::v2::KeyChain::setDefaultKey(), ndn::security::pib::PibMemory::setDefaultKeyOfIdentity(), ndn::security::pib::PibSqlite3::setDefaultKeyOfIdentity(), and toUri().

◆ toUri() [2/2]

std::string ndn::Name::toUri ( name::UriFormat  format = name::UriFormat::DEFAULT) const

Get URI representation of the name.

Returns
URI representation; "ndn:" scheme identifier is not included
See also
https://named-data.net/doc/NDN-packet-spec/current/name.html#ndn-uri-scheme
Note
To print URI representation into a stream, it is more efficient to use os << name.

Definition at line 362 of file name.cpp.

References toUri().

◆ hasWire()

bool ndn::Name::hasWire ( ) const
inline

Check if this Name instance already has wire encoding.

Definition at line 112 of file name.hpp.

References ndn::Block::hasWire().

◆ wireEncode() [1/2]

template<encoding::Tag TAG>
size_t ndn::Name::wireEncode ( EncodingImpl< TAG > &  encoder) const

◆ wireEncode() [2/2]

const Block & ndn::Name::wireEncode ( ) const

Perform wire encoding, or return existing wire encoding.

Postcondition
hasWire() == true

Definition at line 132 of file name.cpp.

References ndn::Block::hasWire(), and ndn::Block::parse().

◆ wireDecode()

void ndn::Name::wireDecode ( const Block wire)

◆ deepCopy()

Name ndn::Name::deepCopy ( ) const

Make a deep copy of the name, reallocating the underlying memory buffer.

Definition at line 160 of file name.cpp.

References ndn::Block::resetWire(), and wireEncode().

◆ empty()

◆ size()

◆ get()

const Component& ndn::Name::get ( ssize_t  i) const
inline

Returns an immutable reference to the component at the specified index.

Parameters
izero-based index of the component to return; if negative, it is interpreted as offset from the end of the name
Warning
No bounds checking is performed, using an out-of-range index is undefined behavior.

Definition at line 164 of file name.hpp.

References ndn::Block::elements(), and size().

Referenced by compare(), ndn::security::v2::CertificateBundleFetcher::doFetch(), equals(), getSuccessor(), isPrefixOf(), ndn::security::v2::isValidKeyName(), ndn::security::v2::Certificate::isValidName(), ndn::Interest::matchesData(), and operator[]().

◆ operator[]()

const Component& ndn::Name::operator[] ( ssize_t  i) const
inline

Equivalent to get(i).

Definition at line 175 of file name.hpp.

References get().

◆ at()

const name::Component & ndn::Name::at ( ssize_t  i) const

Returns an immutable reference to the component at the specified index, with bounds checking.

Parameters
izero-based index of the component to return; if negative, it is interpreted as offset from the end of the name
Exceptions
ErrorThe index is out of bounds.

Definition at line 171 of file name.cpp.

References ndn::Block::elements(), NDN_THROW, and size().

Referenced by nfd::ManagerBase::extractRequester(), ndn::security::v2::Certificate::getIssuerId(), ndn::security::v2::Certificate::getKeyId(), getSubName(), and nfd::fw::Strategy::makeInstanceName().

◆ getSubName()

PartialName ndn::Name::getSubName ( ssize_t  iStartComponent,
size_t  nComponents = npos 
) const

Extracts some components as a sub-name (PartialName).

Parameters
iStartComponentzero-based index of the first component; if negative, size()+iStartComponent is used instead
nComponentsnumber of desired components, starting at iStartComponent; use npos to return all components until the end of the name
Returns
a new PartialName containing the extracted components

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.

Definition at line 185 of file name.cpp.

References append(), at(), npos, and size().

Referenced by getPrefix(), and nfd::fw::Strategy::parseInstanceName().

◆ getPrefix()

◆ begin()

const_iterator ndn::Name::begin ( ) const
inline

Begin iterator.

Definition at line 223 of file name.hpp.

References ndn::Block::elements().

Referenced by rend().

◆ end()

const_iterator ndn::Name::end ( ) const
inline

End iterator.

Definition at line 231 of file name.hpp.

References ndn::Block::elements().

Referenced by rbegin().

◆ rbegin()

const_reverse_iterator ndn::Name::rbegin ( ) const
inline

Reverse begin iterator.

Definition at line 239 of file name.hpp.

References end().

Referenced by nfd::fw::Strategy::makeInstanceName().

◆ rend()

const_reverse_iterator ndn::Name::rend ( ) const
inline

Reverse end iterator.

Definition at line 247 of file name.hpp.

References begin().

Referenced by nfd::fw::Strategy::makeInstanceName().

◆ set() [1/2]

Name & ndn::Name::set ( ssize_t  i,
const Component component 
)

Replace the component at the specified index.

Parameters
izero-based index of the component to replace; if negative, it is interpreted as offset from the end of the name
componentthe new component to use as a replacement
Returns
a reference to this name, to allow chaining.
Warning
No bounds checking is performed, using an out-of-range index is undefined behavior.

Definition at line 206 of file name.cpp.

References ndn::Block::elements(), ndn::Block::resetWire(), and size().

◆ set() [2/2]

Name & ndn::Name::set ( ssize_t  i,
Component &&  component 
)

Replace the component at the specified index.

Parameters
izero-based index of the component to replace; if negative, it is interpreted as offset from the end of the name
componentthe new component to use as a replacement
Returns
a reference to this name, to allow chaining.
Warning
No bounds checking is performed, using an out-of-range index is undefined behavior.

Definition at line 218 of file name.cpp.

References ndn::Block::elements(), nonstd::optional_lite::std11::move(), ndn::Block::resetWire(), and size().

◆ append() [1/9]

◆ append() [2/9]

Name& ndn::Name::append ( Component &&  component)
inline

Append a component.

Returns
a reference to this name, to allow chaining.

Definition at line 287 of file name.hpp.

References nonstd::optional_lite::std11::move(), and ndn::Block::push_back().

◆ append() [3/9]

Name& ndn::Name::append ( uint32_t  type,
const uint8_t *  value,
size_t  count 
)
inline

Append a NameComponent of TLV-TYPE type, copying count bytes at value as TLV-VALUE.

Returns
a reference to this name, to allow chaining.

Definition at line 298 of file name.hpp.

References append().

◆ append() [4/9]

Name& ndn::Name::append ( const uint8_t *  value,
size_t  count 
)
inline

Append a GenericNameComponent, copying count bytes at value as TLV-VALUE.

Returns
a reference to this name, to allow chaining.

Definition at line 307 of file name.hpp.

References append().

◆ append() [5/9]

template<class Iterator >
Name& ndn::Name::append ( uint32_t  type,
Iterator  first,
Iterator  last 
)
inline

Append a NameComponent of TLV-TYPE type, copying TLV-VALUE from a range.

Template Parameters
Iteratoran InputIterator dereferencing to a one-octet value type. More efficient implementation is available when it is a RandomAccessIterator.
Parameters
typethe TLV-TYPE.
firstbeginning of the range.
lastpast-end of the range.
Returns
a reference to this name, to allow chaining.

Definition at line 322 of file name.hpp.

References append().

◆ append() [6/9]

template<class Iterator >
Name& ndn::Name::append ( Iterator  first,
Iterator  last 
)
inline

Append a GenericNameComponent, copying TLV-VALUE from a range.

Template Parameters
Iteratoran InputIterator dereferencing to a one-octet value type. More efficient implementation is available when it is a RandomAccessIterator.
Parameters
firstbeginning of the range.
lastpast-end of the range.
Returns
a reference to this name, to allow chaining.

Definition at line 336 of file name.hpp.

References append().

◆ append() [7/9]

Name& ndn::Name::append ( const char *  str)
inline

Append a GenericNameComponent, copying TLV-VALUE from a null-terminated string.

Parameters
stra null-terminated string. Bytes from the string are copied as is, and not interpreted as URI component.
Returns
a reference to this name, to allow chaining.

Definition at line 347 of file name.hpp.

References append().

◆ append() [8/9]

Name& ndn::Name::append ( Block  value)
inline

Append a GenericNameComponent from a TLV element.

Parameters
valuea TLV element. If its TLV-TYPE is tlv::GenericNameComponent, it is appended as is. Otherwise, it is nested into a GenericNameComponent.
Returns
a reference to this name, to allow chaining.

Definition at line 358 of file name.hpp.

References ndn::tlv::GenericNameComponent, nonstd::optional_lite::std11::move(), ndn::Block::push_back(), and ndn::Block::type().

◆ append() [9/9]

Name & ndn::Name::append ( const PartialName name)

Append a PartialName.

Parameters
namethe components to append
Returns
a reference to this name, to allow chaining

Definition at line 242 of file name.cpp.

References append().

◆ appendNumber()

Name& ndn::Name::appendNumber ( uint64_t  number)
inline

Append a component with a nonNegativeInteger.

See also
number the number
Returns
a reference to this name, to allow chaining
See also
https://named-data.net/doc/NDN-packet-spec/current/tlv.html#non-negative-integer-encoding

Definition at line 382 of file name.hpp.

References append(), and ndn::name::Component::fromNumber().

◆ appendNumberWithMarker()

Name& ndn::Name::appendNumberWithMarker ( uint8_t  marker,
uint64_t  number 
)
inline

Append a component with a marked number.

Parameters
marker1-octet marker
numberthe number

The component is encoded as a 1-octet marker, followed by a nonNegativeInteger.

Returns
a reference to this name, to allow chaining
See also
NDN Naming Conventions https://named-data.net/doc/tech-memos/naming-conventions.pdf

Definition at line 397 of file name.hpp.

References append(), and ndn::name::Component::fromNumberWithMarker().

◆ appendVersion()

Name & ndn::Name::appendVersion ( optional< uint64_t >  version = nullopt)

Append a version component.

Parameters
versionthe version number to append; if nullopt, the current UNIX time in milliseconds is used
Returns
a reference to this name, to allow chaining
See also
NDN Naming Conventions https://named-data.net/doc/tech-memos/naming-conventions.pdf

Definition at line 230 of file name.cpp.

References append(), ndn::name::Component::fromVersion(), ndn::time::system_clock::now(), and ndn::time::toUnixTimestamp().

Referenced by ndn::MetadataObject::makeData(), ndn::mgmt::StatusDatasetContext::setPrefix(), and ndn::PrefixAnnouncement::toData().

◆ appendSegment()

Name& ndn::Name::appendSegment ( uint64_t  segmentNo)
inline

Append a segment number (sequential) component.

Returns
a reference to this name, to allow chaining
See also
NDN Naming Conventions https://named-data.net/doc/tech-memos/naming-conventions.pdf

Definition at line 416 of file name.hpp.

References append(), and ndn::name::Component::fromSegment().

Referenced by ndn::MetadataObject::makeData(), and ndn::PrefixAnnouncement::toData().

◆ appendByteOffset()

Name& ndn::Name::appendByteOffset ( uint64_t  offset)
inline

Append a byte offset component.

Returns
a reference to this name, to allow chaining
See also
NDN Naming Conventions https://named-data.net/doc/tech-memos/naming-conventions.pdf

Definition at line 426 of file name.hpp.

References append(), and ndn::name::Component::fromByteOffset().

Referenced by appendSegmentOffset().

◆ appendSegmentOffset()

Name& ndn::Name::appendSegmentOffset ( uint64_t  offset)
inline
Deprecated:
use appendByteOffset

Definition at line 433 of file name.hpp.

References appendByteOffset().

◆ appendTimestamp()

Name & ndn::Name::appendTimestamp ( optional< time::system_clock::TimePoint timestamp = nullopt)

Append a timestamp component.

Parameters
timestampthe timestamp to append; if nullopt, the current system time is used
Returns
a reference to this name, to allow chaining
See also
NDN Naming Conventions https://named-data.net/doc/tech-memos/naming-conventions.pdf

Definition at line 236 of file name.cpp.

References append(), ndn::name::Component::fromTimestamp(), and ndn::time::system_clock::now().

◆ appendSequenceNumber()

Name& ndn::Name::appendSequenceNumber ( uint64_t  seqNo)
inline

Append a sequence number component.

Returns
a reference to this name, to allow chaining
See also
NDN Naming Conventions https://named-data.net/doc/tech-memos/naming-conventions.pdf

Definition at line 451 of file name.hpp.

References append(), and ndn::name::Component::fromSequenceNumber().

Referenced by ndn::util::NotificationStream< Notification >::postNotification().

◆ appendImplicitSha256Digest() [1/2]

Name& ndn::Name::appendImplicitSha256Digest ( ConstBufferPtr  digest)
inline

Append an ImplicitSha256Digest component.

Returns
a reference to this name, to allow chaining

Definition at line 460 of file name.hpp.

References append(), ndn::name::Component::fromImplicitSha256Digest(), and nonstd::optional_lite::std11::move().

Referenced by ndn::Data::getFullName().

◆ appendImplicitSha256Digest() [2/2]

Name& ndn::Name::appendImplicitSha256Digest ( const uint8_t *  digest,
size_t  digestSize 
)
inline

Append an ImplicitSha256Digest component.

Returns
a reference to this name, to allow chaining

Definition at line 469 of file name.hpp.

References append(), and ndn::name::Component::fromImplicitSha256Digest().

◆ appendParametersSha256Digest() [1/2]

Name& ndn::Name::appendParametersSha256Digest ( ConstBufferPtr  digest)
inline

Append a ParametersSha256Digest component.

Returns
a reference to this name, to allow chaining

Definition at line 478 of file name.hpp.

References append(), ndn::name::Component::fromParametersSha256Digest(), and nonstd::optional_lite::std11::move().

◆ appendParametersSha256Digest() [2/2]

Name& ndn::Name::appendParametersSha256Digest ( const uint8_t *  digest,
size_t  digestSize 
)
inline

Append a ParametersSha256Digest component.

Returns
a reference to this name, to allow chaining

Definition at line 487 of file name.hpp.

References append(), and ndn::name::Component::fromParametersSha256Digest().

◆ appendParametersSha256DigestPlaceholder()

Name & ndn::Name::appendParametersSha256DigestPlaceholder ( )

Append a placeholder for a ParametersSha256Digest component.

Returns
a reference to this name, to allow chaining

Definition at line 262 of file name.cpp.

References append(), ndn::tlv::ParametersSha256DigestComponent, and ndn::SHA256_OF_EMPTY_STRING.

◆ push_back()

template<class T >
void ndn::Name::push_back ( const T &  component)
inline

Append a component.

Note
This makes push_back an alias of append, giving Name a similar API as STL vector.

Definition at line 503 of file name.hpp.

References append().

◆ erase()

void ndn::Name::erase ( ssize_t  i)

Erase the component at the specified index.

Parameters
izero-based index of the component to replace; if negative, it is interpreted as offset from the end of the name
Warning
No bounds checking is performed, using an out-of-range index is undefined behavior.

Definition at line 270 of file name.cpp.

References ndn::Block::elements_begin(), ndn::Block::erase(), and size().

Referenced by ndn::Interest::unsetApplicationParameters().

◆ clear()

◆ getSuccessor()

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:

  • successor of / is /sha256digest=0000000000000000000000000000000000000000000000000000000000000000.
  • successor of /sha256digest=0000000000000000000000000000000000000000000000000000000000000000 is /sha256digest=0000000000000000000000000000000000000000000000000000000000000001.
  • successor of /sha256digest=ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff is /2=....
  • successor of /P/A is /P/B.
  • successor of /Q/FF is /Q/%00%00.
Returns
a new Name containing the successor

Definition at line 288 of file name.cpp.

References append(), empty(), get(), and getPrefix().

◆ isPrefixOf()

bool ndn::Name::isPrefixOf ( const Name other) const

Check if this name is a prefix of another name.

This name is a prefix of other if the N components of this name are same as the first N components of other.

Return values
truethis name is a prefix of other
falsethis name is not a prefix of other

Definition at line 299 of file name.cpp.

References get(), and size().

Referenced by nfd::fw::asf::FaceInfo::cancelTimeout(), ndn::security::v2::validator_config::checkNameRelation(), ndn::security::v2::ValidationPolicySimpleHierarchy::checkPolicy(), ndn::InterestFilter::doesMatch(), ndn::InMemoryStorage::erase(), ndn::security::v2::CertificateCache::find(), ndn::security::v2::TrustAnchorContainer::find(), ndn::Interest::matchesData(), ndn::InMemoryStorage::selectChild(), and ndn::mgmt::StatusDatasetContext::setPrefix().

◆ equals()

bool ndn::Name::equals ( const Name other) const

Check if this name equals another name.

Two names are equal if they have the same number of components, and components at each index are equal.

Definition at line 315 of file name.cpp.

References get(), and size().

◆ compare() [1/2]

int ndn::Name::compare ( const Name other) const
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.

Parameters
otherThe other Name to compare with.
Return values
negativethis comes before other in canonical ordering
zerothis equals other
positivethis comes after other in canonical ordering
See also
https://named-data.net/doc/NDN-packet-spec/current/name.html#canonical-order

Definition at line 591 of file name.hpp.

References npos.

Referenced by nfd::cs::compareDataWithData(), and nfd::cs::compareQueryWithData().

◆ compare() [2/2]

int ndn::Name::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

Equivalent to getSubName(pos1, count1).compare(other.getSubName(pos2, count2)).

Definition at line 329 of file name.cpp.

References ndn::name::Component::compare(), get(), and size().

Friends And Related Function Documentation

◆ operator==

bool operator== ( const Name lhs,
const Name rhs 
)
friend

Definition at line 610 of file name.hpp.

◆ operator!=

bool operator!= ( const Name lhs,
const Name rhs 
)
friend

Definition at line 616 of file name.hpp.

◆ operator<

bool operator< ( const Name lhs,
const Name rhs 
)
friend

Definition at line 621 of file name.hpp.

◆ operator<=

bool operator<= ( const Name lhs,
const Name rhs 
)
friend

Definition at line 627 of file name.hpp.

◆ operator>

bool operator> ( const Name lhs,
const Name rhs 
)
friend

Definition at line 634 of file name.hpp.

◆ operator>=

bool operator>= ( const Name lhs,
const Name rhs 
)
friend

Definition at line 640 of file name.hpp.

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const Name name 
)
friend

Print URI representation of a name.

See also
https://named-data.net/doc/NDN-packet-spec/current/name.html#ndn-uri-scheme

Definition at line 648 of file name.hpp.

Member Data Documentation

◆ npos

const size_t ndn::Name::npos = std::numeric_limits<size_t>::max()
static

Indicates "until the end" in getSubName() and compare().

Definition at line 658 of file name.hpp.

Referenced by nfd::pit::Entry::canMatch(), compare(), and getSubName().


The documentation for this class was generated from the following files:
ndn::Name::Name
Name()
Create an empty name.
Definition: name.cpp:54
ndn::name
Definition: name-component-types.hpp:33