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

Name abstraction to represent an absolute name. More...

#include <name.hpp>

Inheritance diagram for ndn::Name:
Collaboration diagram for ndn::Name:

Classes

class  Error
 Error that can be thrown from Name. More...
 

Public Types

typedef name::Component Component
 
typedef std::vector< Componentcomponent_container
 
typedef Component value_type
 
typedef void allocator_type
 
typedef Componentreference
 
typedef const Component const_reference
 
typedef Componentpointer
 
typedef const Componentconst_pointer
 
typedef Componentiterator
 
typedef const Componentconst_iterator
 
typedef boost::reverse_iterator< iteratorreverse_iterator
 
typedef boost::reverse_iterator< const_iteratorconst_reverse_iterator
 
typedef component_container::difference_type difference_type
 
typedef component_container::size_type size_type
 

Public Member Functions

 Name ()
 Create a new Name with no components. More...
 
 Name (const Block &wire)
 Create Name object from wire block. More...
 
 Name (const char *uri)
 Create name from uri (NDN URI scheme) More...
 
 Name (std::string uri)
 Create name from uri (NDN URI scheme) More...
 
Name deepCopy () const
 Make a deep copy of the name, reallocating the underlying memory buffer. More...
 
template<encoding::Tag TAG>
size_t wireEncode (EncodingImpl< TAG > &encoder) const
 Fast encoding or block size estimation. More...
 
const BlockwireEncode () const
 
void wireDecode (const Block &wire)
 
bool hasWire () const
 Check if already has wire. More...
 
Nameappend (const uint8_t *value, size_t valueLength)
 Append a new component, copying from value of length valueLength. More...
 
template<class Iterator >
Nameappend (Iterator first, Iterator last)
 Append a new component, copying from value frome the range [first, last) of bytes. More...
 
Nameappend (const Component &value)
 Append component value. More...
 
Nameappend (const char *value)
 Append name component that represented as a string. More...
 
Nameappend (const Block &value)
 
Nameappend (const PartialName &name)
 append a PartialName to this Name. More...
 
void clear ()
 Clear all the components. More...
 
PartialName getSubName (ssize_t iStartComponent, size_t nComponents=npos) const
 Extract a sub-name (PartialName) of nComponents components starting from iStartComponent. More...
 
PartialName getPrefix (ssize_t nComponents) const
 Extract a prefix (PartialName) of the name, containing first nComponents components. More...
 
std::string toUri () const
 Encode this name as a URI. More...
 
NameappendNumber (uint64_t number)
 Append a component with the number encoded as nonNegativeInteger. More...
 
NameappendNumberWithMarker (uint8_t marker, uint64_t number)
 Create a component encoded as NameComponentWithMarker. More...
 
NameappendVersion (uint64_t version)
 Append version using NDN naming conventions. More...
 
NameappendVersion ()
 Append version using NDN naming conventions based on current UNIX timestamp in milliseconds. More...
 
NameappendSegment (uint64_t segmentNo)
 Append segment number (sequential) using NDN naming conventions. More...
 
NameappendSegmentOffset (uint64_t offset)
 Append segment byte offset using NDN naming conventions. More...
 
NameappendTimestamp (const time::system_clock::TimePoint &timePoint=time::system_clock::now())
 Append timestamp using NDN naming conventions. More...
 
NameappendSequenceNumber (uint64_t seqNo)
 Append sequence number using NDN naming conventions. More...
 
NameappendImplicitSha256Digest (const ConstBufferPtr &digest)
 Append ImplicitSha256Digest. More...
 
NameappendImplicitSha256Digest (const uint8_t *digest, size_t digestSize)
 Append ImplicitSha256Digest. More...
 
Name getSuccessor () const
 Get the successor of a name. More...
 
bool equals (const Name &name) const
 Check if this name has the same component count and components as 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...
 
bool empty () const
 Check if name is emtpy. More...
 
size_t size () const
 Get the number of components. More...
 
const Componentget (ssize_t i) const
 Get the component at the given index. More...
 
const Componentoperator[] (ssize_t i) const
 
const Componentat (ssize_t i) const
 Get component at the specified index. 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...
 
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). More...
 
const_iterator end () const
 End iterator (const). More...
 
