name.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
24 #ifndef NDN_NAME_HPP
25 #define NDN_NAME_HPP
26 
27 #include <vector>
28 #include <string>
29 #include <string.h>
30 #include <sstream>
31 #include "util/blob.hpp"
32 #include "encoding/wire-format.hpp"
33 #include "lite/name-lite.hpp"
34 
35 namespace ndn {
36 
40 class Name {
41 public:
45  class Component {
46  public:
51  : value_((const uint8_t*)0, 0)
52  {
53  }
54 
59  Component(const std::vector<uint8_t>& value)
60  : value_(value)
61  {
62  }
63 
69  Component(const uint8_t *value, size_t valueLen)
70  : value_(value, valueLen)
71  {
72  }
73 
81  Component(const char* value)
82  : value_((const uint8_t*)value, ::strlen(value))
83  {
84  }
85 
93  Component(const std::string& value)
94  : value_((const uint8_t*)&value[0], value.size())
95  {
96  }
97 
102  Component(const Blob &value)
103  : value_(value)
104  {
105  }
106 
113  void
114  get(NameLite::Component& componentLite) const;
115 
116  const Blob&
117  getValue() const { return value_; }
118 
124  void
125  toEscapedString(std::ostringstream& result) const
126  {
127  Name::toEscapedString(*value_, result);
128  }
129 
135  std::string
137  {
138  return Name::toEscapedString(*value_);
139  }
140 
147  bool
148  isSegment() const { return value_.size() >= 1 && value_.buf()[0] == 0x00; }
149 
156  bool
157  isSegmentOffset() const { return value_.size() >= 1 && value_.buf()[0] == 0xFB; }
158 
165  bool
166  isVersion() const { return value_.size() >= 1 && value_.buf()[0] == 0xFD; }
167 
174  bool
175  isTimestamp() const { return value_.size() >= 1 && value_.buf()[0] == 0xFC; }
176 
183  bool
184  isSequenceNumber() const { return value_.size() >= 1 && value_.buf()[0] == 0xFE; }
185 
190  uint64_t
191  toNumber() const;
192 
199  uint64_t
200  toNumberWithMarker(uint8_t marker) const;
201 
209  uint64_t
210  toNumberWithPrefix(const uint8_t* prefix, size_t prefixLength) const;
211 
218  bool
219  hasPrefix(const uint8_t* prefix, size_t prefixLength) const;
220 
228  uint64_t
229  toSegment() const
230  {
231  return toNumberWithMarker(0x00);
232  }
233 
241  uint64_t
243  {
244  return toNumberWithMarker(0xFB);
245  }
246 
250  uint64_t
251  DEPRECATED_IN_NDN_CPP toSeqNum() const
252  {
253  return toSegment();
254  }
255 
259  bool
260  DEPRECATED_IN_NDN_CPP isFinalSegment() const { return hasPrefix(getFinalSegmentPrefix(), getFinalSegmentPrefixLength()); }
261 
265  uint64_t
266  DEPRECATED_IN_NDN_CPP toFinalSegment() const
267  {
269  }
270 
279  uint64_t
280  toVersion() const
281  {
282  return toNumberWithMarker(0xFD);
283  }
284 
293  uint64_t
294  toTimestamp() const
295  {
296  return toNumberWithMarker(0xFC);
297  }
298 
306  uint64_t
308  {
309  return toNumberWithMarker(0xFE);
310  }
311 
318  static Component
319  fromNumber(uint64_t number);
320 
328  static Component
329  fromNumberWithMarker(uint64_t number, uint8_t marker);
330 
339  static Component
340  fromNumberWithPrefix(uint64_t number, const uint8_t* prefix, size_t prefixLength);
341 
349  static Component
350  fromSegment(uint64_t segment)
351  {
352  return fromNumberWithMarker(segment, 0x00);
353  }
354 
362  static Component
363  fromSegmentOffset(uint64_t segmentOffset)
364  {
365  return fromNumberWithMarker(segmentOffset, 0xFB);
366  }
367 
377  static Component
378  fromVersion(uint64_t version)
379  {
380  return fromNumberWithMarker(version, 0xFD);
381  }
382 
391  static Component
392  fromTimestamp(uint64_t timestamp)
393  {
394  return fromNumberWithMarker(timestamp, 0xFC);
395  }
396 
404  static Component
405  fromSequenceNumber(uint64_t sequenceNumber)
406  {
407  return fromNumberWithMarker(sequenceNumber, 0xFE);
408  }
409 
413  static const uint8_t*
414  getFinalSegmentPrefix() { return FINAL_SEGMENT_PREFIX; }
415 
419  static size_t
420  getFinalSegmentPrefixLength() { return FINAL_SEGMENT_PREFIX_LENGTH; }
421 
426  Component
427  getSuccessor() const;
428 
434  bool
435  equals(const Component& other) const
436  {
437  return *value_ == *other.value_;
438  }
439 
445  bool
446  operator == (const Component& other) const { return equals(other); }
447 
453  bool
454  operator != (const Component& other) const { return !equals(other); }
455 
464  int
465  compare(const Component& other) const;
466 
473  bool
474  operator <= (const Component& other) const { return compare(other) <= 0; }
475 
482  bool
483  operator < (const Component& other) const { return compare(other) < 0; }
484 
491  bool
492  operator >= (const Component& other) const { return compare(other) >= 0; }
493 
500  bool
501  operator > (const Component& other) const { return compare(other) > 0; }
502 
503  private:
507  static const uint8_t FINAL_SEGMENT_PREFIX[];
508  static size_t FINAL_SEGMENT_PREFIX_LENGTH;
509 
510  Blob value_;
511  };
512 
517  : changeCount_(0)
518  {
519  }
520 
525  Name(const std::vector<Component>& components)
526  : components_(components), changeCount_(0)
527  {
528  }
529 
534  Name(const char* uri)
535  : changeCount_(0)
536  {
537  set(uri);
538  }
539 
544  Name(const std::string& uri)
545  : changeCount_(0)
546  {
547  set(uri.c_str());
548  }
549 
557  void
558  get(NameLite& nameLite) const;
559 
564  void
565  set(const NameLite& nameLite);
566 
571  void
572  set(const char *uri);
573 
578  void
579  set(const std::string& uri) { set(uri.c_str()); }
580 
585  Name&
586  append(const uint8_t *value, size_t valueLength)
587  {
588  return append(Component(value, valueLength));
589  }
590 
595  Name&
596  append(const std::vector<uint8_t>& value)
597  {
598  return append(Component(value));
599  }
600 
601  Name&
602  append(const Blob &value)
603  {
604  return append(Component(value));
605  }
606 
607  Name&
608  append(const Component &value)
609  {
610  components_.push_back(value);
611  ++changeCount_;
612  return *this;
613  }
614 
623  Name&
624  append(const char* value)
625  {
626  return append(Component(value));
627  }
628 
637  Name&
638  append(const std::string& value)
639  {
640  return append(Component(value));
641  }
642 
648  Name&
649  append(const Name& name);
650 
654  Name&
655  DEPRECATED_IN_NDN_CPP appendComponent(const uint8_t *value, size_t valueLength)
656  {
657  return append(value, valueLength);
658  }
659 
663  Name&
664  DEPRECATED_IN_NDN_CPP appendComponent(const std::vector<uint8_t>& value)
665  {
666  return append(value);
667  }
668 
672  Name&
673  DEPRECATED_IN_NDN_CPP appendComponent(const Blob &value)
674  {
675  return append(value);
676  }
677 
681  Name&
682  DEPRECATED_IN_NDN_CPP addComponent(const uint8_t *value, size_t valueLength)
683  {
684  return append(value, valueLength);
685  }
686 
690  Name&
691  DEPRECATED_IN_NDN_CPP addComponent(const std::vector<uint8_t>& value)
692  {
693  return append(value);
694  }
695 
699  Name&
700  DEPRECATED_IN_NDN_CPP addComponent(const Blob &value)
701  {
702  return append(value);
703  }
704 
708  void
709  clear() {
710  components_.clear();
711  ++changeCount_;
712  }
713 
717  size_t
718  DEPRECATED_IN_NDN_CPP getComponentCount() const { return size(); }
719 
723  const Component&
724  DEPRECATED_IN_NDN_CPP getComponent(size_t i) const { return get(i); }
725 
735  Name
736  getSubName(int iStartComponent, size_t nComponents) const;
737 
745  Name
746  getSubName(int iStartComponent) const
747  {
748  return getSubName(iStartComponent, components_.size());
749  }
750 
757  Name
758  getPrefix(int nComponents) const
759  {
760  if (nComponents < 0)
761  return getSubName(0, components_.size() + nComponents);
762  else
763  return getSubName(0, nComponents);
764  }
765 
774  std::string
775  toUri(bool includeScheme = false) const;
776 
780  std::string
781  DEPRECATED_IN_NDN_CPP to_uri() const
782  {
783  return toUri();
784  }
785 
793  Name&
794  appendSegment(uint64_t segment)
795  {
796  return append(Component::fromSegment(segment));
797  }
798 
806  Name&
807  appendSegmentOffset(uint64_t segmentOffset)
808  {
809  return append(Component::fromSegmentOffset(segmentOffset));
810  }
811 
815  Name&
816  DEPRECATED_IN_NDN_CPP appendFinalSegment(uint64_t segment)
817  {
820  }
821 
830  Name&
831  appendVersion(uint64_t version)
832  {
833  return append(Component::fromVersion(version));
834  }
835 
844  Name&
845  appendTimestamp(uint64_t timestamp)
846  {
847  return append(Component::fromTimestamp(timestamp));
848  }
849 
857  Name&
858  appendSequenceNumber(uint64_t sequenceNumber)
859  {
860  return append(Component::fromSequenceNumber(sequenceNumber));
861  }
862 
868  bool
869  equals(const Name& name) const;
870 
890  Name
891  getSuccessor() const;
892 
900  bool
901  match(const Name& name) const;
902 
910  bool
911  isPrefixOf(const Name& name) const { return match(name); }
912 
922  static Blob
923  fromEscapedString(const char *escapedString, size_t beginOffset, size_t endOffset);
924 
932  static Blob
933  fromEscapedString(const char *escapedString);
934 
942  static Blob
943  fromEscapedString(const std::string& escapedString) { return fromEscapedString(escapedString.c_str()); }
944 
951  static void
952  toEscapedString(const std::vector<uint8_t>& value, std::ostringstream& result);
953 
960  static std::string
961  toEscapedString(const std::vector<uint8_t>& value);
962 
963  //
964  // vector equivalent interface.
965  //
966 
971  size_t
972  size() const { return components_.size(); }
973 
980  Blob
982  {
983  return wireFormat.encodeName(*this);
984  }
985 
993  void
994  wireDecode
995  (const uint8_t *input, size_t inputLength,
997  {
998  wireFormat.decodeName(*this, input, inputLength);
999  }
1000 
1007  void
1008  wireDecode(const std::vector<uint8_t>& input, WireFormat& wireFormat = *WireFormat::getDefaultWireFormat())
1009  {
1010  wireDecode(&input[0], input.size(), wireFormat);
1011  }
1012 
1019  void
1020  wireDecode
1021  (const Blob& input,
1023  {
1024  wireDecode(input.buf(), input.size(), wireFormat);
1025  }
1026 
1034  const Component&
1035  get(int i) const;
1036 
1041  uint64_t
1042  getChangeCount() const { return changeCount_; }
1043 
1063  int
1064  compare(const Name& other) const
1065  {
1066  return compare(0, components_.size(), other);
1067  }
1068 
1088  int
1089  compare
1090  (int iStartComponent, size_t nComponents, const Name& other,
1091  int iOtherStartComponent, size_t nOtherComponents) const;
1092 
1093 
1111  int
1112  compare
1113  (int iStartComponent, size_t nComponents, const Name& other,
1114  int iOtherStartComponent = 0) const
1115  {
1116  return compare
1117  (iStartComponent, nComponents, other, iOtherStartComponent,
1118  other.components_.size());
1119  }
1120 
1121  const Component&
1122  operator [] (int i) const
1123  {
1124  return get(i);
1125  }
1126 
1131  template<class T> void
1132  push_back(const T &component)
1133  {
1134  append(component);
1135  }
1136 
1142  bool
1143  operator == (const Name &name) const { return equals(name); }
1144 
1150  bool
1151  operator != (const Name &name) const { return !equals(name); }
1152 
1159  bool
1160  operator <= (const Name& other) const { return compare(other) <= 0; }
1161 
1168  bool
1169  operator < (const Name& other) const { return compare(other) < 0; }
1170 
1177  bool
1178  operator >= (const Name& other) const { return compare(other) >= 0; }
1179 
1186  bool
1187  operator > (const Name& other) const { return compare(other) > 0; }
1188 
1192  static bool
1193  DEPRECATED_IN_NDN_CPP breadthFirstLess(const Name& name1, const Name& name2) { return name1 < name2; }
1194 
1199  bool operator() (const Name& name1, const Name& name2) const { return name1 < name2; }
1200  };
1201 
1202  //
1203  // Iterator interface to name components.
1204  //
1205  typedef std::vector<Component>::const_iterator const_iterator;
1206  typedef std::vector<Component>::const_reverse_iterator const_reverse_iterator;
1207 
1208  typedef Component partial_type;
1209 
1213  const_iterator
1214  begin() const { return components_.begin(); }
1215 
1219  const_iterator
1220  end() const { return components_.end(); }
1221 
1225  const_reverse_iterator
1226  rbegin() const { return components_.rbegin(); }
1227 
1231  const_reverse_iterator
1232  rend() const { return components_.rend(); }
1233 
1234 private:
1235  std::vector<Component> components_;
1236  uint64_t changeCount_;
1237 };
1238 
1239 inline std::ostream&
1240 operator << (std::ostream& os, const Name& name)
1241 {
1242  os << name.toUri();
1243  return os;
1244 }
1245 
1246 }
1247 
1248 #endif
1249 
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:142
Name &DEPRECATED_IN_NDN_CPP appendComponent(const Blob &value)
Definition: name.hpp:673
Name & append(const std::string &value)
Append a new component, copying the bytes from the value string.
Definition: name.hpp:638
static Component fromTimestamp(uint64_t timestamp)
Create a component with the encoded timestamp according to NDN naming conventions for "Timestamp" (ma...
Definition: name.hpp:392
Copyright (C) 2013-2016 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:474
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:365
Name & append(const std::vector< uint8_t > &value)
Append a new component, copying from value.
Definition: name.hpp:596
void set(const NameLite &nameLite)
Clear this name, and set the components by copying from nameLite.
Definition: name.cpp:284
uint64_t toTimestamp() const
Interpret this name component as a timestamp according to NDN naming conventions for "Timestamp" (mar...
Definition: name.hpp:294
Name & appendSegmentOffset(uint64_t segmentOffset)
Append a component with the encoded segment byte offset according to NDN naming conventions for segme...
Definition: name.hpp:807
static Component fromSegment(uint64_t segment)
Create a component with the encoded segment number according to NDN naming conventions for "Segment n...
Definition: name.hpp:350
Name &DEPRECATED_IN_NDN_CPP appendComponent(const std::vector< uint8_t > &value)
Definition: name.hpp:664
std::string toUri(bool includeScheme=false) const
Encode this name as a URI.
Definition: name.cpp:305
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:579
void push_back(const T &component)
Append the component.
Definition: name.hpp:1132
A NameLite holds an array of NameLite::Component.
Definition: name-lite.hpp:34
uint64_t toSequenceNumber() const
Interpret this name component as a sequence number according to NDN naming conventions for "Sequencin...
Definition: name.hpp:307
const Component &DEPRECATED_IN_NDN_CPP getComponent(size_t i) const
Definition: name.hpp:724
Name & append(const uint8_t *value, size_t valueLength)
Append a new component, copying from value of length valueLength.
Definition: name.hpp:586
static Component fromSequenceNumber(uint64_t sequenceNumber)
Create a component with the encoded sequence number according to NDN naming conventions for "Sequenci...
Definition: name.hpp:405
Name getSubName(int iStartComponent, size_t nComponents) const
Get a new name, constructed as a subset of components.
Definition: name.cpp:322
bool isSegment() const
Check if this component is a segment number according to NDN naming conventions for "Segment number" ...
Definition: name.hpp:148
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:1008
const_reverse_iterator rbegin() const
Reverse begin iterator (const).
Definition: name.hpp:1226
static size_t getFinalSegmentPrefixLength()
Definition: name.hpp:420
bool operator==(const Name &name) const
Check if this name has the same component count and components as the given name. ...
Definition: name.hpp:1143
A Name::Component holds a read-only name component value.
Definition: name.hpp:45
int compare(const Name &other) const
Compare this to the other Name using NDN canonical ordering.
Definition: name.hpp:1064
int compare(const Component &other) const
Compare this to the other Component using NDN canonical ordering.
Definition: name.cpp:173
bool operator<(const Component &other) const
Return true if this is less than the other Component in the NDN canonical ordering.
Definition: name.hpp:483
Component(const std::vector< uint8_t > &value)
Create a new Name::Component, copying the given value.
Definition: name.hpp:59
Name & appendSequenceNumber(uint64_t sequenceNumber)
Append a component with the encoded sequence number according to NDN naming conventions for "Sequenci...
Definition: name.hpp:858
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:1178
static Component fromVersion(uint64_t version)
Create a component with the encoded version number according to NDN naming conventions for "Versionin...
Definition: name.hpp:378
Component(const char *value)
Create a new Name::Component, copying the bytes from the value string.
Definition: name.hpp:81
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:492
uint64_t DEPRECATED_IN_NDN_CPP toFinalSegment() const
Definition: name.hpp:266
Name & appendVersion(uint64_t version)
Append a component with the encoded version number according to NDN naming conventions for "Versionin...
Definition: name.hpp:831
A Name holds an array of Name::Component and represents an NDN name.
Definition: name.hpp:40
Component getSuccessor() const
Get the successor of this component, as described in Name::getSuccessor.
Definition: name.cpp:186
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:132
uint64_t toNumber() const
Interpret this name component as a network-ordered number and return an integer.
Definition: name.cpp:165
size_t size() const
Get the number of components.
Definition: name.hpp:972
bool DEPRECATED_IN_NDN_CPP isFinalSegment() const
Definition: name.hpp:260
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:384
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:1151
Name getSuccessor() const
Get the successor of this name which is defined as follows.
Definition: name.cpp:352
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:159
static bool DEPRECATED_IN_NDN_CPP breadthFirstLess(const Name &name1, const Name &name2)
Definition: name.hpp:1193
Name &DEPRECATED_IN_NDN_CPP appendComponent(const uint8_t *value, size_t valueLength)
Definition: name.hpp:655
std::string toEscapedString() const
Convert this component value by escaping characters according to the NDN URI Scheme.
Definition: name.hpp:136
uint64_t toSegment() const
Interpret this name component as a segment number according to NDN naming conventions for "Segment nu...
Definition: name.hpp:229
bool operator>(const Component &other) const
Return true if this is greater than the other Component in the NDN canonical ordering.
Definition: name.hpp:501
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:102
size_t size() const
Return the length of the immutable byte array.
Definition: blob.hpp:147
bool isSegmentOffset() const
Check if this component is a segment byte offset according to NDN naming conventions for "Byte offset...
Definition: name.hpp:157
bool hasPrefix(const uint8_t *prefix, size_t prefixLength) const
Check if this name component begins with the given prefix.
Definition: name.cpp:116
static Component fromSegmentOffset(uint64_t segmentOffset)
Create a component with the encoded segment byte offset according to NDN naming conventions for segme...
Definition: name.hpp:363
A NameLite::Component holds a pointer to the component value.
Definition: name-lite.hpp:39
uint64_t DEPRECATED_IN_NDN_CPP toSeqNum() const
Definition: name.hpp:251
bool equals(const Component &other) const
Check if this is the same component as other.
Definition: name.hpp:435
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:88
bool operator!=(const Component &other) const
Check if this is not the same component as other.
Definition: name.hpp:454
uint64_t toSegmentOffset() const
Interpret this name component as a segment byte offset according to NDN naming conventions for segmen...
Definition: name.hpp:242
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.
Name getSubName(int iStartComponent) const
Get a new name, constructed as a subset of components starting at iStartComponent until the end of th...
Definition: name.hpp:746
uint64_t getChangeCount() const
Get the change count, which is incremented each time this object is changed.
Definition: name.hpp:1042
bool isTimestamp() const
Check if this component is a timestamp according to NDN naming conventions for "Timestamp" (marker 0x...
Definition: name.hpp:175
Component(const uint8_t *value, size_t valueLen)
Create a new Name::Component, copying the given value.
Definition: name.hpp:69
void toEscapedString(std::ostringstream &result) const
Write this component value to result, escaping characters according to the NDN URI Scheme...
Definition: name.hpp:125
Name &DEPRECATED_IN_NDN_CPP addComponent(const Blob &value)
Definition: name.hpp:700
Name & appendTimestamp(uint64_t timestamp)
Append a component with the encoded timestamp according to NDN naming conventions for "Timestamp" (ma...
Definition: name.hpp:845
const_iterator end() const
End iterator (const).
Definition: name.hpp:1220
static const uint8_t * getFinalSegmentPrefix()
Definition: name.hpp:414
Name(const char *uri)
Parse the uri according to the NDN URI Scheme and create the name with the components.
Definition: name.hpp:534
std::string DEPRECATED_IN_NDN_CPP to_uri() const
Definition: name.hpp:781
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:1160
size_t DEPRECATED_IN_NDN_CPP getComponentCount() const
Definition: name.hpp:718
Component()
Create a new Name::Component with a zero-length value.
Definition: name.hpp:50
Name()
Create a new Name with no components.
Definition: name.hpp:516
bool operator==(const Component &other) const
Check if this is the same component as other.
Definition: name.hpp:446
static WireFormat * getDefaultWireFormat()
Return the default WireFormat used by default encoding and decoding methods which was set with setDef...
Definition: wire-format.cpp:34
Name & append(const char *value)
Append a new component, copying the bytes from the value string.
Definition: name.hpp:624
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...
Definition: name.hpp:911
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:995
Name(const std::string &uri)
Parse the uri according to the NDN URI Scheme and create the name with the components.
Definition: name.hpp:544
Name &DEPRECATED_IN_NDN_CPP addComponent(const std::vector< uint8_t > &value)
Definition: name.hpp:691
Component(const std::string &value)
Create a new Name::Component, copying the bytes from the value string.
Definition: name.hpp:93
Component(const Blob &value)
Create a new Name::Component, taking another pointer to the Blob value.
Definition: name.hpp:102
Definition: wire-format.hpp:39
Name &DEPRECATED_IN_NDN_CPP addComponent(const uint8_t *value, size_t valueLength)
Definition: name.hpp:682
bool isSequenceNumber() const
Check if this component is a sequence number according to NDN naming conventions for "Sequencing" (ma...
Definition: name.hpp:184
Definition: name.hpp:1198
Name getPrefix(int nComponents) const
Return a new Name with the first nComponents components of this Name.
Definition: name.hpp:758
uint64_t toVersion() const
Interpret this name component as a version number according to NDN naming conventions for "Versioning...
Definition: name.hpp:280
const_reverse_iterator rend() const
Reverse end iterator (const).
Definition: name.hpp:1232
const_iterator begin() const
Begin iterator (const).
Definition: name.hpp:1214
bool operator>(const Name &other) const
Return true if this is greater than the other Name in the NDN canonical ordering. ...
Definition: name.hpp:1187
void clear()
Clear all the components.
Definition: name.hpp:709
Name &DEPRECATED_IN_NDN_CPP appendFinalSegment(uint64_t segment)
Definition: name.hpp:816
Name(const std::vector< Component > &components)
Create a new Name, copying the name components.
Definition: name.hpp:525
static Blob fromEscapedString(const std::string &escapedString)
Make a Blob value by decoding the escapedString according to the NDN URI Scheme.
Definition: name.hpp:943
bool operator<(const Name &other) const
Return true if this is less than the other Name in the NDN canonical ordering.
Definition: name.hpp:1169
Blob wireEncode(WireFormat &wireFormat=*WireFormat::getDefaultWireFormat()) const
Encode this Name for a particular wire format.
Definition: name.hpp:981
bool isVersion() const
Check if this component is a version number according to NDN naming conventions for "Versioning" (mar...
Definition: name.hpp:166
bool equals(const Name &name) const
Check if this name has the same component count and components as the given name. ...
Definition: name.cpp:337
Name & appendSegment(uint64_t segment)
Append a component with the encoded segment number according to NDN naming conventions for "Segment n...
Definition: name.hpp:794
static Component fromNumber(uint64_t number)
Create a component whose value is the nonNegativeInteger encoding of the number.
Definition: name.cpp:124