31 #include "util/blob.hpp"
32 #include "encoding/wire-format.hpp"
53 : value_((const uint8_t*)0, 0)
72 : value_(value, valueLen)
84 : value_((const uint8_t*)value, ::strlen(value))
96 : value_((const uint8_t*)&value[0], value.
size())
118 getValue()
const {
return value_; }
175 hasPrefix(
const uint8_t* prefix,
size_t prefixLength)
const;
301 static const uint8_t*
318 return *value_ == *other.value_;
388 static const uint8_t FINAL_SEGMENT_PREFIX[];
389 static size_t FINAL_SEGMENT_PREFIX_LENGTH;
406 Name(
const std::vector<Component>& components)
407 : components_(components), changeCount_(0)
437 get(
struct ndn_Name& nameStruct)
const;
451 set(
const char *uri);
458 set(
const std::string& uri) {
set(uri.c_str()); }
465 append(
const uint8_t *value,
size_t valueLength)
475 append(
const std::vector<uint8_t>& value)
483 return append(Component(value));
487 append(
const Component &value)
489 components_.push_back(value);
536 return append(value, valueLength);
561 DEPRECATED_IN_NDN_CPP
addComponent(
const uint8_t *value,
size_t valueLength)
563 return append(value, valueLength);
650 toUri(
bool includeScheme =
false)
const;
764 fromEscapedString(
const char *escapedString,
size_t beginOffset,
size_t endOffset);
793 toEscapedString(
const std::vector<uint8_t>& value, std::ostringstream& result);
813 size()
const {
return components_.size(); }
824 return wireFormat.encodeName(*
this);
836 (
const uint8_t *input,
size_t inputLength,
839 wireFormat.decodeName(*
this, input, inputLength);
851 wireDecode(&input[0], input.size(), wireFormat);
903 operator [] (
int i)
const
912 template<
class T>
void
980 bool operator() (
const Name& name1,
const Name& name2)
const {
return name1 < name2; }
986 typedef std::vector<Component>::const_iterator const_iterator;
987 typedef std::vector<Component>::const_reverse_iterator const_reverse_iterator;
995 begin()
const {
return components_.begin(); }
1001 end()
const {
return components_.end(); }
1006 const_reverse_iterator
1007 rbegin()
const {
return components_.rbegin(); }
1012 const_reverse_iterator
1013 rend()
const {
return components_.rend(); }
1016 std::vector<Component> components_;
1017 uint64_t changeCount_;
1020 inline std::ostream&
1021 operator << (std::ostream& os,
const Name& name)
static Component fromNumberWithPrefix(uint64_t number, const uint8_t *prefix, size_t prefixLength)
Create a component whose value is the prefix appended with the network-ordered encoding of the number...
Definition: name.cpp:190
Name &DEPRECATED_IN_NDN_CPP appendComponent(const Blob &value)
Definition: name.hpp:552
Name & append(const std::string &value)
Append a new component, copying the bytes from the value string.
Definition: name.hpp:517
Copyright (C) 2013-2015 Regents of the University of California.
Definition: common.hpp:35
bool operator<=(const Component &other) const
Return true if this is less than or equal to the other Component in the NDN canonical ordering...
Definition: name.hpp:355
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...
Definition: name.cpp:385
Name & append(const std::vector< uint8_t > &value)
Append a new component, copying from value.
Definition: name.hpp:475
uint64_t toTimestamp() const
Interpret this name component as a timestamp according to NDN naming conventions for "Timestamp" (mar...
Definition: name.hpp:250
Name & appendSegmentOffset(uint64_t segmentOffset)
Append a component with the encoded segment byte offset according to NDN naming conventions for segme...
Definition: name.hpp:682
Name &DEPRECATED_IN_NDN_CPP appendComponent(const std::vector< uint8_t > &value)
Definition: name.hpp:543
std::string toUri(bool includeScheme=false) const
Encode this name as a URI.
Definition: name.cpp:324
void set(const std::string &uri)
Parse the uri according to the NDN URI Scheme and set the name with the components.
Definition: name.hpp:458
void push_back(const T &component)
Append the component.
Definition: name.hpp:913
uint64_t toSequenceNumber() const
Interpret this name component as a sequence number according to NDN naming conventions for "Sequencin...
Definition: name.hpp:263
const Component &DEPRECATED_IN_NDN_CPP getComponent(size_t i) const
Definition: name.hpp:603
Name & append(const uint8_t *value, size_t valueLength)
Append a new component, copying from value of length valueLength.
Definition: name.hpp:465
Name getSubName(int iStartComponent, size_t nComponents) const
Get a new name, constructed as a subset of components.
Definition: name.cpp:341
void wireDecode(const std::vector< uint8_t > &input, WireFormat &wireFormat=*WireFormat::getDefaultWireFormat())
Decode the input using a particular wire format and update this Name.
Definition: name.hpp:849
const_reverse_iterator rbegin() const
Reverse begin iterator (const).
Definition: name.hpp:1007
static size_t getFinalSegmentPrefixLength()
Definition: name.hpp:308
bool operator==(const Name &name) const
Check if this name has the same component count and components as the given name. ...
Definition: name.hpp:924
A Name::Component holds a read-only name component value.
Definition: name.hpp:47
int compare(const Name &other) const
Compare this to the other Name using NDN canonical ordering.
Definition: name.cpp:496
int compare(const Component &other) const
Compare this to the other Component using NDN canonical ordering.
Definition: name.cpp:221
bool operator<(const Component &other) const
Return true if this is less than the other Component in the NDN canonical ordering.
Definition: name.hpp:364
Component(const std::vector< uint8_t > &value)
Create a new Name::Component, copying the given value.
Definition: name.hpp:61
Name & appendSequenceNumber(uint64_t sequenceNumber)
Append a component with the encoded sequence number according to NDN naming conventions for "Sequenci...
Definition: name.hpp:733
bool operator>=(const Name &other) const
Return true if this is less than or equal to the other Name in the NDN canonical ordering.
Definition: name.hpp:959
Component(const char *value)
Create a new Name::Component, copying the bytes from the value string.
Definition: name.hpp:83
bool operator>=(const Component &other) const
Return true if this is less than or equal to the other Component in the NDN canonical ordering...
Definition: name.hpp:373
uint64_t DEPRECATED_IN_NDN_CPP toFinalSegment() const
Definition: name.hpp:222
Name & appendVersion(uint64_t version)
Append a component with the encoded version number according to NDN naming conventions for "Versionin...
Definition: name.hpp:706
A Name holds an array of Name::Component and represents an NDN name.
Definition: name.hpp:42
static Component fromNumberWithMarker(uint64_t number, uint8_t marker)
Create a component whose value is the marker appended with the nonNegativeInteger encoding of the num...
Definition: name.cpp:180
uint64_t toNumber() const
Interpret this name component as a network-ordered number and return an integer.
Definition: name.cpp:213
size_t size() const
Get the number of components.
Definition: name.hpp:813
bool DEPRECATED_IN_NDN_CPP isFinalSegment() const
Definition: name.hpp:216
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 ND...
Definition: name.cpp:404
size_t nComponents
the number of components in the name
Definition: name-types.h:43
A Blob holds a pointer to an immutable byte array implemented as const std::vector.
Definition: blob.hpp:42
bool operator!=(const Name &name) const
Check if this name has the same component count and components as the given name. ...
Definition: name.hpp:932
const uint8_t * buf() const
Return a const pointer to the first byte of the immutable byte array, or 0 if the pointer is null...
Definition: blob.hpp:138
static bool DEPRECATED_IN_NDN_CPP breadthFirstLess(const Name &name1, const Name &name2)
Definition: name.hpp:974
Copyright (C) 2015 Regents of the University of California.
Definition: name-types.h:33
Name &DEPRECATED_IN_NDN_CPP appendComponent(const uint8_t *value, size_t valueLength)
Definition: name.hpp:534
std::string toEscapedString() const
Convert this component value by escaping characters according to the NDN URI Scheme.
Definition: name.hpp:137
uint64_t toSegment() const
Interpret this name component as a segment number according to NDN naming conventions for "Segment nu...
Definition: name.hpp:185
bool operator>(const Component &other) const
Return true if this is greater than the other Component in the NDN canonical ordering.
Definition: name.hpp:382
uint64_t toNumberWithPrefix(const uint8_t *prefix, size_t prefixLength) const
Interpret this name component as a network-ordered number with a prefix and return an integer...
Definition: name.cpp:150
size_t size() const
Return the length of the immutable byte array.
Definition: blob.hpp:126
bool hasPrefix(const uint8_t *prefix, size_t prefixLength) const
Check if this name component begins with the given prefix.
Definition: name.cpp:164
An ndn_Name holds an array of ndn_NameComponent.
Definition: name-types.h:40
uint64_t DEPRECATED_IN_NDN_CPP toSeqNum() const
Definition: name.hpp:207
bool equals(const Component &other) const
Check if this is the same component as other.
Definition: name.hpp:316
uint64_t toNumberWithMarker(uint8_t marker) const
Interpret this name component as a network-ordered number with a marker and return an integer...
Definition: name.cpp:136
bool operator!=(const Component &other) const
Check if this is not the same component as other.
Definition: name.hpp:335
uint64_t toSegmentOffset() const
Interpret this name component as a segment byte offset according to NDN naming conventions for segmen...
Definition: name.hpp:198
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.
uint64_t getChangeCount() const
Get the change count, which is incremented each time this object is changed.
Definition: name.hpp:883
Component(const uint8_t *value, size_t valueLen)
Create a new Name::Component, copying the given value.
Definition: name.hpp:71
void toEscapedString(std::ostringstream &result) const
Write this component value to result, escaping characters according to the NDN URI Scheme...
Definition: name.hpp:126
Name &DEPRECATED_IN_NDN_CPP addComponent(const Blob &value)
Definition: name.hpp:579
Name & appendTimestamp(uint64_t timestamp)
Append a component with the encoded timestamp according to NDN naming conventions for "Timestamp" (ma...
Definition: name.hpp:720
const_iterator end() const
End iterator (const).
Definition: name.hpp:1001
static const uint8_t * getFinalSegmentPrefix()
Definition: name.hpp:302
Name(const char *uri)
Parse the uri according to the NDN URI Scheme and create the name with the components.
Definition: name.hpp:415
std::string DEPRECATED_IN_NDN_CPP to_uri() const
Definition: name.hpp:656
bool operator<=(const Name &other) const
Return true if this is less than or equal to the other Name in the NDN canonical ordering.
Definition: name.hpp:941
size_t DEPRECATED_IN_NDN_CPP getComponentCount() const
Definition: name.hpp:597
Component()
Create a new Name::Component with a zero-length value.
Definition: name.hpp:52
Name()
Create a new Name with no components.
Definition: name.hpp:397
bool operator==(const Component &other) const
Check if this is the same component as other.
Definition: name.hpp:327
Name & append(const char *value)
Append a new component, copying the bytes from the value string.
Definition: name.hpp:503
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.
Definition: name.hpp:836
Name(const std::string &uri)
Parse the uri according to the NDN URI Scheme and create the name with the components.
Definition: name.hpp:425
Name &DEPRECATED_IN_NDN_CPP addComponent(const std::vector< uint8_t > &value)
Definition: name.hpp:570
Component(const std::string &value)
Create a new Name::Component, copying the bytes from the value string.
Definition: name.hpp:95
Component(const Blob &value)
Create a new Name::Component, taking another pointer to the Blob value.
Definition: name.hpp:104
Name &DEPRECATED_IN_NDN_CPP addComponent(const uint8_t *value, size_t valueLength)
Definition: name.hpp:561
Name getPrefix(int nComponents) const
Return a new Name with the first nComponents components of this Name.
Definition: name.hpp:633
uint64_t toVersion() const
Interpret this name component as a version number according to NDN naming conventions for "Versioning...
Definition: name.hpp:236
const_reverse_iterator rend() const
Reverse end iterator (const).
Definition: name.hpp:1013
const_iterator begin() const
Begin iterator (const).
Definition: name.hpp:995
bool operator>(const Name &other) const
Return true if this is greater than the other Name in the NDN canonical ordering. ...
Definition: name.hpp:968
void clear()
Clear all the components.
Definition: name.hpp:588
Name &DEPRECATED_IN_NDN_CPP appendFinalSegment(uint64_t segment)
Definition: name.hpp:691
void set(const struct ndn_Name &nameStruct)
Clear this name, and set the components by copying from the name struct.
Definition: name.cpp:303
Name(const std::vector< Component > &components)
Create a new Name, copying the name components.
Definition: name.hpp:406
static Blob fromEscapedString(const std::string &escapedString)
Make a Blob value by decoding the escapedString according to the NDN URI Scheme.
Definition: name.hpp:784
bool operator<(const Name &other) const
Return true if this is less than the other Name in the NDN canonical ordering.
Definition: name.hpp:950
Blob wireEncode(WireFormat &wireFormat=*WireFormat::getDefaultWireFormat()) const
Encode this Name for a particular wire format.
Definition: name.hpp:822
bool equals(const Name &name) const
Check if this name has the same component count and components as the given name. ...
Definition: name.cpp:370
Name & appendSegment(uint64_t segment)
Append a component with the encoded segment number according to NDN naming conventions for "Segment n...
Definition: name.hpp:669
static Component fromNumber(uint64_t number)
Create a component whose value is the nonNegativeInteger encoding of the number.
Definition: name.cpp:172