All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
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),
52  otherTypeCode_(-1),
53  value_((const uint8_t*)0, 0)
54  {
55  }
56 
71  Component
72  (const std::vector<uint8_t>& value,
73  ndn_NameComponentType type = ndn_NameComponentType_GENERIC,
74  int otherTypeCode = -1)
75  : value_(value)
76  {
77  setType(type, otherTypeCode);
78  }
79 
95  Component
96  (const uint8_t *value, size_t valueLength,
97  ndn_NameComponentType type = ndn_NameComponentType_GENERIC,
98  int otherTypeCode = -1)
99  : value_(value, valueLength)
100  {
101  setType(type, otherTypeCode);
102  }
103 
119  Component
120  (const char* value,
121  ndn_NameComponentType type = ndn_NameComponentType_GENERIC,
122  int otherTypeCode = -1)
123  : value_((const uint8_t*)value, ::strlen(value))
124  {
125  setType(type, otherTypeCode);
126  }
127 
143  Component
144  (const std::string& value,
145  ndn_NameComponentType type = ndn_NameComponentType_GENERIC,
146  int otherTypeCode = -1)
147  : value_((const uint8_t*)&value[0], value.size())
148  {
149  setType(type, otherTypeCode);
150  }
151 
167  Component
168  (const Blob &value,
169  ndn_NameComponentType type = ndn_NameComponentType_GENERIC,
170  int otherTypeCode = -1)
171  : value_(value)
172  {
173  setType(type, otherTypeCode);
174  }
175 
181  Component(const NameLite::Component &componentLite)
182  : type_(componentLite.getType()),
183  otherTypeCode_(componentLite.getOtherTypeCode()),
184  value_(componentLite.getValue())
185  {
186  }
187 
194  void
195  get(NameLite::Component& componentLite) const;
196 
201  const Blob&
202  getValue() const { return value_; }
203 
210  ndn_NameComponentType
211  getType() const { return type_; }
212 
219  int
220  getOtherTypeCode() const { return otherTypeCode_; }
221 
228  void
229  toEscapedString(std::ostringstream& result) const;
230 
237  std::string
238  toEscapedString() const;
239 
246  bool
247  isSegment() const
248  {
249  return value_.size() >= 1 && value_.buf()[0] == 0x00 &&
250  type_ == ndn_NameComponentType_GENERIC;
251  }
252 
259  bool
261  {
262  return value_.size() >= 1 && value_.buf()[0] == 0xFB &&
263  type_ == ndn_NameComponentType_GENERIC;
264  }
265 
272  bool
273  isVersion() const
274  {
275  return value_.size() >= 1 && value_.buf()[0] == 0xFD &&
276  type_ == ndn_NameComponentType_GENERIC;
277  }
278 
285  bool
286  isTimestamp() const
287  {
288  return value_.size() >= 1 && value_.buf()[0] == 0xFC &&
289  type_ == ndn_NameComponentType_GENERIC;
290  }
291 
298  bool
300  {
301  return value_.size() >= 1 && value_.buf()[0] == 0xFE &&
302  type_ == ndn_NameComponentType_GENERIC;
303  }
304 
309  bool
310  isGeneric() const
311  {
312  return type_ == ndn_NameComponentType_GENERIC;
313  }
314 
319  bool
321  {
322  return type_ == ndn_NameComponentType_IMPLICIT_SHA256_DIGEST;
323  }
324 
329  bool
331  {
332  return type_ == ndn_NameComponentType_PARAMETERS_SHA256_DIGEST;
333  }
334 
339  uint64_t
340  toNumber() const;
341 
348  uint64_t
349  toNumberWithMarker(uint8_t marker) const;
350 
358  uint64_t
359  toNumberWithPrefix(const uint8_t* prefix, size_t prefixLength) const;
360 
367  bool
368  hasPrefix(const uint8_t* prefix, size_t prefixLength) const;
369 
377  uint64_t
378  toSegment() const
379  {
380  return toNumberWithMarker(0x00);
381  }
382 
390  uint64_t
392  {
393  return toNumberWithMarker(0xFB);
394  }
395 
399  uint64_t
400  DEPRECATED_IN_NDN_CPP toSeqNum() const
401  {
402  return toSegment();
403  }
404 
408  bool
409  DEPRECATED_IN_NDN_CPP isFinalSegment() const { return hasPrefix(getFinalSegmentPrefix(), getFinalSegmentPrefixLength()); }
410 
414  uint64_t
415  DEPRECATED_IN_NDN_CPP toFinalSegment() const
416  {
418  }
419 
428  uint64_t
429  toVersion() const
430  {
431  return toNumberWithMarker(0xFD);
432  }
433 
442  uint64_t
443  toTimestamp() const
444  {
445  return toNumberWithMarker(0xFC);
446  }
447 
455  uint64_t
457  {
458  return toNumberWithMarker(0xFE);
459  }
460 
475  static Component
476  fromNumber
477  (uint64_t number,
478  ndn_NameComponentType type = ndn_NameComponentType_GENERIC,
479  int otherTypeCode = -1);
480 
488  static Component
489  fromNumberWithMarker(uint64_t number, uint8_t marker);
490 
501  static Component
502  fromNumberWithPrefix(uint64_t number, const uint8_t* prefix, size_t prefixLength);
503 
511  static Component
512  fromSegment(uint64_t segment)
513  {
514  return fromNumberWithMarker(segment, 0x00);
515  }
516 
524  static Component
525  fromSegmentOffset(uint64_t segmentOffset)
526  {
527  return fromNumberWithMarker(segmentOffset, 0xFB);
528  }
529 
539  static Component
540  fromVersion(uint64_t version)
541  {
542  return fromNumberWithMarker(version, 0xFD);
543  }
544 
553  static Component
554  fromTimestamp(uint64_t timestamp)
555  {
556  return fromNumberWithMarker(timestamp, 0xFC);
557  }
558 
566  static Component
567  fromSequenceNumber(uint64_t sequenceNumber)
568  {
569  return fromNumberWithMarker(sequenceNumber, 0xFE);
570  }
571 
580  static Component
581  fromImplicitSha256Digest(const Blob& digest);
582 
594  static Component
595  fromImplicitSha256Digest(const uint8_t *digest, size_t digestLength)
596  {
597  return fromImplicitSha256Digest(Blob(digest, digestLength));
598  }
599 
608  static Component
609  fromImplicitSha256Digest(const std::vector<uint8_t>& digest)
610  {
611  return fromImplicitSha256Digest(Blob(digest));
612  }
613 
622  static Component
623  fromParametersSha256Digest(const Blob& digest);
624 
633  static Component
634  fromParametersSha256Digest(const uint8_t *digest, size_t digestLength)
635  {
636  return fromParametersSha256Digest(Blob(digest, digestLength));
637  }
638 
647  static Component
648  fromParametersSha256Digest(const std::vector<uint8_t>& digest)
649  {
650  return fromParametersSha256Digest(Blob(digest));
651  }
652 
656  static const uint8_t*
657  getFinalSegmentPrefix() { return FINAL_SEGMENT_PREFIX; }
658 
662  static size_t
663  getFinalSegmentPrefixLength() { return FINAL_SEGMENT_PREFIX_LENGTH; }
664 
669  Component
670  getSuccessor() const;
671 
677  bool
678  equals(const Component& other) const
679  {
680  if (type_ == ndn_NameComponentType_OTHER_CODE)
681  return *value_ == *other.value_ &&
682  other.type_ == ndn_NameComponentType_OTHER_CODE &&
683  otherTypeCode_ == other.otherTypeCode_;
684  else
685  return *value_ == *other.value_ && type_ == other.type_;
686  }
687 
693  bool
694  operator == (const Component& other) const { return equals(other); }
695 
701  bool
702  operator != (const Component& other) const { return !equals(other); }
703 
712  int
713  compare(const Component& other) const;
714 
721  bool
722  operator <= (const Component& other) const { return compare(other) <= 0; }
723 
730  bool
731  operator < (const Component& other) const { return compare(other) < 0; }
732 
739  bool
740  operator >= (const Component& other) const { return compare(other) >= 0; }
741 
748  bool
749  operator > (const Component& other) const { return compare(other) > 0; }
750 
751  private:
758  void
759  setType(ndn_NameComponentType type, int otherTypeCode);
760 
764  static const uint8_t FINAL_SEGMENT_PREFIX[];
765  static size_t FINAL_SEGMENT_PREFIX_LENGTH;
766 
767  ndn_NameComponentType type_;
768  int otherTypeCode_;
769  Blob value_;
770  };
771 
776  : changeCount_(0)
777  {
778  }
779 
784  Name(const std::vector<Component>& components)
785  : components_(components), changeCount_(0)
786  {
787  }
788 
793  Name(const char* uri)
794  : changeCount_(0)
795  {
796  set(uri);
797  }
798 
803  Name(const std::string& uri)
804  : changeCount_(0)
805  {
806  set(uri.c_str());
807  }
808 
816  void
817  get(NameLite& nameLite) const;
818 
823  void
824  set(const NameLite& nameLite);
825 
830  void
831  set(const char *uri);
832 
837  void
838  set(const std::string& uri) { set(uri.c_str()); }
839 
856  Name&
857  append
858  (const uint8_t *value, size_t valueLength,
859  ndn_NameComponentType type = ndn_NameComponentType_GENERIC,
860  int otherTypeCode = -1)
861  {
862  if (type == ndn_NameComponentType_OTHER_CODE)
863  checkAppendOtherTypeCode(otherTypeCode);
864 
865  return append(Component(value, valueLength, type, otherTypeCode));
866  }
867 
883  Name&
884  append
885  (const std::vector<uint8_t>& value,
886  ndn_NameComponentType type = ndn_NameComponentType_GENERIC,
887  int otherTypeCode = -1)
888  {
889  if (type == ndn_NameComponentType_OTHER_CODE)
890  checkAppendOtherTypeCode(otherTypeCode);
891 
892  return append(Component(value, type, otherTypeCode));
893  }
894 
911  Name&
912  append
913  (const Blob &value,
914  ndn_NameComponentType type = ndn_NameComponentType_GENERIC,
915  int otherTypeCode = -1)
916  {
917  if (type == ndn_NameComponentType_OTHER_CODE)
918  checkAppendOtherTypeCode(otherTypeCode);
919 
920  return append(Component(value, type, otherTypeCode));
921  }
922 
923  Name&
924  append(const Component &value)
925  {
926  components_.push_back(value);
927  ++changeCount_;
928  return *this;
929  }
930 
947  Name&
948  append
949  (const char* value,
950  ndn_NameComponentType type = ndn_NameComponentType_GENERIC,
951  int otherTypeCode = -1)
952  {
953  if (type == ndn_NameComponentType_OTHER_CODE)
954  checkAppendOtherTypeCode(otherTypeCode);
955 
956  return append(Component(value, type, otherTypeCode));
957  }
958 
975  Name&
976  append
977  (const std::string& value,
978  ndn_NameComponentType type = ndn_NameComponentType_GENERIC,
979  int otherTypeCode = -1)
980  {
981  if (type == ndn_NameComponentType_OTHER_CODE)
982  checkAppendOtherTypeCode(otherTypeCode);
983 
984  return append(Component(value, type, otherTypeCode));
985  }
986 
992  Name&
993  append(const Name& name);
994 
998  Name&
999  DEPRECATED_IN_NDN_CPP appendComponent(const uint8_t *value, size_t valueLength)
1000  {
1001  return append(value, valueLength);
1002  }
1003 
1007  Name&
1008  DEPRECATED_IN_NDN_CPP appendComponent(const std::vector<uint8_t>& value)
1009  {
1010  return append(value);
1011  }
1012 
1016  Name&
1017  DEPRECATED_IN_NDN_CPP appendComponent(const Blob &value)
1018  {
1019  return append(value);
1020  }
1021 
1025  Name&
1026  DEPRECATED_IN_NDN_CPP addComponent(const uint8_t *value, size_t valueLength)
1027  {
1028  return append(value, valueLength);
1029  }
1030 
1034  Name&
1035  DEPRECATED_IN_NDN_CPP addComponent(const std::vector<uint8_t>& value)
1036  {
1037  return append(value);
1038  }
1039 
1043  Name&
1044  DEPRECATED_IN_NDN_CPP addComponent(const Blob &value)
1045  {
1046  return append(value);
1047  }
1048 
1052  void
1053  clear() {
1054  components_.clear();
1055  ++changeCount_;
1056  }
1057 
1061  size_t
1062  DEPRECATED_IN_NDN_CPP getComponentCount() const { return size(); }
1063 
1067  const Component&
1068  DEPRECATED_IN_NDN_CPP getComponent(size_t i) const { return get(i); }
1069 
1079  Name
1080  getSubName(int iStartComponent, size_t nComponents) const;
1081 
1089  Name
1090  getSubName(int iStartComponent) const
1091  {
1092  return getSubName(iStartComponent, components_.size());
1093  }
1094 
1101  Name
1102  getPrefix(int nComponents) const
1103  {
1104  if (nComponents < 0)
1105  return getSubName(0, components_.size() + nComponents);
1106  else
1107  return getSubName(0, nComponents);
1108  }
1109 
1118  std::string
1119  toUri(bool includeScheme = false) const;
1120 
1124  std::string
1125  DEPRECATED_IN_NDN_CPP to_uri() const
1126  {
1127  return toUri();
1128  }
1129 
1137  Name&
1138  appendSegment(uint64_t segment)
1139  {
1140  return append(Component::fromSegment(segment));
1141  }
1142 
1150  Name&
1151  appendSegmentOffset(uint64_t segmentOffset)
1152  {
1153  return append(Component::fromSegmentOffset(segmentOffset));
1154  }
1155 
1159  Name&
1160  DEPRECATED_IN_NDN_CPP appendFinalSegment(uint64_t segment)
1161  {
1164  }
1165 
1174  Name&
1175  appendVersion(uint64_t version)
1176  {
1177  return append(Component::fromVersion(version));
1178  }
1179 
1188  Name&
1189  appendTimestamp(uint64_t timestamp)
1190  {
1191  return append(Component::fromTimestamp(timestamp));
1192  }
1193 
1201  Name&
1202  appendSequenceNumber(uint64_t sequenceNumber)
1203  {
1204  return append(Component::fromSequenceNumber(sequenceNumber));
1205  }
1206 
1215  Name&
1217  {
1219  }
1220 
1231  Name&
1232  appendImplicitSha256Digest(const uint8_t *digest, size_t digestLength)
1233  {
1234  return append(Component::fromImplicitSha256Digest(digest, digestLength));
1235  }
1236 
1245  Name&
1246  appendImplicitSha256Digest(const std::vector<uint8_t>& digest)
1247  {
1249  }
1250 
1259  Name&
1261  {
1263  }
1264 
1273  Name&
1274  appendParametersSha256Digest(const uint8_t *digest, size_t digestLength)
1275  {
1276  return append(Component::fromParametersSha256Digest(digest, digestLength));
1277  }
1278 
1287  Name&
1288  appendParametersSha256Digest(const std::vector<uint8_t>& digest)
1289  {
1291  }
1292 
1298  bool
1299  equals(const Name& name) const;
1300 
1320  Name
1321  getSuccessor() const;
1322 
1330  bool
1331  match(const Name& name) const;
1332 
1340  bool
1341  isPrefixOf(const Name& name) const { return match(name); }
1342 
1353  static Blob
1354  fromEscapedString(const char *escapedString, size_t beginOffset, size_t endOffset);
1355 
1364  static Blob
1365  fromEscapedString(const char *escapedString);
1366 
1375  static Blob
1376  fromEscapedString(const std::string& escapedString) { return fromEscapedString(escapedString.c_str()); }
1377 
1384  static void
1385  toEscapedString(const std::vector<uint8_t>& value, std::ostringstream& result);
1386 
1393  static std::string
1394  toEscapedString(const std::vector<uint8_t>& value);
1395 
1396  //
1397  // vector equivalent interface.
1398  //
1399 
1404  size_t
1405  size() const { return components_.size(); }
1406 
1413  Blob
1415  {
1416  return wireFormat.encodeName(*this);
1417  }
1418 
1426  void
1427  wireDecode
1428  (const uint8_t *input, size_t inputLength,
1430  {
1431  wireFormat.decodeName(*this, input, inputLength);
1432  }
1433 
1440  void
1441  wireDecode(const std::vector<uint8_t>& input, WireFormat& wireFormat = *WireFormat::getDefaultWireFormat())
1442  {
1443  wireDecode(&input[0], input.size(), wireFormat);
1444  }
1445 
1452  void
1453  wireDecode
1454  (const Blob& input,
1456  {
1457  wireDecode(input.buf(), input.size(), wireFormat);
1458  }
1459 
1467  const Component&
1468  get(int i) const;
1469 
1474  uint64_t
1475  getChangeCount() const { return changeCount_; }
1476 
1496  int
1497  compare(const Name& other) const
1498  {
1499  return compare(0, components_.size(), other);
1500  }
1501 
1521  int
1522  compare
1523  (int iStartComponent, size_t nComponents, const Name& other,
1524  int iOtherStartComponent, size_t nOtherComponents) const;
1525 
1526 
1544  int
1545  compare
1546  (int iStartComponent, size_t nComponents, const Name& other,
1547  int iOtherStartComponent = 0) const
1548  {
1549  return compare
1550  (iStartComponent, nComponents, other, iOtherStartComponent,
1551  other.components_.size());
1552  }
1553 
1554  const Component&
1555  operator [] (int i) const
1556  {
1557  return get(i);
1558  }
1559 
1564  template<class T> void
1565  push_back(const T &component)
1566  {
1567  append(component);
1568  }
1569 
1575  bool
1576  operator == (const Name &name) const { return equals(name); }
1577 
1583  bool
1584  operator != (const Name &name) const { return !equals(name); }
1585 
1592  bool
1593  operator <= (const Name& other) const { return compare(other) <= 0; }
1594 
1601  bool
1602  operator < (const Name& other) const { return compare(other) < 0; }
1603 
1610  bool
1611  operator >= (const Name& other) const { return compare(other) >= 0; }
1612 
1619  bool
1620  operator > (const Name& other) const { return compare(other) > 0; }
1621 
1625  static bool
1626  DEPRECATED_IN_NDN_CPP breadthFirstLess(const Name& name1, const Name& name2) { return name1 < name2; }
1627 
1632  bool operator() (const Name& name1, const Name& name2) const { return name1 < name2; }
1633  };
1634 
1635  //
1636  // Iterator interface to name components.
1637  //
1638  typedef std::vector<Component>::const_iterator const_iterator;
1639  typedef std::vector<Component>::const_reverse_iterator const_reverse_iterator;
1640 
1641  typedef Component partial_type;
1642 
1646  const_iterator
1647  begin() const { return components_.begin(); }
1648 
1652  const_iterator
1653  end() const { return components_.end(); }
1654 
1658  const_reverse_iterator
1659  rbegin() const { return components_.rbegin(); }
1660 
1664  const_reverse_iterator
1665  rend() const { return components_.rend(); }
1666 
1667 private:
1673  void
1674  checkAppendOtherTypeCode(int otherTypeCode);
1675 
1676  std::vector<Component> components_;
1677  uint64_t changeCount_;
1678 };
1679 
1680 inline std::ostream&
1681 operator << (std::ostream& os, const Name& name)
1682 {
1683  os << name.toUri();
1684  return os;
1685 }
1686 
1687 }
1688 
1689 #endif
1690 
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:194
Name &DEPRECATED_IN_NDN_CPP appendComponent(const Blob &value)
Definition: name.hpp:1017
static Component fromTimestamp(uint64_t timestamp)
Create a component with the encoded timestamp according to NDN naming conventions for "Timestamp" (ma...
Definition: name.hpp:554
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:722
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:553
static Component fromParametersSha256Digest(const std::vector< uint8_t > &digest)
Create a component of type ParametersSha256DigestComponent, so that isParametersSha256Digest() is tru...
Definition: name.hpp:648
void set(const NameLite &nameLite)
Clear this name, and set the components by copying from nameLite.
Definition: name.cpp:476
Name & appendParametersSha256Digest(const std::vector< uint8_t > &digest)
Append a component of type ParametersSha256DigestComponent, so that isParametersSha256Digest() is tru...
Definition: name.hpp:1288
ndn_NameComponentType getType() const
Get the name component type.
Definition: name.hpp:211
uint64_t toTimestamp() const
Interpret this name component as a timestamp according to NDN naming conventions for "Timestamp" (mar...
Definition: name.hpp:443
Name & appendSegmentOffset(uint64_t segmentOffset)
Append a component with the encoded segment byte offset according to NDN naming conventions for segme...
Definition: name.hpp:1151
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:512
Name &DEPRECATED_IN_NDN_CPP appendComponent(const std::vector< uint8_t > &value)
Definition: name.hpp:1008
std::string toUri(bool includeScheme=false) const
Encode this name as a URI.
Definition: name.cpp:497
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:838
void push_back(const T &component)
Append the component.
Definition: name.hpp:1565
static Component fromNumber(uint64_t number, ndn_NameComponentType type=ndn_NameComponentType_GENERIC, int otherTypeCode=-1)
Create a component whose value is the nonNegativeInteger encoding of the number.
Definition: name.cpp:167
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:456
Name & appendImplicitSha256Digest(const std::vector< uint8_t > &digest)
Append a component of type ImplicitSha256DigestComponent, so that isImplicitSha256Digest() is true...
Definition: name.hpp:1246
const Component &DEPRECATED_IN_NDN_CPP getComponent(size_t i) const
Definition: name.hpp:1068
bool isParametersSha256Digest() const
Check if this component is a ParametersSha256Digest component.
Definition: name.hpp:330
Name & appendImplicitSha256Digest(const Blob &digest)
Append a component of type ImplicitSha256DigestComponent, so that isImplicitSha256Digest() is true...
Definition: name.hpp:1216
static Component fromSequenceNumber(uint64_t sequenceNumber)
Create a component with the encoded sequence number according to NDN naming conventions for "Sequenci...
Definition: name.hpp:567
Name getSubName(int iStartComponent, size_t nComponents) const
Get a new name, constructed as a subset of components.
Definition: name.cpp:514
bool isSegment() const
Check if this component is a segment number according to NDN naming conventions for "Segment number" ...
Definition: name.hpp:247
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:1441
const_reverse_iterator rbegin() const
Reverse begin iterator (const).
Definition: name.hpp:1659
static Component fromImplicitSha256Digest(const Blob &digest)
Create a component of type ImplicitSha256DigestComponent, so that isImplicitSha256Digest() is true...
Definition: name.cpp:284
static size_t getFinalSegmentPrefixLength()
Definition: name.hpp:663
bool operator==(const Name &name) const
Check if this name has the same component count and components as the given name. ...
Definition: name.hpp:1576
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:1497
int compare(const Component &other) const
Compare this to the other Component using NDN canonical ordering.
Definition: name.cpp:261
bool operator<(const Component &other) const
Return true if this is less than the other Component in the NDN canonical ordering.
Definition: name.hpp:731
Name & appendSequenceNumber(uint64_t sequenceNumber)
Append a component with the encoded sequence number according to NDN naming conventions for "Sequenci...
Definition: name.hpp:1202
Name & appendImplicitSha256Digest(const uint8_t *digest, size_t digestLength)
Append a component of type ImplicitSha256DigestComponent, so that isImplicitSha256Digest() is true...
Definition: name.hpp:1232
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:1611
static Component fromParametersSha256Digest(const uint8_t *digest, size_t digestLength)
Create a component of type ParametersSha256DigestComponent, so that isParametersSha256Digest() is tru...
Definition: name.hpp:634
static Component fromVersion(uint64_t version)
Create a component with the encoded version number according to NDN naming conventions for "Versionin...
Definition: name.hpp:540
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:740
uint64_t DEPRECATED_IN_NDN_CPP toFinalSegment() const
Definition: name.hpp:415
const Blob & getValue() const
Get the component value.
Definition: name.hpp:202
Name & appendVersion(uint64_t version)
Append a component with the encoded version number according to NDN naming conventions for "Versionin...
Definition: name.hpp:1175
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:308
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:184
uint64_t toNumber() const
Interpret this name component as a network-ordered number and return an integer.
Definition: name.cpp:253
size_t size() const
Get the number of components.
Definition: name.hpp:1405
bool DEPRECATED_IN_NDN_CPP isFinalSegment() const
Definition: name.hpp:409
static Component fromImplicitSha256Digest(const std::vector< uint8_t > &digest)
Create a component of type ImplicitSha256DigestComponent, so that isImplicitSha256Digest() is true...
Definition: name.hpp:609
Name & append(const uint8_t *value, size_t valueLength, ndn_NameComponentType type=ndn_NameComponentType_GENERIC, int otherTypeCode=-1)
Append a new component, copying from value of length valueLength.
Definition: name.hpp:858
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:572
A Blob holds a pointer to an immutable byte array implemented as const std::vector<uint8_t>.
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:1584
Name getSuccessor() const
Get the successor of this name which is defined as follows.
Definition: name.cpp:544
int getOtherTypeCode() const
Get the component type code from the packet which is other than a recognized ndn_NameComponentType en...
Definition: name.hpp:220
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:1626
Name &DEPRECATED_IN_NDN_CPP appendComponent(const uint8_t *value, size_t valueLength)
Definition: name.hpp:999
std::string toEscapedString() const
Convert this component value by escaping characters according to the NDN URI Scheme.
Definition: name.cpp:245
uint64_t toSegment() const
Interpret this name component as a segment number according to NDN naming conventions for "Segment nu...
Definition: name.hpp:378
bool operator>(const Component &other) const
Return true if this is greater than the other Component in the NDN canonical ordering.
Definition: name.hpp:749
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:144
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:260
bool isGeneric() const
Check if this component is a generic component.
Definition: name.hpp:310
bool hasPrefix(const uint8_t *prefix, size_t prefixLength) const
Check if this name component begins with the given prefix.
Definition: name.cpp:158
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:525
A NameLite::Component holds a pointer to the component value.
Definition: name-lite.hpp:41
Name & appendParametersSha256Digest(const uint8_t *digest, size_t digestLength)
Append a component of type ParametersSha256DigestComponent, so that isParametersSha256Digest() is tru...
Definition: name.hpp:1274
uint64_t DEPRECATED_IN_NDN_CPP toSeqNum() const
Definition: name.hpp:400
bool equals(const Component &other) const
Check if this is the same component as other.
Definition: name.hpp:678
Component(const NameLite::Component &componentLite)
Create a new Name::Component, copying bytes from the NameLite::Component value and using its type...
Definition: name.hpp:181
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:130
bool operator!=(const Component &other) const
Check if this is not the same component as other.
Definition: name.hpp:702
uint64_t toSegmentOffset() const
Interpret this name component as a segment byte offset according to NDN naming conventions for segmen...
Definition: name.hpp:391
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:1090
uint64_t getChangeCount() const
Get the change count, which is incremented each time this object is changed.
Definition: name.hpp:1475
bool isTimestamp() const
Check if this component is a timestamp according to NDN naming conventions for "Timestamp" (marker 0x...
Definition: name.hpp:286
Name &DEPRECATED_IN_NDN_CPP addComponent(const Blob &value)
Definition: name.hpp:1044
Name & appendTimestamp(uint64_t timestamp)
Append a component with the encoded timestamp according to NDN naming conventions for "Timestamp" (ma...
Definition: name.hpp:1189
const_iterator end() const
End iterator (const).
Definition: name.hpp:1653
static const uint8_t * getFinalSegmentPrefix()
Definition: name.hpp:657
Name(const char *uri)
Parse the uri according to the NDN URI Scheme and create the name with the components.
Definition: name.hpp:793
std::string DEPRECATED_IN_NDN_CPP to_uri() const
Definition: name.hpp:1125
static Component fromParametersSha256Digest(const Blob &digest)
Create a component of type ParametersSha256DigestComponent, so that isParametersSha256Digest() is tru...
Definition: name.cpp:296
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:1593
size_t DEPRECATED_IN_NDN_CPP getComponentCount() const
Definition: name.hpp:1062
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:320
Name()
Create a new Name with no components.
Definition: name.hpp:775
bool operator==(const Component &other) const
Check if this is the same component as other.
Definition: name.hpp:694
static WireFormat * getDefaultWireFormat()
Return the default WireFormat used by default encoding and decoding methods which was set with setDef...
Definition: wire-format.cpp:34
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:1341
static Component fromImplicitSha256Digest(const uint8_t *digest, size_t digestLength)
Create a component of type ImplicitSha256DigestComponent, so that isImplicitSha256Digest() is true...
Definition: name.hpp:595
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:1428
Name(const std::string &uri)
Parse the uri according to the NDN URI Scheme and create the name with the components.
Definition: name.hpp:803
Name &DEPRECATED_IN_NDN_CPP addComponent(const std::vector< uint8_t > &value)
Definition: name.hpp:1035
Definition: wire-format.hpp:39
Name &DEPRECATED_IN_NDN_CPP addComponent(const uint8_t *value, size_t valueLength)
Definition: name.hpp:1026
Name & appendParametersSha256Digest(const Blob &digest)
Append a component of type ParametersSha256DigestComponent, so that isParametersSha256Digest() is tru...
Definition: name.hpp:1260
bool isSequenceNumber() const
Check if this component is a sequence number according to NDN naming conventions for "Sequencing" (ma...
Definition: name.hpp:299
Definition: name.hpp:1631
Name getPrefix(int nComponents) const
Return a new Name with the first nComponents components of this Name.
Definition: name.hpp:1102
uint64_t toVersion() const
Interpret this name component as a version number according to NDN naming conventions for "Versioning...
Definition: name.hpp:429
const_reverse_iterator rend() const
Reverse end iterator (const).
Definition: name.hpp:1665
const_iterator begin() const
Begin iterator (const).
Definition: name.hpp:1647
bool operator>(const Name &other) const
Return true if this is greater than the other Name in the NDN canonical ordering. ...
Definition: name.hpp:1620
void clear()
Clear all the components.
Definition: name.hpp:1053
Name &DEPRECATED_IN_NDN_CPP appendFinalSegment(uint64_t segment)
Definition: name.hpp:1160
Name(const std::vector< Component > &components)
Create a new Name, copying the name components.
Definition: name.hpp:784
static Blob fromEscapedString(const std::string &escapedString)
Make a Blob value by decoding the escapedString according to the NDN URI Scheme.
Definition: name.hpp:1376
bool operator<(const Name &other) const
Return true if this is less than the other Name in the NDN canonical ordering.
Definition: name.hpp:1602
Blob wireEncode(WireFormat &wireFormat=*WireFormat::getDefaultWireFormat()) const
Encode this Name for a particular wire format.
Definition: name.hpp:1414
bool isVersion() const
Check if this component is a version number according to NDN naming conventions for "Versioning" (mar...
Definition: name.hpp:273
bool equals(const Name &name) const
Check if this name has the same component count and components as the given name. ...
Definition: name.cpp:529
Name & appendSegment(uint64_t segment)
Append a component with the encoded segment number according to NDN naming conventions for "Segment n...
Definition: name.hpp:1138