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  : type_(ndn_NameComponentType_GENERIC), value_((const uint8_t*)0, 0)
52  {
53  }
54 
60  Component(const std::vector<uint8_t>& value)
61  : type_(ndn_NameComponentType_GENERIC), value_(value)
62  {
63  }
64 
71  Component(const uint8_t *value, size_t valueLength)
72  : type_(ndn_NameComponentType_GENERIC), value_(value, valueLength)
73  {
74  }
75 
84  Component(const char* value)
85  : type_(ndn_NameComponentType_GENERIC), value_((const uint8_t*)value, ::strlen(value))
86  {
87  }
88 
97  Component(const std::string& value)
98  : type_(ndn_NameComponentType_GENERIC),
99  value_((const uint8_t*)&value[0], value.size())
100  {
101  }
102 
109  Component(const Blob &value)
110  : type_(ndn_NameComponentType_GENERIC), value_(value)
111  {
112  }
113 
119  Component(const NameLite::Component &componentLite)
120  : type_(componentLite.isImplicitSha256Digest() ?
121  ndn_NameComponentType_IMPLICIT_SHA256_DIGEST : ndn_NameComponentType_GENERIC),
122  value_(componentLite.getValue())
123  {
124  }
125 
132  void
133  get(NameLite::Component& componentLite) const;
134 
135  const Blob&
136  getValue() const { return value_; }
137 
144  void
145  toEscapedString(std::ostringstream& result) const;
146 
153  std::string
154  toEscapedString() const;
155 
162  bool
163  isSegment() const
164  {
165  return value_.size() >= 1 && value_.buf()[0] == 0x00 &&
166  type_ == ndn_NameComponentType_GENERIC;
167  }
168 
175  bool
177  {
178  return value_.size() >= 1 && value_.buf()[0] == 0xFB &&
179  type_ == ndn_NameComponentType_GENERIC;
180  }
181 
188  bool
189  isVersion() const
190  {
191  return value_.size() >= 1 && value_.buf()[0] == 0xFD &&
192  type_ == ndn_NameComponentType_GENERIC;
193  }
194 
201  bool
202  isTimestamp() const
203  {
204  return value_.size() >= 1 && value_.buf()[0] == 0xFC &&
205  type_ == ndn_NameComponentType_GENERIC;
206  }
207 
214  bool
216  {
217  return value_.size() >= 1 && value_.buf()[0] == 0xFE &&
218  type_ == ndn_NameComponentType_GENERIC;
219  }
220 
225  bool
226  isGeneric() const
227  {
228  return type_ == ndn_NameComponentType_GENERIC;
229  }
230 
235  bool
237  {
238  return type_ == ndn_NameComponentType_IMPLICIT_SHA256_DIGEST;
239  }
240 
245  uint64_t
246  toNumber() const;
247 
254  uint64_t
255  toNumberWithMarker(uint8_t marker) const;
256 
264  uint64_t
265  toNumberWithPrefix(const uint8_t* prefix, size_t prefixLength) const;
266 
273  bool
274  hasPrefix(const uint8_t* prefix, size_t prefixLength) const;
275 
283  uint64_t
284  toSegment() const
285  {
286  return toNumberWithMarker(0x00);
287  }
288 
296  uint64_t
298  {
299  return toNumberWithMarker(0xFB);
300  }
301 
305  uint64_t
306  DEPRECATED_IN_NDN_CPP toSeqNum() const
307  {
308  return toSegment();
309  }
310 
314  bool
315  DEPRECATED_IN_NDN_CPP isFinalSegment() const { return hasPrefix(getFinalSegmentPrefix(), getFinalSegmentPrefixLength()); }
316 
320  uint64_t
321  DEPRECATED_IN_NDN_CPP toFinalSegment() const
322  {
324  }
325 
334  uint64_t
335  toVersion() const
336  {
337  return toNumberWithMarker(0xFD);
338  }
339 
348  uint64_t
349  toTimestamp() const
350  {
351  return toNumberWithMarker(0xFC);
352  }
353 
361  uint64_t
363  {
364  return toNumberWithMarker(0xFE);
365  }
366 
373  static Component
374  fromNumber(uint64_t number);
375 
383  static Component
384  fromNumberWithMarker(uint64_t number, uint8_t marker);
385 
396  static Component
397  fromNumberWithPrefix(uint64_t number, const uint8_t* prefix, size_t prefixLength);
398 
406  static Component
407  fromSegment(uint64_t segment)
408  {
409  return fromNumberWithMarker(segment, 0x00);
410  }
411 
419  static Component
420  fromSegmentOffset(uint64_t segmentOffset)
421  {
422  return fromNumberWithMarker(segmentOffset, 0xFB);
423  }
424 
434  static Component
435  fromVersion(uint64_t version)
436  {
437  return fromNumberWithMarker(version, 0xFD);
438  }
439 
448  static Component
449  fromTimestamp(uint64_t timestamp)
450  {
451  return fromNumberWithMarker(timestamp, 0xFC);
452  }
453 
461  static Component
462  fromSequenceNumber(uint64_t sequenceNumber)
463  {
464  return fromNumberWithMarker(sequenceNumber, 0xFE);
465  }
466 
475  static Component
476  fromImplicitSha256Digest(const Blob& digest);
477 
489  static Component
490  fromImplicitSha256Digest(const uint8_t *digest, size_t digestLength)
491  {
492  return fromImplicitSha256Digest(Blob(digest, digestLength));
493  }
494 
503  static Component
504  fromImplicitSha256Digest(const std::vector<uint8_t>& digest)
505  {
506  return fromImplicitSha256Digest(Blob(digest));
507  }
508 
512  static const uint8_t*
513  getFinalSegmentPrefix() { return FINAL_SEGMENT_PREFIX; }
514 
518  static size_t
519  getFinalSegmentPrefixLength() { return FINAL_SEGMENT_PREFIX_LENGTH; }
520 
525  Component
526  getSuccessor() const;
527 
533  bool
534  equals(const Component& other) const
535  {
536  return *value_ == *other.value_ && type_ == other.type_;
537  }
538 
544  bool
545  operator == (const Component& other) const { return equals(other); }
546 
552  bool
553  operator != (const Component& other) const { return !equals(other); }
554 
563  int
564  compare(const Component& other) const;
565 
572  bool
573  operator <= (const Component& other) const { return compare(other) <= 0; }
574 
581  bool
582  operator < (const Component& other) const { return compare(other) < 0; }
583 
590  bool
591  operator >= (const Component& other) const { return compare(other) >= 0; }
592 
599  bool
600  operator > (const Component& other) const { return compare(other) > 0; }
601 
602  private:
606  static const uint8_t FINAL_SEGMENT_PREFIX[];
607  static size_t FINAL_SEGMENT_PREFIX_LENGTH;
608 
609  // Note: We keep the type_ internal because it is only used to distinguish
610  // from ImplicitSha256Digest. If we support general typed components then
611  // we can provide public access.
612  ndn_NameComponentType type_;
613  Blob value_;
614  };
615 
620  : changeCount_(0)
621  {
622  }
623 
628  Name(const std::vector<Component>& components)
629  : components_(components), changeCount_(0)
630  {
631  }
632 
637  Name(const char* uri)
638  : changeCount_(0)
639  {
640  set(uri);
641  }
642 
647  Name(const std::string& uri)
648  : changeCount_(0)
649  {
650  set(uri.c_str());
651  }
652 
660  void
661  get(NameLite& nameLite) const;
662 
667  void
668  set(const NameLite& nameLite);
669 
674  void
675  set(const char *uri);
676 
681  void
682  set(const std::string& uri) { set(uri.c_str()); }
683 
689  Name&
690  append(const uint8_t *value, size_t valueLength)
691  {
692  return append(Component(value, valueLength));
693  }
694 
700  Name&
701  append(const std::vector<uint8_t>& value)
702  {
703  return append(Component(value));
704  }
705 
711  Name&
712  append(const Blob &value)
713  {
714  return append(Component(value));
715  }
716 
717  Name&
718  append(const Component &value)
719  {
720  components_.push_back(value);
721  ++changeCount_;
722  return *this;
723  }
724 
733  Name&
734  append(const char* value)
735  {
736  return append(Component(value));
737  }
738 
747  Name&
748  append(const std::string& value)
749  {
750  return append(Component(value));
751  }
752 
758  Name&
759  append(const Name& name);
760 
764  Name&
765  DEPRECATED_IN_NDN_CPP appendComponent(const uint8_t *value, size_t valueLength)
766  {
767  return append(value, valueLength);
768  }
769 
773  Name&
774  DEPRECATED_IN_NDN_CPP appendComponent(const std::vector<uint8_t>& value)
775  {
776  return append(value);
777  }
778 
782  Name&
783  DEPRECATED_IN_NDN_CPP appendComponent(const Blob &value)
784  {
785  return append(value);
786  }
787 
791  Name&
792  DEPRECATED_IN_NDN_CPP addComponent(const uint8_t *value, size_t valueLength)
793  {
794  return append(value, valueLength);
795  }
796 
800  Name&
801  DEPRECATED_IN_NDN_CPP addComponent(const std::vector<uint8_t>& value)
802  {
803  return append(value);
804  }
805 
809  Name&
810  DEPRECATED_IN_NDN_CPP addComponent(const Blob &value)
811  {
812  return append(value);
813  }
814 
818  void
819  clear() {
820  components_.clear();
821  ++changeCount_;
822  }
823 
827  size_t
828  DEPRECATED_IN_NDN_CPP getComponentCount() const { return size(); }
829 
833  const Component&
834  DEPRECATED_IN_NDN_CPP getComponent(size_t i) const { return get(i); }
835 
845  Name
846  getSubName(int iStartComponent, size_t nComponents) const;
847 
855  Name
856  getSubName(int iStartComponent) const
857  {
858  return getSubName(iStartComponent, components_.size());
859  }
860 
867  Name
868  getPrefix(int nComponents) const
869  {
870  if (nComponents < 0)
871  return getSubName(0, components_.size() + nComponents);
872  else
873  return getSubName(0, nComponents);
874  }
875 
884  std::string
885  toUri(bool includeScheme = false) const;
886 
890  std::string
891  DEPRECATED_IN_NDN_CPP to_uri() const
892  {
893  return toUri();
894  }
895 
903  Name&
904  appendSegment(uint64_t segment)
905  {
906  return append(Component::fromSegment(segment));
907  }
908 
916  Name&
917  appendSegmentOffset(uint64_t segmentOffset)
918  {
919  return append(Component::fromSegmentOffset(segmentOffset));
920  }
921 
925  Name&
926  DEPRECATED_IN_NDN_CPP appendFinalSegment(uint64_t segment)
927  {
930  }
931 
940  Name&
941  appendVersion(uint64_t version)
942  {
943  return append(Component::fromVersion(version));
944  }
945 
954  Name&
955  appendTimestamp(uint64_t timestamp)
956  {
957  return append(Component::fromTimestamp(timestamp));
958  }
959 
967  Name&
968  appendSequenceNumber(uint64_t sequenceNumber)
969  {
970  return append(Component::fromSequenceNumber(sequenceNumber));
971  }
972 
981  Name&
983  {
985  }
986 
997  Name&
998  appendImplicitSha256Digest(const uint8_t *digest, size_t digestLength)
999  {
1000  return append(Component::fromImplicitSha256Digest(digest, digestLength));
1001  }
1002 
1011  Name&
1012  appendImplicitSha256Digest(const std::vector<uint8_t>& digest)
1013  {
1015  }
1016 
1022  bool
1023  equals(const Name& name) const;
1024 
1044  Name
1045  getSuccessor() const;
1046 
1054  bool
1055  match(const Name& name) const;
1056 
1064  bool
1065  isPrefixOf(const Name& name) const { return match(name); }
1066 
1077  static Blob
1078  fromEscapedString(const char *escapedString, size_t beginOffset, size_t endOffset);
1079 
1088  static Blob
1089  fromEscapedString(const char *escapedString);
1090 
1099  static Blob
1100  fromEscapedString(const std::string& escapedString) { return fromEscapedString(escapedString.c_str()); }
1101 
1108  static void
1109  toEscapedString(const std::vector<uint8_t>& value, std::ostringstream& result);
1110 
1117  static std::string
1118  toEscapedString(const std::vector<uint8_t>& value);
1119 
1120  //
1121  // vector equivalent interface.
1122  //
1123 
1128  size_t
1129  size() const { return components_.size(); }
1130 
1137  Blob
1139  {
1140  return wireFormat.encodeName(*this);
1141  }
1142 
1150  void
1151  wireDecode
1152  (const uint8_t *input, size_t inputLength,
1154  {
1155  wireFormat.decodeName(*this, input, inputLength);
1156  }
1157 
1164  void
1165  wireDecode(const std::vector<uint8_t>& input, WireFormat& wireFormat = *WireFormat::getDefaultWireFormat())
1166  {
1167  wireDecode(&input[0], input.size(), wireFormat);
1168  }
1169 
1176  void
1177  wireDecode
1178  (const Blob& input,
1180  {
1181  wireDecode(input.buf(), input.size(), wireFormat);
1182  }
1183 
1191  const Component&
1192  get(int i) const;
1193 
1198  uint64_t
1199  getChangeCount() const { return changeCount_; }
1200 
1220  int
1221  compare(const Name& other) const
1222  {
1223  return compare(0, components_.size(), other);
1224  }
1225 
1245  int
1246  compare
1247  (int iStartComponent, size_t nComponents, const Name& other,
1248  int iOtherStartComponent, size_t nOtherComponents) const;
1249 
1250 
1268  int
1269  compare
1270  (int iStartComponent, size_t nComponents, const Name& other,
1271  int iOtherStartComponent = 0) const
1272  {
1273  return compare
1274  (iStartComponent, nComponents, other, iOtherStartComponent,
1275  other.components_.size());
1276  }
1277 
1278  const Component&
1279  operator [] (int i) const
1280  {
1281  return get(i);
1282  }
1283 
1288  template<class T> void
1289  push_back(const T &component)
1290  {
1291  append(component);
1292  }
1293 
1299  bool
1300  operator == (const Name &name) const { return equals(name); }
1301 
1307  bool
1308  operator != (const Name &name) const { return !equals(name); }
1309 
1316  bool
1317  operator <= (const Name& other) const { return compare(other) <= 0; }
1318 
1325  bool
1326  operator < (const Name& other) const { return compare(other) < 0; }
1327 
1334  bool
1335  operator >= (const Name& other) const { return compare(other) >= 0; }
1336 
1343  bool
1344  operator > (const Name& other) const { return compare(other) > 0; }
1345 
1349  static bool
1350  DEPRECATED_IN_NDN_CPP breadthFirstLess(const Name& name1, const Name& name2) { return name1 < name2; }
1351 
1356  bool operator() (const Name& name1, const Name& name2) const { return name1 < name2; }
1357  };
1358 
1359  //
1360  // Iterator interface to name components.
1361  //
1362  typedef std::vector<Component>::const_iterator const_iterator;
1363  typedef std::vector<Component>::const_reverse_iterator const_reverse_iterator;
1364 
1365  typedef Component partial_type;
1366 
1370  const_iterator
1371  begin() const { return components_.begin(); }
1372 
1376  const_iterator
1377  end() const { return components_.end(); }
1378 
1382  const_reverse_iterator
1383  rbegin() const { return components_.rbegin(); }
1384 
1388  const_reverse_iterator
1389  rend() const { return components_.rend(); }
1390 
1391 private:
1392  std::vector<Component> components_;
1393  uint64_t changeCount_;
1394 };
1395 
1396 inline std::ostream&
1397 operator << (std::ostream& os, const Name& name)
1398 {
1399  os << name.toUri();
1400  return os;
1401 }
1402 
1403 }
1404 
1405 #endif
1406 
static Component fromNumberWithPrefix(uint64_t number, const uint8_t *prefix, size_t prefixLength)
Create a GENERIC component whose value is the prefix appended with the network-ordered encoding of th...
Definition: name.cpp:183
Name &DEPRECATED_IN_NDN_CPP appendComponent(const Blob &value)
Definition: name.hpp:783
Name & append(const std::string &value)
Append a new GENERIC component, copying the bytes from the value string.
Definition: name.hpp:748
static Component fromTimestamp(uint64_t timestamp)
Create a component with the encoded timestamp according to NDN naming conventions for "Timestamp" (ma...
Definition: name.hpp:449
Copyright (C) 2013-2016 Regents of the University of California.
Definition: common.hpp:36
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:573
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:457
Name & append(const std::vector< uint8_t > &value)
Append a new GENERIC component, copying from value.
Definition: name.hpp:701
void set(const NameLite &nameLite)
Clear this name, and set the components by copying from nameLite.
Definition: name.cpp:376
uint64_t toTimestamp() const
Interpret this name component as a timestamp according to NDN naming conventions for "Timestamp" (mar...
Definition: name.hpp:349
Name & appendSegmentOffset(uint64_t segmentOffset)
Append a component with the encoded segment byte offset according to NDN naming conventions for segme...
Definition: name.hpp:917
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:407
Name &DEPRECATED_IN_NDN_CPP appendComponent(const std::vector< uint8_t > &value)
Definition: name.hpp:774
std::string toUri(bool includeScheme=false) const
Encode this name as a URI.
Definition: name.cpp:397
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:682
void push_back(const T &component)
Append the component.
Definition: name.hpp:1289
A NameLite holds an array of NameLite::Component.
Definition: name-lite.hpp:36
uint64_t toSequenceNumber() const
Interpret this name component as a sequence number according to NDN naming conventions for "Sequencin...
Definition: name.hpp:362
Name & appendImplicitSha256Digest(const std::vector< uint8_t > &digest)
Append a component of type ImplicitSha256DigestComponent, so that isImplicitSha256Digest() is true...
Definition: name.hpp:1012
const Component &DEPRECATED_IN_NDN_CPP getComponent(size_t i) const
Definition: name.hpp:834
Name & append(const uint8_t *value, size_t valueLength)
Append a new GENERIC component, copying from value of length valueLength.
Definition: name.hpp:690
Name & append(const Blob &value)
Append a new GENERIC component, using the existing Blob value.
Definition: name.hpp:712
Name & appendImplicitSha256Digest(const Blob &digest)
Append a component of type ImplicitSha256DigestComponent, so that isImplicitSha256Digest() is true...
Definition: name.hpp:982
static Component fromSequenceNumber(uint64_t sequenceNumber)
Create a component with the encoded sequence number according to NDN naming conventions for "Sequenci...
Definition: name.hpp:462
Name getSubName(int iStartComponent, size_t nComponents) const
Get a new name, constructed as a subset of components.
Definition: name.cpp:414
bool isSegment() const
Check if this component is a segment number according to NDN naming conventions for "Segment number" ...
Definition: name.hpp:163
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:1165
const_reverse_iterator rbegin() const
Reverse begin iterator (const).
Definition: name.hpp:1383
static Component fromImplicitSha256Digest(const Blob &digest)
Create a component of type ImplicitSha256DigestComponent, so that isImplicitSha256Digest() is true...
Definition: name.cpp:254
static size_t getFinalSegmentPrefixLength()
Definition: name.hpp:519
bool operator==(const Name &name) const
Check if this name has the same component count and components as the given name. ...
Definition: name.hpp:1300
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:1221
int compare(const Component &other) const
Compare this to the other Component using NDN canonical ordering.
Definition: name.cpp:236
bool operator<(const Component &other) const
Return true if this is less than the other Component in the NDN canonical ordering.
Definition: name.hpp:582
Component(const std::vector< uint8_t > &value)
Create a new GENERIC Name::Component, copying the given value.
Definition: name.hpp:60
Name & appendSequenceNumber(uint64_t sequenceNumber)
Append a component with the encoded sequence number according to NDN naming conventions for "Sequenci...
Definition: name.hpp:968
Name & appendImplicitSha256Digest(const uint8_t *digest, size_t digestLength)
Append a component of type ImplicitSha256DigestComponent, so that isImplicitSha256Digest() is true...
Definition: name.hpp:998
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:1335
static Component fromVersion(uint64_t version)
Create a component with the encoded version number according to NDN naming conventions for "Versionin...
Definition: name.hpp:435
Component(const char *value)
Create a new GENERIC Name::Component, copying the bytes from the value string.
Definition: name.hpp:84
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:591
uint64_t DEPRECATED_IN_NDN_CPP toFinalSegment() const
Definition: name.hpp:321
Name & appendVersion(uint64_t version)
Append a component with the encoded version number according to NDN naming conventions for "Versionin...
Definition: name.hpp:941
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:266
static Component fromNumberWithMarker(uint64_t number, uint8_t marker)
Create a GENERIC component whose value is the marker appended with the nonNegativeInteger encoding of...
Definition: name.cpp:173
uint64_t toNumber() const
Interpret this name component as a network-ordered number and return an integer.
Definition: name.cpp:228
size_t size() const
Get the number of components.
Definition: name.hpp:1129
bool DEPRECATED_IN_NDN_CPP isFinalSegment() const
Definition: name.hpp:315
static Component fromImplicitSha256Digest(const std::vector< uint8_t > &digest)
Create a component of type ImplicitSha256DigestComponent, so that isImplicitSha256Digest() is true...
Definition: name.hpp:504
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:476
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:1308
Name getSuccessor() const
Get the successor of this name which is defined as follows.
Definition: name.cpp:444
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:1350
Name &DEPRECATED_IN_NDN_CPP appendComponent(const uint8_t *value, size_t valueLength)
Definition: name.hpp:765
std::string toEscapedString() const
Convert this component value by escaping characters according to the NDN URI Scheme.
Definition: name.cpp:220
uint64_t toSegment() const
Interpret this name component as a segment number according to NDN naming conventions for "Segment nu...
Definition: name.hpp:284
bool operator>(const Component &other) const
Return true if this is greater than the other Component in the NDN canonical ordering.
Definition: name.hpp:600
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:143
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:176
bool isGeneric() const
Check if this component is a generic component.
Definition: name.hpp:226
bool hasPrefix(const uint8_t *prefix, size_t prefixLength) const
Check if this name component begins with the given prefix.
Definition: name.cpp:157
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:420
A NameLite::Component holds a pointer to the component value.
Definition: name-lite.hpp:41
uint64_t DEPRECATED_IN_NDN_CPP toSeqNum() const
Definition: name.hpp:306
bool equals(const Component &other) const
Check if this is the same component as other.
Definition: name.hpp:534
Component(const NameLite::Component &componentLite)
Create a new Name::Component, copying bytes from the NameLite::Component value and using its type...
Definition: name.hpp:119
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:129
bool operator!=(const Component &other) const
Check if this is not the same component as other.
Definition: name.hpp:553
uint64_t toSegmentOffset() const
Interpret this name component as a segment byte offset according to NDN naming conventions for segmen...
Definition: name.hpp:297
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:856
uint64_t getChangeCount() const
Get the change count, which is incremented each time this object is changed.
Definition: name.hpp:1199
bool isTimestamp() const
Check if this component is a timestamp according to NDN naming conventions for "Timestamp" (marker 0x...
Definition: name.hpp:202
Name &DEPRECATED_IN_NDN_CPP addComponent(const Blob &value)
Definition: name.hpp:810
Name & appendTimestamp(uint64_t timestamp)
Append a component with the encoded timestamp according to NDN naming conventions for "Timestamp" (ma...
Definition: name.hpp:955
const_iterator end() const
End iterator (const).
Definition: name.hpp:1377
static const uint8_t * getFinalSegmentPrefix()
Definition: name.hpp:513
Name(const char *uri)
Parse the uri according to the NDN URI Scheme and create the name with the components.
Definition: name.hpp:637
std::string DEPRECATED_IN_NDN_CPP to_uri() const
Definition: name.hpp:891
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:1317
size_t DEPRECATED_IN_NDN_CPP getComponentCount() const
Definition: name.hpp:828
Component()
Create a new GENERIC Name::Component with a zero-length value.
Definition: name.hpp:50
bool isImplicitSha256Digest() const
Check if this component is an ImplicitSha256Digest component.
Definition: name.hpp:236
Name()
Create a new Name with no components.
Definition: name.hpp:619
bool operator==(const Component &other) const
Check if this is the same component as other.
Definition: name.hpp:545
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 GENERIC component, copying the bytes from the value string.
Definition: name.hpp:734
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:1065
static Component fromImplicitSha256Digest(const uint8_t *digest, size_t digestLength)
Create a component of type ImplicitSha256DigestComponent, so that isImplicitSha256Digest() is true...
Definition: name.hpp:490
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:1152
Name(const std::string &uri)
Parse the uri according to the NDN URI Scheme and create the name with the components.
Definition: name.hpp:647
Name &DEPRECATED_IN_NDN_CPP addComponent(const std::vector< uint8_t > &value)
Definition: name.hpp:801
Component(const std::string &value)
Create a new GENERIC Name::Component, copying the bytes from the value string.
Definition: name.hpp:97
Component(const Blob &value)
Create a new GENERIC Name::Component, taking another pointer to the Blob value.
Definition: name.hpp:109
Definition: wire-format.hpp:39
Name &DEPRECATED_IN_NDN_CPP addComponent(const uint8_t *value, size_t valueLength)
Definition: name.hpp:792
bool isSequenceNumber() const
Check if this component is a sequence number according to NDN naming conventions for "Sequencing" (ma...
Definition: name.hpp:215
Definition: name.hpp:1355
Name getPrefix(int nComponents) const
Return a new Name with the first nComponents components of this Name.
Definition: name.hpp:868
uint64_t toVersion() const
Interpret this name component as a version number according to NDN naming conventions for "Versioning...
Definition: name.hpp:335
const_reverse_iterator rend() const
Reverse end iterator (const).
Definition: name.hpp:1389
const_iterator begin() const
Begin iterator (const).
Definition: name.hpp:1371
bool operator>(const Name &other) const
Return true if this is greater than the other Name in the NDN canonical ordering. ...
Definition: name.hpp:1344
void clear()
Clear all the components.
Definition: name.hpp:819
Name &DEPRECATED_IN_NDN_CPP appendFinalSegment(uint64_t segment)
Definition: name.hpp:926
Component(const uint8_t *value, size_t valueLength)
Create a new GENERIC Name::Component, copying the given value.
Definition: name.hpp:71
Name(const std::vector< Component > &components)
Create a new Name, copying the name components.
Definition: name.hpp:628
static Blob fromEscapedString(const std::string &escapedString)
Make a Blob value by decoding the escapedString according to the NDN URI Scheme.
Definition: name.hpp:1100
bool operator<(const Name &other) const
Return true if this is less than the other Name in the NDN canonical ordering.
Definition: name.hpp:1326
Blob wireEncode(WireFormat &wireFormat=*WireFormat::getDefaultWireFormat()) const
Encode this Name for a particular wire format.
Definition: name.hpp:1138
bool isVersion() const
Check if this component is a version number according to NDN naming conventions for "Versioning" (mar...
Definition: name.hpp:189
bool equals(const Name &name) const
Check if this name has the same component count and components as the given name. ...
Definition: name.cpp:429
Name & appendSegment(uint64_t segment)
Append a component with the encoded segment number according to NDN naming conventions for "Segment n...
Definition: name.hpp:904
static Component fromNumber(uint64_t number)
Create a GENERIC component whose value is the nonNegativeInteger encoding of the number.
Definition: name.cpp:165