const_reverse_iterator rbegin () const
 Reverse begin iterator (const). More...
 
const_reverse_iterator rend () const
 Reverse end iterator (const). More...
 

Static Public Attributes

static const size_t npos = std::numeric_limits<size_t>::max()
 indicates "until the end" in getSubName and compare More...
 

Detailed Description

Name abstraction to represent an absolute name.

Definition at line 46 of file name.hpp.

Member Typedef Documentation

◆ Component

Definition at line 62 of file name.hpp.

◆ component_container

Definition at line 64 of file name.hpp.

◆ value_type

Definition at line 66 of file name.hpp.

◆ allocator_type

Definition at line 67 of file name.hpp.

◆ reference

Definition at line 68 of file name.hpp.

◆ const_reference

Definition at line 69 of file name.hpp.

◆ pointer

Definition at line 70 of file name.hpp.

◆ const_pointer

Definition at line 71 of file name.hpp.

◆ iterator

Definition at line 72 of file name.hpp.

◆ const_iterator

Definition at line 73 of file name.hpp.

◆ reverse_iterator

typedef boost::reverse_iterator<iterator> ndn::Name::reverse_iterator

Definition at line 75 of file name.hpp.

◆ const_reverse_iterator

typedef boost::reverse_iterator<const_iterator> ndn::Name::const_reverse_iterator

Definition at line 76 of file name.hpp.

◆ difference_type

typedef component_container::difference_type ndn::Name::difference_type

Definition at line 78 of file name.hpp.

◆ size_type

typedef component_container::size_type ndn::Name::size_type

Definition at line 79 of file name.hpp.

Constructor & Destructor Documentation

◆ Name() [1/4]

ndn::Name::Name ( )

Create a new Name with no components.

Definition at line 46 of file name.cpp.

Referenced by ndn::operator>>().

◆ Name() [2/4]

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

Create Name object from wire block.

This is a more efficient equivalent for

name.wireDecode(wire);

Definition at line 51 of file name.cpp.

References ndn::Block::parse().

◆ Name() [3/4]

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

Create name from uri (NDN URI scheme)

Parameters
uriThe null-terminated URI string

Definition at line 57 of file name.cpp.

◆ Name() [4/4]

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

Create name from uri (NDN URI scheme)

Parameters
uriThe URI string

Definition at line 62 of file name.cpp.

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

Member Function Documentation

◆ deepCopy()

Name ndn::Name::deepCopy ( ) const

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

Definition at line 112 of file name.cpp.

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

◆ 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

Definition at line 143 of file name.cpp.

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

◆ wireDecode()

◆ hasWire()

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

Check if already has wire.

Definition at line 618 of file name.hpp.

◆ append() [1/6]

◆ append() [2/6]

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

Append a new component, copying from value frome the range [first, last) of bytes.

Parameters
firstIterator pointing to the beginning of the buffer
lastIterator pointing to the ending of the buffer
Template Parameters
Iteratoriterator type satisfying at least InputIterator concept. Implementation is more optimal when the iterator type satisfies RandomAccessIterator concept. It is required that sizeof(std::iterator_traits<Iterator>::value_type) == 1.
Returns
This name so that you can chain calls to append.

Definition at line 157 of file name.hpp.

References push_back().

◆ append() [3/6]

Name& ndn::Name::append ( const Component value)
inline

Append component value.

Definition at line 167 of file name.hpp.

References push_back().

◆ append() [4/6]

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

Append name component that represented as a string.

