Represents an absolute name. More...
#include <name.hpp>
Classes | |
class | Error |
Public Types | |
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... | |
std::string | toUri () 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 Block & | wireEncode () 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... | |
bool | empty () const |
Check if name is empty. More... | |
size_t | size () const |
Get number of components. More... | |
const Component & | get (ssize_t i) const |
Get the component at the given index. More... | |
const Component & | operator[] (ssize_t i) const |
Equivalent to get(i) More... | |
const Component & | at (ssize_t i) const |
Get the component at the given index. More... | |
PartialName | getSubName (ssize_t iStartComponent, size_t nComponents=npos) const |
Extract some components as a sub-name (PartialName) More... | |
PartialName | getPrefix (ssize_t nComponents) const |
Extract 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... | |
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 & | 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 & | appendVersion (uint64_t version) |
Append a version component. More... | |
Name & | appendVersion () |
Append a version component based on current time. More... | |
Name & | appendSegment (uint64_t segmentNo) |
Append a segment number (sequential) component. More... | |
Name & | appendSegmentOffset (uint64_t offset) |
Append a segment byte offset component. More... | |
Name & | appendTimestamp (const time::system_clock::TimePoint &timePoint) |
Append a timestamp component. More... | |
Name & | appendTimestamp () |
Append a timestamp component based on current time. More... | |
Name & | appendSequenceNumber (uint64_t seqNo) |
Append a sequence number component. More... | |
Name & | appendImplicitSha256Digest (const ConstBufferPtr &digest) |
Append an ImplicitSha256Digest component. More... | |
Name & | appendImplicitSha256Digest (const uint8_t *digest, size_t digestSize) |
Append an ImplicitSha256Digest component. More... | |
Name & | append (const PartialName &name) |
Append a PartialName. More... | |
template<class T > | |
void | push_back (const T &component) |
Append a component. 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... | |
using ndn::Name::Component = name::Component |
using ndn::Name::component_container = std::vector<Component> |
using ndn::Name::value_type = Component |
using ndn::Name::allocator_type = void |
using ndn::Name::reference = Component& |
using ndn::Name::const_reference = const Component& |
using ndn::Name::pointer = Component* |
using ndn::Name::const_pointer = const Component* |
using ndn::Name::iterator = const Component* |
using ndn::Name::const_iterator = const Component* |
using ndn::Name::reverse_iterator = std::reverse_iterator<iterator> |
using ndn::Name::const_reverse_iterator = std::reverse_iterator<const_iterator> |
using ndn::Name::difference_type = component_container::difference_type |
using ndn::Name::size_type = component_container::size_type |
ndn::Name::Name | ( | ) |
|
explicit |
Decode Name from wire encoding.
tlv::Error | wire encoding is invalid |
This is a more efficient equivalent for
Definition at line 60 of file name.cpp.
References ndn::Block::parse().
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 |
Definition at line 71 of file name.cpp.
References append(), and ndn::name::Component::fromEscapedString().
std::string ndn::Name::toUri | ( | ) | const |
Get URI representation of the name.
os << name
. Definition at line 117 of file name.cpp.
Referenced by ndn::security::pib::CertificateContainer::add(), ndn::security::pib::KeyContainer::add(), ndn::security::v2::KeyChain::addCertificate(), ndn::security::v2::ValidationPolicySimpleHierarchy::checkPolicy(), ndn::security::v2::validator_config::ValidationPolicyConfig::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(), 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::tpm::BackEndOsx::Impl::getKey(), ndn::security::pib::PibMemory::getKeyBits(), ndn::security::pib::PibSqlite3::getKeyBits(), ndn::security::pib::detail::IdentityImpl::IdentityImpl(), ndn::security::tpm::BackEnd::importKey(), ndn::security::v2::KeyChain::importSafeBag(), 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(), and ndn::security::pib::PibSqlite3::setDefaultKeyOfIdentity().
|
inline |
Check if this Name instance already has wire encoding.
Definition at line 113 of file name.hpp.
References ndn::Block::hasWire().
size_t ndn::Name::wireEncode | ( | EncodingImpl< TAG > & | encoder | ) | const |
Fast encoding or block size estimation.
Definition at line 126 of file name.cpp.
References ndn::tlv::Name.
Referenced by ndn::security::pib::PibSqlite3::addCertificate(), ndn::security::pib::PibSqlite3::addIdentity(), ndn::security::pib::PibSqlite3::addKey(), deepCopy(), ndn::security::pib::PibSqlite3::getCertificate(), ndn::security::pib::PibSqlite3::getCertificatesOfKey(), ndn::security::pib::PibSqlite3::getDefaultCertificateOfKey(), ndn::security::pib::PibSqlite3::getDefaultKeyOfIdentity(), ndn::security::pib::PibSqlite3::getKeyBits(), ndn::security::pib::PibSqlite3::getKeysOfIdentity(), ndn::security::pib::PibSqlite3::hasCertificate(), ndn::security::pib::PibSqlite3::hasIdentity(), ndn::security::pib::PibSqlite3::hasKey(), ndn::security::parse(), ndn::security::pib::PibSqlite3::removeCertificate(), ndn::security::pib::PibSqlite3::removeIdentity(), ndn::security::pib::PibSqlite3::removeKey(), ndn::security::pib::PibSqlite3::setDefaultCertificateOfKey(), ndn::security::pib::PibSqlite3::setDefaultIdentity(), ndn::security::pib::PibSqlite3::setDefaultKeyOfIdentity(), ndn::security::v2::KeyChain::sign(), ndn::security::tpm::BackEndFile::Impl::toFileName(), ndn::nfd::StrategyChoice::wireEncode(), ndn::Data::wireEncode(), ndn::Interest::wireEncode(), ndn::KeyLocator::wireEncode(), ndn::nfd::ControlParameters::wireEncode(), ndn::nfd::FibEntry::wireEncode(), and ndn::nfd::RibEntry::wireEncode().
const Block & ndn::Name::wireEncode | ( | ) | const |
Perform wire encoding, or return existing wire encoding.
Definition at line 141 of file name.cpp.
References ndn::Block::hasWire(), and ndn::Block::parse().
void ndn::Name::wireDecode | ( | const Block & | wire | ) |
Decode name from wire encoding.
tlv::Error | wire encoding is invalid |
Definition at line 159 of file name.cpp.
References ndn::tlv::Name, ndn::Block::parse(), and ndn::Block::type().
Referenced by ndn::nfd::StrategyChoice::wireDecode(), ndn::KeyLocator::wireDecode(), ndn::nfd::ControlParameters::wireDecode(), ndn::Data::wireDecode(), ndn::nfd::FibEntry::wireDecode(), and ndn::nfd::RibEntry::wireDecode().
Name ndn::Name::deepCopy | ( | ) | const |
Make a deep copy of the name, reallocating the underlying memory buffer.
Definition at line 169 of file name.cpp.
References ndn::Block::resetWire(), and wireEncode().
|
inline |
Check if name is empty.
Definition at line 146 of file name.hpp.
References ndn::Block::elements().
Referenced by nfd::cs::compareQueryWithData(), ndn::security::v2::CertificateBundleFetcher::doFetch(), ndn::Data::getFullName(), nfd::measurements::Measurements::getParent(), getSuccessor(), nfd::name_tree::NameTree::lookup(), and ndn::InMemoryStorage::selectChild().
|
inline |
Get number of components.
Definition at line 154 of file name.hpp.
References ndn::Block::elements_size().
Referenced by at(), ndn::security::v2::validator_config::Checker::check(), ndn::security::v2::validator_config::checkNameRelation(), compare(), nfd::cs::compareQueryWithData(), ndn::InterestFilter::doesMatch(), equals(), nfd::cs::Cs::erase(), nfd::strategy_choice::StrategyChoice::erase(), ndn::RegexTopMatcher::expand(), ndn::security::v2::CertificateCache::find(), nfd::cs::Cs::find(), nfd::name_tree::NameTree::findLongestPrefixMatch(), nfd::rib::Rib::findParent(), get(), ndn::lp::PrefixAnnouncement::getAnnouncedName(), nfd::fw::asf::AsfMeasurements::getOrCreateNamespaceInfo(), getPrefix(), getSubName(), nfd::strategy_choice::StrategyChoice::insert(), isPrefixOf(), ndn::security::v2::isValidKeyName(), ndn::security::v2::Certificate::isValidName(), nfd::CommandAuthenticator::makeAuthorization(), ndn::security::v2::validator_config::Filter::match(), ndn::Interest::matchesData(), ndn::Interest::matchesName(), ndn::nfd::operator==(), ndn::security::parse(), nfd::fw::Strategy::parseInstanceName(), ndn::InMemoryStorage::selectChild(), and ndn::nfd::StrategyChoiceUnsetCommand::validateRequest().
|
inline |
Get the component at the given index.
i | zero-based index; if negative, it starts at the end of this name |
Definition at line 164 of file name.hpp.
References ndn::Block::elements(), and size().
Referenced by compare(), ndn::security::v2::CertificateBundleFetcher::doFetch(), equals(), isPrefixOf(), ndn::security::v2::isValidKeyName(), ndn::security::v2::Certificate::isValidName(), and ndn::Interest::matchesData().
|
inline |
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 |
Definition at line 180 of file name.cpp.
References ndn::Block::elements(), and size().
Referenced by nfd::ManagerBase::extractRequester(), ndn::lp::PrefixAnnouncement::getAnnouncedName(), ndn::security::v2::Certificate::getIssuerId(), ndn::security::v2::Certificate::getKeyId(), getSubName(), and nfd::fw::Strategy::makeInstanceName().
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.
Definition at line 194 of file name.cpp.
References append(), at(), npos, and size().
Referenced by ndn::lp::PrefixAnnouncement::getAnnouncedName(), getPrefix(), and nfd::fw::Strategy::parseInstanceName().
|
inline |
Extract a prefix of the name.
nComponents | Number of components; if negative, size()+nComponents is used instead |
Definition at line 210 of file name.hpp.
References getSubName(), and size().
Referenced by ndn::security::v2::validator_config::Checker::check(), ndn::security::v2::ValidationPolicySimpleHierarchy::checkPolicy(), nfd::strategy_choice::StrategyChoice::erase(), ndn::security::v2::extractIdentityFromCertName(), ndn::security::v2::extractIdentityFromKeyName(), ndn::security::v2::extractKeyNameFromCertName(), nfd::rib::Rib::findParent(), ndn::security::v2::Certificate::getIdentity(), ndn::security::v2::Certificate::getKeyName(), nfd::fw::asf::AsfMeasurements::getOrCreateNamespaceInfo(), getSuccessor(), ndn::security::v2::validator_config::Filter::match(), nfd::fw::Strategy::parseInstanceName(), ndn::InMemoryStorage::selectChild(), and nfd::name_tree::Entry::setParent().
|
inline |
Begin iterator.
Definition at line 222 of file name.hpp.
References ndn::Block::elements().
Referenced by rend().
|
inline |
End iterator.
Definition at line 230 of file name.hpp.
References ndn::Block::elements().
Referenced by rbegin().
|
inline |
Reverse begin iterator.
Definition at line 238 of file name.hpp.
References end().
Referenced by nfd::fw::Strategy::makeInstanceName().
|
inline |
Reverse end iterator.
Definition at line 246 of file name.hpp.
References begin().
Referenced by nfd::fw::Strategy::makeInstanceName().
Append a component.
Definition at line 256 of file name.hpp.
References ndn::Block::push_back().
Referenced by append(), appendImplicitSha256Digest(), appendNumber(), appendNumberWithMarker(), appendSegment(), appendSegmentOffset(), appendSequenceNumber(), appendTimestamp(), appendVersion(), ndn::security::v2::constructKeyName(), ndn::RegexTopMatcher::expand(), getSubName(), getSuccessor(), Name(), push_back(), and ndn::security::v2::KeyChain::sign().
|
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. |
Definition at line 291 of file name.hpp.
References append().
|
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. |
Definition at line 305 of file name.hpp.
References append().
|
inline |
Append a GenericNameComponent, copying TLV-VALUE from a null-terminated string.
str | a null-terminated string. Bytes from the string are copied as is, and not interpreted as URI component. |
Definition at line 316 of file name.hpp.
References append().
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. |
Definition at line 327 of file name.hpp.
References ndn::tlv::GenericNameComponent, ndn::Block::push_back(), and ndn::Block::type().
|
inline |
Append a component with a nonNegativeInteger.
Definition at line 344 of file name.hpp.
References append(), and ndn::name::Component::fromNumber().
|
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.
Definition at line 359 of file name.hpp.
References append(), and ndn::name::Component::fromNumberWithMarker().
|
inline |
Append a version component.
Definition at line 369 of file name.hpp.
References append(), and ndn::name::Component::fromVersion().
Referenced by ndn::mgmt::StatusDatasetContext::setPrefix().
Name & ndn::Name::appendVersion | ( | ) |
Append a version component based on current time.
The version number is the current UNIX timestamp in milliseconds
Definition at line 215 of file name.cpp.
References ndn::time::system_clock::now(), and ndn::time::toUnixTimestamp().
|
inline |
Append a segment number (sequential) component.
Definition at line 389 of file name.hpp.
References append(), and ndn::name::Component::fromSegment().
|
inline |
Append a segment byte offset component.
Definition at line 399 of file name.hpp.
References append(), and ndn::name::Component::fromSegmentOffset().
|
inline |
Append a timestamp component.
Definition at line 409 of file name.hpp.
References append(), and ndn::name::Component::fromTimestamp().
Name & ndn::Name::appendTimestamp | ( | ) |
Append a timestamp component based on current time.
Definition at line 221 of file name.cpp.
References ndn::time::system_clock::now().
|
inline |
Append a sequence number component.
Definition at line 426 of file name.hpp.
References append(), and ndn::name::Component::fromSequenceNumber().
Referenced by ndn::util::NotificationStream< Notification >::postNotification().
|
inline |
Append an ImplicitSha256Digest component.
Definition at line 435 of file name.hpp.
References append(), and ndn::name::Component::fromImplicitSha256Digest().
Referenced by ndn::Data::getFullName().
|
inline |
Append an ImplicitSha256Digest component.
Definition at line 444 of file name.hpp.
References append(), and ndn::name::Component::fromImplicitSha256Digest().
Name & ndn::Name::append | ( | const PartialName & | name | ) |
|
inline |
|
inline |
Remove all components.
Definition at line 470 of file name.hpp.
References ndn::tlv::Name.
Referenced by ndn::KeyLocator::clear(), ndn::security::pib::PibMemory::clearIdentities(), ndn::security::pib::PibMemory::removeIdentity(), ndn::Data::resetWire(), ndn::security::SigningInfo::setSha256Signing(), and ndn::Data::wireDecode().
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:
Definition at line 242 of file name.cpp.
References append(), empty(), and getPrefix().
Referenced by nfd::cs::Cs::erase(), and nfd::cs::Cs::find().
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
.
true | this name is a prefix of other |
false | this name is not a prefix of other |
Definition at line 255 of file name.cpp.
Referenced by ndn::mgmt::Dispatcher::addTopPrefix(), 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(), nfd::rib::Rib::findDescendants(), nfd::rib::Rib::findDescendantsForNonInsertedName(), ndn::Interest::matchesData(), ndn::Interest::matchesName(), ndn::InMemoryStorage::selectChild(), and ndn::mgmt::StatusDatasetContext::setPrefix().
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 271 of file name.cpp.
Referenced by ndn::operator!=(), and ndn::operator==().
|
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 |
Definition at line 540 of file name.hpp.
References npos.
Referenced by compare(), nfd::cs::compareDataWithData(), nfd::cs::compareQueryWithData(), ndn::operator<(), ndn::operator<=(), ndn::operator>(), and ndn::operator>=().
|
static |
indicates "until the end" in getSubName and compare
Definition at line 557 of file name.hpp.
Referenced by nfd::pit::Entry::canMatch(), compare(), and getSubName().