Note that this method is necessary to ensure correctness and unambiguity of append("string") operations (both Component and Name can be implicitly converted from string, each having different outcomes

Definition at line 181 of file name.hpp.

References push_back().

◆ append() [5/6]

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

Definition at line 188 of file name.hpp.

References append(), ndn::tlv::NameComponent, push_back(), and ndn::Block::type().

◆ append() [6/6]

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

append a PartialName to this Name.

Parameters
namethe components to append
Returns
this name

Definition at line 179 of file name.cpp.

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

◆ clear()

void ndn::Name::clear ( )
inline

Clear all the components.

Definition at line 210 of file name.hpp.

References getSubName(), ndn::tlv::Name, and npos.

Referenced by ndn::KeyLocator::clear(), ndn::Data::onChanged(), ndn::security::SigningInfo::setSha256Signing(), and ndn::Data::wireDecode().

◆ getSubName()

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

Extract a sub-name (PartialName) of nComponents components starting from iStartComponent.

Parameters
iStartComponentindex of the first component; if iStartComponent is negative, size()+iStartComponent is used instead
nComponentsThe number of components starting at iStartComponent. Use npos to get the Partial Name until the end of this Name.

If iStartComponent is out of bounds and is negative, returns the components starting from the beginning of the Name. If iStartComponent is out of bounds and is positive, returns the component "/". If nComponents is out of bounds, returns the components until the end of this Name

Returns
A new partial name

Definition at line 262 of file name.cpp.

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

Referenced by ndn::security::v1::IdentityCertificate::certificateNameToPublicKeyName(), clear(), getPrefix(), and ndn::security::KeyChain::prepareUnsignedIdentityCertificate().

◆ getPrefix()

PartialName ndn::Name::getPrefix ( ssize_t  nComponents) const
inline

Extract a prefix (PartialName) of the name, containing first nComponents components.

Parameters
nComponentsThe number of prefix components. If nComponents is -N then return the prefix up to name.size() - N. For example getPrefix(-1) returns the name without the final component.
Returns
A new partial name

Definition at line 241 of file name.hpp.

References appendImplicitSha256Digest(), appendNumber(), appendNumberWithMarker(), appendSegment(), appendSegmentOffset(), appendSequenceNumber(), appendTimestamp(), appendVersion(), equals(), getSubName(), getSuccessor(), isPrefixOf(), ndn::time::system_clock::now(), and toUri().

Referenced by ndn::security::SecPublicInfoSqlite3::addCertificate(), ndn::security::PibMemory::addCertificate(), ndn::security::PibSqlite3::addCertificate(), ndn::security::SecPublicInfo::addCertificateAsSystemDefault(), ndn::security::SecPublicInfoSqlite3::addKey(), nfd::fw::AccessStrategy::beforeSatisfyInterest(), ndn::security::conf::KeyLocatorChecker::check(), ndn::security::SecPublicInfoSqlite3::deletePublicKeyInfo(), ndn::security::SecPublicInfoSqlite3::doesPublicKeyExist(), nfd::strategy_choice::StrategyChoice::erase(), ndn::util::SegmentFetcher::fetch(), nfd::cs::Cs::find(), nfd::name_tree::NameTree::findLongestPrefixMatch(), nfd::rib::Rib::findParent(), ndn::security::SecPublicInfoSqlite3::getAllCertificateNamesOfKey(), ndn::security::SecPublicInfoSqlite3::getDefaultCertificateNameForKey(), ndn::security::SecPublicInfoSqlite3::getDefaultKeyNameForIdentity(), ndn::security::PibMemory::getKeysOfIdentity(), nfd::fw::asf::AsfMeasurements::getOrCreateNamespaceInfo(), ndn::security::SecPublicInfoSqlite3::getPublicKey(), ndn::security::SecPublicInfoSqlite3::getPublicKeyType(), ndn::security::CertificateCacheTtl::getSize(), getSuccessor(), ndn::security::KeyChain::importIdentity(), nfd::name_tree::NameTree::lookup(), ndn::security::conf::Filter::match(), nfd::pit::Pit::Pit(), ndn::security::KeyChain::prepareUnsignedIdentityCertificate(), ndn::util::InMemoryStorage::selectChild(), ndn::security::KeyChain::selfSign(), nfd::name_tree::Entry::setParent(), and nfd::name_tree::Hashtable::~Hashtable().

◆ toUri()

std::string ndn::Name::toUri ( ) const

Encode this name as a URI.

Returns
The encoded URI.

Definition at line 171 of file name.cpp.

Referenced by ndn::security::SecTpmOsx::addAppToAcl(), ndn::security::SecPublicInfoSqlite3::addCertificate(), ndn::security::SecPublicInfoSqlite3::addIdentity(), ndn::security::SecPublicInfoSqlite3::addKey(), ndn::security::v1::IdentityCertificate::certificateNameToPublicKeyName(), ndn::security::ValidatorRegex::checkPolicy(), ndn::security::ValidatorConfig::checkPolicy(), ndn::security::SecPublicInfoSqlite3::deleteCertificateInfo(), ndn::security::SecPublicInfoSqlite3::deleteIdentityInfo(), ndn::security::SecTpmFile::deleteKeyPairInTpm(), ndn::security::SecTpmOsx::deleteKeyPairInTpmInternal(), ndn::security::SecPublicInfoSqlite3::deletePublicKeyInfo(), ndn::security::SecPublicInfoSqlite3::doesCertificateExist(), ndn::security::SecPublicInfoSqlite3::doesIdentityExist(), ndn::security::SecTpmFile::doesKeyExistInTpm(), ndn::security::SecPublicInfoSqlite3::doesPublicKeyExist(), nfd::TablesConfigSection::ensureConfigured(), ndn::security::SecTpmFile::exportPrivateKeyPkcs8FromTpm(), ndn::security::SecTpmOsx::exportPrivateKeyPkcs8FromTpmInternal(), ndn::security::SecTpmFile::generateKeyPairInTpm(), ndn::security::SecPublicInfoSqlite3::getAllCertificateNamesOfKey(), ndn::security::SecPublicInfoSqlite3::getAllKeyNamesOfIdentity(), ndn::security::SecPublicInfoSqlite3::getCertificate(), ndn::security::SecPublicInfoSqlite3::getDefaultCertificateNameForKey(), ndn::security::SecPublicInfoSqlite3::getDefaultIdentity(), ndn::security::SecPublicInfoSqlite3::getDefaultKeyNameForIdentity(), ndn::security::KeyChain::getDefaultKeyParamsForIdentity(), ndn::security::SecPublicInfo::getNewKeyName(), getPrefix(), ndn::security::SecPublicInfoSqlite3::getPublicKey(), ndn::security::SecTpmOsx::getPublicKeyFromTpm(), ndn::security::SecTpmFile::getPublicKeyFromTpm(), ndn::security::SecPublicInfoSqlite3::getPublicKeyType(), ndn::security::Identity::Identity(), ndn::security::KeyChain::importIdentity(), ndn::security::SecTpmFile::importPrivateKeyPkcs8IntoTpm(), ndn::security::SecTpmOsx::importPrivateKeyPkcs8IntoTpmInternal(), ndn::security::SecTpmOsx::importPublicKeyPkcs1IntoTpm(), ndn::security::SecTpmFile::importPublicKeyPkcs1IntoTpm(), nfd::CommandAuthenticator::makeAuthorization(), ndn::security::Validator::onData(), ndn::security::Validator::onNack(), nfd::rib::RibManager::onRibUpdateFailure(), ndn::security::Validator::onTimeout(), ndn::security::KeyChain::prepareUnsignedIdentityCertificate(), ndn::security::KeyChain::selfSign(), ndn::security::SecTpmFile::signInTpm(), and ndn::security::SecTpmOsx::signInTpmInternal().

◆ appendNumber()

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

Append a component with the number encoded as nonNegativeInteger.

See also
http://named-data.net/doc/ndn-tlv/tlv.html#non-negative-integer-encoding
Parameters
numberThe non-negative number
Returns
This name so that you can chain calls to append.

Definition at line 192 of file name.cpp.

References ndn::name::Component::fromNumber(), and ndn::Block::push_back().

Referenced by getPrefix().

◆ appendNumberWithMarker()

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

Create a component encoded as NameComponentWithMarker.

See also
http://named-data.net/doc/tech-memos/naming-conventions.pdf
Parameters
marker1-byte marker octet
numberThe non-negative number

Definition at line 199 of file name.cpp.

References ndn::name::Component::fromNumberWithMarker(), and ndn::Block::push_back().

Referenced by getPrefix().

◆ appendVersion() [1/2]

◆ appendVersion() [2/2]

Name & ndn::Name::appendVersion ( )

Append version using NDN naming conventions based on current UNIX timestamp in milliseconds.

See also
http://named-data.net/doc/tech-memos/naming-conventions.pdf

Definition at line 213 of file name.cpp.

References ndn::time::system_clock::now(), and ndn::time::toUnixTimestamp().

Referenced by getPrefix().

◆ appendSegment()

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

Append segment number (sequential) using NDN naming conventions.

See also
http://named-data.net/doc/tech-memos/naming-conventions.pdf

Definition at line 220 of file name.cpp.

References ndn::name::Component::fromSegment(), and ndn::Block::push_back().

Referenced by ndn::util::SegmentFetcher::fetch(), and getPrefix().

◆ appendSegmentOffset()

Name & ndn::Name::appendSegmentOffset ( uint64_t  offset)

Append segment byte offset using NDN naming conventions.

See also
http://named-data.net/doc/tech-memos/naming-conventions.pdf

Definition at line 227 of file name.cpp.

References ndn::name::Component::fromSegmentOffset(), and ndn::Block::push_back().

Referenced by getPrefix().

◆ appendTimestamp()

Name & ndn::Name::appendTimestamp ( const time::system_clock::TimePoint timePoint = time::system_clock::now())

Append timestamp using NDN naming conventions.

See also
http://named-data.net/doc/tech-memos/naming-conventions.pdf

Definition at line 234 of file name.cpp.

References ndn::name::Component::fromTimestamp(), and ndn::Block::push_back().

Referenced by getPrefix().

◆ appendSequenceNumber()

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

◆ appendImplicitSha256Digest() [1/2]

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

Append ImplicitSha256Digest.

Definition at line 248 of file name.cpp.

References ndn::name::Component::fromImplicitSha256Digest(), and ndn::Block::push_back().

Referenced by ndn::Data::getFullName(), and getPrefix().

◆ appendImplicitSha256Digest() [2/2]

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

Append ImplicitSha256Digest.

Definition at line 255 of file name.cpp.

References ndn::name::Component::fromImplicitSha256Digest(), and ndn::Block::push_back().

◆ 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 for / is /%00
  • successor for /%00%01/%01%02 is /%00%01/%01%03
  • successor for /%00%01/%01FF is /%00%01/%02%00
  • successor for /%00%01/FFFF is /%00%01/%00%00%00
Returns
a new name

Definition at line 281 of file name.cpp.

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

Referenced by nfd::cs::Cs::find(), and getPrefix().

◆ equals()

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

Check if this name has the same component count and components as the given name.

Parameters
nameThe Name to check.
Returns
true if the names are equal, otherwise false.

Definition at line 294 of file name.cpp.

References at(), and size().

Referenced by getPrefix(), operator!=(), and operator==().

◆ isPrefixOf()

◆ empty()

◆ size()

size_t ndn::Name::size ( ) const
inline

Get the number of components.

Returns
The number of components.

Definition at line 400 of file name.hpp.

Referenced by ndn::mgmt::Dispatcher::addStatusDataset(), append(), at(), ndn::security::v1::IdentityCertificate::certificateNameToPublicKeyName(), ndn::security::conf::KeyLocatorChecker::check(), ndn::security::ValidatorConfig::checkPolicy(), ndn::security::CommandInterestValidator::checkPolicy(), compare(), nfd::cs::compareQueryWithData(), nfd::name_tree::computeHash(), nfd::name_tree::computeHashes(), nfd::rib::AutoPrefixPropagator::disable(), ndn::InterestFilter::doesMatch(), equals(), nfd::strategy_choice::StrategyChoice::erase(), ndn::RegexTopMatcher::expand(), nfd::cs::Cs::find(), nfd::name_tree::NameTree::findExactMatch(), nfd::name_tree::NameTree::findLongestPrefixMatch(), nfd::rib::Rib::findParent(), get(), nfd::fw::asf::AsfMeasurements::getOrCreateNamespaceInfo(), getSubName(), nfd::strategy_choice::StrategyChoice::install(), isPrefixOf(), nfd::name_tree::NameTree::lookup(), nfd::fw::Strategy::lookupFib(), nfd::CommandAuthenticator::makeAuthorization(), ndn::RegexTopMatcher::match(), ndn::security::conf::Filter::match(), ndn::Interest::matchesData(), ndn::Interest::matchesName(), ndn::security::conf::RelationNameFilter::matchName(), nfd::pit::Pit::Pit(), ndn::security::KeyChain::prepareUnsignedIdentityCertificate(), ndn::mgmt::Dispatcher::removeTopPrefix(), ndn::util::InMemoryStorage::selectChild(), ndn::security::v1::IdentityCertificate::setName(), ndn::nfd::CommandOptions::setSigningInfo(), ndn::nfd::StrategyChoiceUnsetCommand::validateRequest(), and ndn::security::Validator::verifySignature().

◆ get()

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

◆ operator[]()

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

Definition at line 420 of file name.hpp.

◆ at()

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

Get component at the specified index.

Unlike get() and operator[] methods, at() checks for out of bounds and will throw Name::Error when it happens

Exceptions
Name::Errorif index out of bounds

Definition at line 434 of file name.hpp.

References ndn::Name::Error::Error(), and size().

Referenced by append(), compare(), equals(), nfd::ManagerBase::extractRequester(), nfd::name_tree::NameTree::findLongestPrefixMatch(), getSubName(), isPrefixOf(), and nfd::name_tree::NameTree::lookup().

◆ 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
http://named-data.net/doc/ndn-tlv/name.html#canonical-order

Definition at line 466 of file name.hpp.

References npos.

Referenced by nfd::cs::compareDataWithData(), nfd::cs::compareQueryWithData(), operator<(), operator<=(), operator>(), operator>=(), and nfd::name_tree::Hashtable::~Hashtable().

◆ 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

This is equivalent to this->getSubName(pos1, count1).compare(other.getSubName(pos2, count2));

Definition at line 324 of file name.cpp.

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

◆ push_back()

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

Append the component.

Parameters
componentThe component of type T.

Definition at line 485 of file name.hpp.

References append().

Referenced by append().

◆ operator==()

bool ndn::Name::operator== ( const Name name) const
inline

Check if this name has the same component count and components as the given name.

Parameters
nameThe Name to check.
Returns
true if the names are equal, otherwise false.

Definition at line 496 of file name.hpp.

References equals().

◆ operator!=()

bool ndn::Name::operator!= ( const Name name) const
inline

Check if this name has the same component count and components as the given name.

Parameters
nameThe Name to check.
Returns
true if the names are not equal, otherwise false.

Definition at line 507 of file name.hpp.

References equals().

◆ operator<=()

bool ndn::Name::operator<= ( const Name other) const
inline

Return true if this is less than or equal to the other Name in the NDN canonical ordering.

Parameters
otherThe other Name to compare with.
See also
http://named-data.net/doc/ndn-tlv/name.html#canonical-order

Definition at line 519 of file name.hpp.

References compare().

◆ operator<()

bool ndn::Name::operator< ( const Name other) const
inline

Return true if this is less than the other Name in the NDN canonical ordering.

Parameters
otherThe other Name to compare with.
See also
http://named-data.net/doc/ndn-tlv/name.html#canonical-order

Definition at line 531 of file name.hpp.

References compare().

◆ operator>=()

bool ndn::Name::operator>= ( const Name other) const
inline

Return true if this is less than or equal to the other Name in the NDN canonical ordering.

Parameters
otherThe other Name to compare with.
See also
http://named-data.net/doc/ndn-tlv/name.html#canonical-order

Definition at line 543 of file name.hpp.

References compare().

◆ operator>()

bool ndn::Name::operator> ( const Name other) const
inline

Return true if this is greater than the other Name in the NDN canonical ordering.

Parameters
otherThe other Name to compare with.
See also
http://named-data.net/doc/ndn-tlv/name.html#canonical-order

Definition at line 555 of file name.hpp.

References compare().

◆ begin()

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

◆ end()

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

End iterator (const).

Todo:
Check if this crash when there are no elements in the buffer

Definition at line 579 of file name.hpp.

Referenced by ndn::RegexTopMatcher::fromName(), ndn::SecRuleRelative::matchSignerName(), ndn::operator<<(), and rbegin().

◆ rbegin()

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

Reverse begin iterator (const).

Definition at line 588 of file name.hpp.

References end().

Referenced by wireEncode().

◆ rend()

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

Reverse end iterator (const).

Definition at line 597 of file name.hpp.

References begin().

Referenced by wireEncode().

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 605 of file name.hpp.

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


The documentation for this class was generated from the following files: