NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
name-component.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013-2019 Regents of the University of California.
4  *
5  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6  *
7  * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License as published by the Free Software
9  * Foundation, either version 3 of the License, or (at your option) any later version.
10  *
11  * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13  * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14  *
15  * You should have received copies of the GNU General Public License and GNU Lesser
16  * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17  * <http://www.gnu.org/licenses/>.
18  *
19  * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20  *
21  * @author Jeff Thompson <jefft0@remap.ucla.edu>
22  * @author Alexander Afanasyev <http://lasr.cs.ucla.edu/afanasyev/index.html>
23  * @author Zhenkai Zhu <http://irl.cs.ucla.edu/~zhenkai/>
24  */
25 
28 
29 #include <cstdlib>
30 #include <cstring>
31 #include <sstream>
32 
33 namespace ndn {
34 namespace name {
35 
36 BOOST_CONCEPT_ASSERT((boost::EqualityComparable<Component>));
37 BOOST_CONCEPT_ASSERT((WireEncodable<Component>));
38 BOOST_CONCEPT_ASSERT((WireEncodableWithEncodingBuffer<Component>));
39 BOOST_CONCEPT_ASSERT((WireDecodable<Component>));
40 static_assert(std::is_base_of<tlv::Error, Component::Error>::value,
41  "name::Component::Error must inherit from tlv::Error");
42 
45 
48 {
49  return g_conventionEncoding;
50 }
51 
52 void
54 {
55  switch (convention) {
56  case Convention::MARKER:
57  case Convention::TYPED:
58  g_conventionEncoding = convention;
59  break;
60  default:
61  NDN_THROW(std::invalid_argument("Unknown naming convention"));
62  }
63 }
64 
67 {
68  return g_conventionDecoding;
69 }
70 
71 void
73 {
74  g_conventionDecoding = convention;
75 }
76 
77 static bool
79 {
81 }
82 
83 static bool
85 {
87 }
88 
89 static bool
91 {
92  if (format == UriFormat::DEFAULT) {
93  static const char* env = std::getenv("NDN_NAME_ALT_URI");
94  static bool defaultSetting = env == nullptr || env[0] != '0';
95  return defaultSetting;
96  }
97  return format == UriFormat::ALTERNATE;
98 }
99 
100 void
101 Component::ensureValid() const
102 {
104  NDN_THROW(Error("TLV-TYPE " + to_string(type()) + " is not a valid NameComponent"));
105  }
107 }
108 
109 Component::Component(uint32_t type)
110  : Block(type)
111 {
112  ensureValid();
113 }
114 
116  : Block(wire)
117 {
118  ensureValid();
119 }
120 
121 Component::Component(uint32_t type, ConstBufferPtr buffer)
122  : Block(type, std::move(buffer))
123 {
124  ensureValid();
125 }
126 
127 Component::Component(uint32_t type, const uint8_t* value, size_t valueLen)
128  : Block(makeBinaryBlock(type, value, valueLen))
129 {
130  ensureValid();
131 }
132 
133 Component::Component(const char* str)
134  : Block(makeBinaryBlock(tlv::GenericNameComponent, str, std::char_traits<char>::length(str)))
135 {
136 }
137 
138 Component::Component(const std::string& str)
140 {
141 }
142 
143 static Component
144 parseUriEscapedValue(uint32_t type, const char* input, size_t len)
145 {
146  std::ostringstream oss;
147  unescape(oss, input, len);
148  std::string value = oss.str();
149  if (value.find_first_not_of('.') == std::string::npos) { // all periods
150  if (value.size() < 3) {
151  NDN_THROW(Component::Error("Illegal URI (name component cannot be . or ..)"));
152  }
153  return Component(type, reinterpret_cast<const uint8_t*>(value.data()), value.size() - 3);
154  }
155  return Component(type, reinterpret_cast<const uint8_t*>(value.data()), value.size());
156 }
157 
158 Component
159 Component::fromEscapedString(const std::string& input)
160 {
161  size_t equalPos = input.find('=');
162  if (equalPos == std::string::npos) {
163  return parseUriEscapedValue(tlv::GenericNameComponent, input.data(), input.size());
164  }
165 
166  auto typePrefix = input.substr(0, equalPos);
167  auto type = std::strtoul(typePrefix.data(), nullptr, 10);
169  to_string(type) == typePrefix) {
170  size_t valuePos = equalPos + 1;
171  return parseUriEscapedValue(static_cast<uint32_t>(type),
172  input.data() + valuePos, input.size() - valuePos);
173  }
174 
175  auto ct = detail::getComponentTypeTable().findByUriPrefix(typePrefix);
176  if (ct == nullptr) {
177  NDN_THROW(Error("Unknown TLV-TYPE '" + typePrefix + "' in NameComponent URI"));
178  }
179  return ct->parseAltUriValue(input.substr(equalPos + 1));
180 }
181 
182 void
183 Component::toUri(std::ostream& os, UriFormat format) const
184 {
185  if (chooseAltUri(format)) {
187  }
188  else {
189  detail::ComponentType().writeUri(os, *this);
190  }
191 }
192 
193 std::string
195 {
196  std::ostringstream os;
197  toUri(os, format);
198  return os.str();
199 }
200 
202 
203 bool
205 {
206  return value_size() == 1 || value_size() == 2 ||
207  value_size() == 4 || value_size() == 8;
208 }
209 
210 bool
211 Component::isNumberWithMarker(uint8_t marker) const
212 {
213  return (value_size() == 2 || value_size() == 3 ||
214  value_size() == 5 || value_size() == 9) && value()[0] == marker;
215 }
216 
217 bool
219 {
222 }
223 
224 bool
226 {
229 }
230 
231 bool
233 {
236 }
237 
238 bool
240 {
243 }
244 
245 bool
247 {
250 }
251 
253 
254 uint64_t
256 {
257  if (!isNumber())
258  NDN_THROW(Error("Name component does not have nonNegativeInteger value"));
259 
260  return readNonNegativeInteger(*this);
261 }
262 
263 uint64_t
264 Component::toNumberWithMarker(uint8_t marker) const
265 {
266  if (!isNumberWithMarker(marker))
267  NDN_THROW(Error("Name component does not have the requested marker "
268  "or the value is not a nonNegativeInteger"));
269 
270  Buffer::const_iterator valueBegin = value_begin() + 1;
271  return tlv::readNonNegativeInteger(value_size() - 1, valueBegin, value_end());
272 }
273 
274 uint64_t
276 {
279  }
281  return toNumber();
282  }
283  NDN_THROW(Error("Not a Version component"));
284 }
285 
286 uint64_t
288 {
291  }
293  return toNumber();
294  }
295  NDN_THROW(Error("Not a Segment component"));
296 }
297 
298 uint64_t
300 {
303  }
305  return toNumber();
306  }
307  NDN_THROW(Error("Not a ByteOffset component"));
308 }
309 
312 {
313  uint64_t value = 0;
316  }
318  value = toNumber();
319  }
320  else {
321  NDN_THROW(Error("Not a Timestamp component"));
322  }
323  return time::getUnixEpoch() + time::microseconds(value);
324 }
325 
326 uint64_t
328 {
331  }
333  return toNumber();
334  }
335  NDN_THROW(Error("Not a SequenceNumber component"));
336 }
337 
339 
340 Component
341 Component::fromNumber(uint64_t number, uint32_t type)
342 {
343  return makeNonNegativeIntegerBlock(type, number);
344 }
345 
346 Component
347 Component::fromNumberWithMarker(uint8_t marker, uint64_t number)
348 {
349  EncodingEstimator estimator;
350 
351  size_t valueLength = estimator.prependNonNegativeInteger(number);
352  valueLength += estimator.prependByteArray(&marker, 1);
353  size_t totalLength = valueLength;
354  totalLength += estimator.prependVarNumber(valueLength);
355  totalLength += estimator.prependVarNumber(tlv::GenericNameComponent);
356 
357  EncodingBuffer encoder(totalLength, 0);
358  encoder.prependNonNegativeInteger(number);
359  encoder.prependByteArray(&marker, 1);
360  encoder.prependVarNumber(valueLength);
361  encoder.prependVarNumber(tlv::GenericNameComponent);
362 
363  return encoder.block();
364 }
365 
366 Component
367 Component::fromVersion(uint64_t version)
368 {
372 }
373 
374 Component
375 Component::fromSegment(uint64_t segmentNo)
376 {
380 }
381 
382 Component
384 {
388 }
389 
390 Component
392 {
393  uint64_t value = time::duration_cast<time::microseconds>(timePoint - time::getUnixEpoch()).count();
397 }
398 
399 Component
401 {
405 }
406 
408 
409 bool
411 {
412  return type() == tlv::GenericNameComponent;
413 }
414 
415 bool
417 {
418  return detail::getComponentType1().match(*this);
419 }
420 
421 Component
423 {
424  return detail::getComponentType1().create(digest);
425 }
426 
427 Component
428 Component::fromImplicitSha256Digest(const uint8_t* digest, size_t digestSize)
429 {
430  return detail::getComponentType1().create(digest, digestSize);
431 }
432 
433 bool
435 {
436  return detail::getComponentType2().match(*this);
437 }
438 
439 Component
441 {
442  return detail::getComponentType2().create(digest);
443 }
444 
445 Component
446 Component::fromParametersSha256Digest(const uint8_t* digest, size_t digestSize)
447 {
448  return detail::getComponentType2().create(digest, digestSize);
449 }
450 
452 
453 bool
454 Component::equals(const Component& other) const
455 {
456  return type() == other.type() &&
457  value_size() == other.value_size() &&
458  (empty() || // needed with Apple clang < 9.0.0 due to libc++ bug
459  std::equal(value_begin(), value_end(), other.value_begin()));
460 }
461 
462 int
463 Component::compare(const Component& other) const
464 {
465  if (this->hasWire() && other.hasWire()) {
466  // In the common case where both components have wire encoding,
467  // it's more efficient to simply compare the wire encoding.
468  // This works because lexical order of TLV encoding happens to be
469  // the same as canonical order of the value.
470  return std::memcmp(wire(), other.wire(), std::min(size(), other.size()));
471  }
472 
473  int cmpType = type() - other.type();
474  if (cmpType != 0)
475  return cmpType;
476 
477  int cmpSize = value_size() - other.value_size();
478  if (cmpSize != 0)
479  return cmpSize;
480 
481  if (empty())
482  return 0;
483 
484  return std::memcmp(value(), other.value(), value_size());
485 }
486 
487 Component
489 {
490  bool isOverflow = false;
491  Component successor;
492  std::tie(isOverflow, successor) =
494  if (!isOverflow) {
495  return successor;
496  }
497 
498  uint32_t type = this->type() + 1;
499  const std::vector<uint8_t>& value = detail::getComponentTypeTable().get(type).getMinValue();
500  return Component(type, value.data(), value.size());
501 }
502 
503 template<encoding::Tag TAG>
504 size_t
506 {
507  size_t totalLength = 0;
508  if (value_size() > 0)
509  totalLength += encoder.prependByteArray(value(), value_size());
510  totalLength += encoder.prependVarNumber(value_size());
511  totalLength += encoder.prependVarNumber(type());
512  return totalLength;
513 }
514 
516 
517 const Block&
519 {
520  if (this->hasWire())
521  return *this;
522 
523  EncodingEstimator estimator;
524  size_t estimatedSize = wireEncode(estimator);
525 
526  EncodingBuffer buffer(estimatedSize, 0);
527  wireEncode(buffer);
528 
529  const_cast<Component&>(*this) = buffer.block();
530  return *this;
531 }
532 
533 void
535 {
536  *this = wire;
537  // validity check is done within Component(const Block& wire)
538 }
539 
540 } // namespace name
541 } // namespace ndn
ndn::name::SEGMENT_OFFSET_MARKER
@ SEGMENT_OFFSET_MARKER
Definition: name-component.hpp:54
ndn::name::Component::equals
bool equals(const Component &other) const
Check if this is the same component as other.
Definition: name-component.cpp:454
ndn::name::Component::fromTimestamp
static Component fromTimestamp(const time::system_clock::TimePoint &timePoint)
Create sequence number component using NDN naming conventions.
Definition: name-component.cpp:391
ndn::tlv::SegmentNameComponent
@ SegmentNameComponent
Definition: tlv.hpp:119
ndn::name::Component::isByteOffset
bool isByteOffset() const
Check if the component is a byte offset per NDN naming conventions.
Definition: name-component.cpp:232
ndn::name::Component::fromNumber
static Component fromNumber(uint64_t number, uint32_t type=tlv::GenericNameComponent)
Create a component encoded as nonNegativeInteger.
Definition: name-component.cpp:341
ndn::name::Component::isNumber
bool isNumber() const
Check if the component is a nonNegativeInteger.
Definition: name-component.cpp:204
ndn::name::Component::fromByteOffset
static Component fromByteOffset(uint64_t offset)
Create byte offset component using NDN naming conventions.
Definition: name-component.cpp:383
ndn::name::getConventionEncoding
Convention getConventionEncoding()
Return which Naming Conventions style to use while encoding.
Definition: name-component.cpp:47
ndn::name::UriFormat::DEFAULT
@ DEFAULT
ALTERNATE, unless NDN_NAME_ALT_URI environment variable is set to '0'.
ndn::time::system_clock::TimePoint
time_point TimePoint
Definition: time.hpp:195
ndn::name::Component::isSegment
bool isSegment() const
Check if the component is a segment number per NDN naming conventions.
Definition: name-component.cpp:225
ndn::name::chooseAltUri
static bool chooseAltUri(UriFormat format)
Definition: name-component.cpp:90
ndn::name::Component::fromNumberWithMarker
static Component fromNumberWithMarker(uint8_t marker, uint64_t number)
Create a component encoded as NameComponentWithMarker.
Definition: name-component.cpp:347
nonstd::optional_lite::std11::move
T & move(T &t)
Definition: optional.hpp:421
ndn::name::Component::isGeneric
bool isGeneric() const
Check if the component is GenericComponent.
Definition: name-component.cpp:410
ndn::tlv::VersionNameComponent
@ VersionNameComponent
Definition: tlv.hpp:121
ndn::name::g_conventionDecoding
static Convention g_conventionDecoding
Definition: name-component.cpp:44
ndn::Block::value_size
size_t value_size() const noexcept
Return the size of TLV-VALUE, aka TLV-LENGTH.
Definition: block.cpp:308
ndn::name::Component::toNumberWithMarker
uint64_t toNumberWithMarker(uint8_t marker) const
Interpret this name component as NameComponentWithMarker.
Definition: name-component.cpp:264
ndn::name::Component::isSequenceNumber
bool isSequenceNumber() const
Check if the component is a sequence number per NDN naming conventions.
Definition: name-component.cpp:246
ndn::name::TIMESTAMP_MARKER
@ TIMESTAMP_MARKER
Definition: name-component.hpp:56
ndn::tlv::TimestampNameComponent
@ TimestampNameComponent
Definition: tlv.hpp:122
ndn::name::Convention::EITHER
@ EITHER
ndn::name::setConventionEncoding
void setConventionEncoding(Convention convention)
Set which Naming Conventions style to use while encoding.
Definition: name-component.cpp:53
ndn::name::Component::toUri
void toUri(std::ostream &os, UriFormat format=UriFormat::DEFAULT) const
Write *this to the output stream, escaping characters according to the NDN URI format.
Definition: name-component.cpp:183
ndn::name::Component::compare
int compare(const Component &other) const
Compare this to the other Component using NDN canonical ordering.
Definition: name-component.cpp:463
ndn::name::VERSION_MARKER
@ VERSION_MARKER
Definition: name-component.hpp:55
ndn::name::Component::toByteOffset
uint64_t toByteOffset() const
Interpret as byte offset component using NDN naming conventions.
Definition: name-component.cpp:299
ndn::Block::find
element_const_iterator find(uint32_t type) const
Find the first sub-element of the specified TLV-TYPE.
Definition: block.cpp:426
ndn::tlv::NameComponentMax
@ NameComponentMax
Definition: tlv.hpp:92
ndn::Block::value_end
Buffer::const_iterator value_end() const
Get end iterator of TLV-VALUE.
Definition: block.hpp:305
ndn::name::g_conventionEncoding
static Convention g_conventionEncoding
Definition: name-component.cpp:43
ndn::name::Component::toVersion
uint64_t toVersion() const
Interpret as version component using NDN naming conventions.
Definition: name-component.cpp:275
ndn::name::detail::getComponentType2
const Sha256ComponentType & getComponentType2()
Definition: name-component-types.hpp:269
ndn::name::Component::toNumber
uint64_t toNumber() const
Interpret this name component as nonNegativeInteger.
Definition: name-component.cpp:255
ndn::name::setConventionDecoding
void setConventionDecoding(Convention convention)
Set which Naming Conventions style(s) to accept while decoding.
Definition: name-component.cpp:72
ndn::name::Component::fromParametersSha256Digest
static Component fromParametersSha256Digest(ConstBufferPtr digest)
Create ParametersSha256DigestComponent component.
Definition: name-component.cpp:440
ndn::name::detail::ComponentType::writeUri
virtual void writeUri(std::ostream &os, const Component &comp) const
Write URI representation of comp to os.
Definition: name-component-types.hpp:105
ndn::WireDecodable
a concept check for TLV abstraction with .wireDecode method and constructible from Block
Definition: concepts.hpp:81
ndn::encoding::EncodingEstimator
EncodingImpl< EstimatorTag > EncodingEstimator
Definition: encoding-buffer-fwd.hpp:39
ndn::encoding::readNonNegativeInteger
uint64_t readNonNegativeInteger(const Block &block)
Read a non-negative integer from a TLV element.
Definition: block-helpers.cpp:64
ndn::name::Component::wireDecode
void wireDecode(const Block &wire)
Decode from the wire format.
Definition: name-component.cpp:534
ndn::name::Component::getSuccessor
Component getSuccessor() const
Get the successor of this name component.
Definition: name-component.cpp:488
ndn::name::Component::toSequenceNumber
uint64_t toSequenceNumber() const
Interpret as sequence number component using NDN naming conventions.
Definition: name-component.cpp:327
ndn::tlv::NameComponentMin
@ NameComponentMin
Definition: tlv.hpp:91
ndn::name::Component::fromVersion
static Component fromVersion(uint64_t version)
Create version component using NDN naming conventions.
Definition: name-component.cpp:367
ndn::Block::type
uint32_t type() const
Return the TLV-TYPE of the Block.
Definition: block.hpp:274
ndn::WireEncodable
a concept check for TLV abstraction with .wireEncode method
Definition: concepts.hpp:45
ndn::tlv::SequenceNumNameComponent
@ SequenceNumNameComponent
Definition: tlv.hpp:123
ndn::Block::value_begin
Buffer::const_iterator value_begin() const
Get begin iterator of TLV-VALUE.
Definition: block.hpp:296
ndn::name::Component::isVersion
bool isVersion() const
Check if the component is a version per NDN naming conventions.
Definition: name-component.cpp:218
ndn::name::Component::isNumberWithMarker
bool isNumberWithMarker(uint8_t marker) const
Check if the component is a NameComponentWithMarker per NDN naming conventions rev1.
Definition: name-component.cpp:211
ndn::name::Component::toSegment
uint64_t toSegment() const
Interpret as segment number component using NDN naming conventions.
Definition: name-component.cpp:287
ndn::name::Convention
Convention
Identify a style of NDN Naming Conventions.
Definition: name-component.hpp:44
ndn::name::Component::isTimestamp
bool isTimestamp() const
Check if the component is a timestamp per NDN naming conventions.
Definition: name-component.cpp:239
ndn::name::parseUriEscapedValue
static Component parseUriEscapedValue(uint32_t type, const char *input, size_t len)
Definition: name-component.cpp:144
NDN_THROW
#define NDN_THROW(e)
Definition: exception.hpp:61
ndn::name::detail::Sha256ComponentType::create
Component create(ConstBufferPtr value) const
Definition: name-component-types.hpp:198
ndn::name::canDecodeMarkerConvention
static bool canDecodeMarkerConvention()
Definition: name-component.cpp:78
ndn::name::Component::isImplicitSha256Digest
bool isImplicitSha256Digest() const
Check if the component is ImplicitSha256DigestComponent.
Definition: name-component.cpp:416
ndn::name::Component::fromSegment
static Component fromSegment(uint64_t segmentNo)
Create segment number component using NDN naming conventions.
Definition: name-component.cpp:375
ndn::name::Component::fromSequenceNumber
static Component fromSequenceNumber(uint64_t seqNo)
Create sequence number component using NDN naming conventions.
Definition: name-component.cpp:400
ndn::time::getUnixEpoch
const system_clock::TimePoint & getUnixEpoch()
Get system_clock::TimePoint representing UNIX time epoch (00:00:00 on Jan 1, 1970)
Definition: time.cpp:106
ndn::encoding::makeNonNegativeIntegerBlock
Block makeNonNegativeIntegerBlock(uint32_t type, uint64_t value)
Create a TLV block containing a non-negative integer.
Definition: block-helpers.cpp:52
ndn::unescape
std::string unescape(const std::string &str)
Decode a percent-encoded string.
Definition: string-helper.cpp:126
ndn::name::detail::getComponentType1
const Sha256ComponentType & getComponentType1()
Definition: name-component-types.hpp:261
name-component-types.hpp
ndn::encoding::Estimator::prependNonNegativeInteger
size_t prependNonNegativeInteger(uint64_t integer) const noexcept
Prepend non-negative integer integer of NDN TLV encoding.
Definition: estimator.cpp:51
ndn::name::Component::empty
NDN_CXX_NODISCARD bool empty() const
Definition: name-component.hpp:536
ndn::name::Component::Error
Definition: name-component.hpp:97
ndn::tlv::GenericNameComponent
@ GenericNameComponent
Definition: tlv.hpp:68
ndn::name::detail::getComponentTypeTable
const ComponentTypeTable & getComponentTypeTable()
Get the global ComponentTypeTable.
Definition: name-component-types.hpp:408
ndn::name::detail::ComponentType::getMinValue
virtual const std::vector< uint8_t > & getMinValue() const
Return the minimum allowable TLV-VALUE of this component type.
Definition: name-component-types.hpp:67
ndn::name::detail::ComponentTypeTable::findByUriPrefix
const ComponentType * findByUriPrefix(const std::string &prefix) const
Retrieve ComponentType by alternate URI prefix.
Definition: name-component-types.hpp:357
ndn::name::canDecodeTypedConvention
static bool canDecodeTypedConvention()
Definition: name-component.cpp:84
ndn::encoding::EncodingImpl
Definition: encoding-buffer-fwd.hpp:36
ndn::tlv::readNonNegativeInteger
uint64_t readNonNegativeInteger(size_t size, Iterator &begin, Iterator end)
Read nonNegativeInteger in NDN-TLV encoding.
Definition: tlv.hpp:486
ndn::name::Component::wireEncode
const Block & wireEncode() const
Encode to a wire format.
Definition: name-component.cpp:518
ndn::name::SEGMENT_MARKER
@ SEGMENT_MARKER
Definition: name-component.hpp:53
ndn::name::detail::ComponentType
Declare rules for a NameComponent type.
Definition: name-component-types.hpp:39
ndn::name::UriFormat::ALTERNATE
@ ALTERNATE
prefer alternate format when available
ndn::name::Component::toTimestamp
time::system_clock::TimePoint toTimestamp() const
Interpret as timestamp component using NDN naming conventions.
Definition: name-component.cpp:311
ndn::Block::value
const uint8_t * value() const noexcept
Return a raw pointer to the beginning of TLV-VALUE.
Definition: block.cpp:302
ndn::name::Component
Represents a name component.
Definition: name-component.hpp:94
ndn::Block
Represents a TLV element of NDN packet format.
Definition: block.hpp:43
ndn::Block::size
size_t size() const
Return the size of the encoded wire, i.e.
Definition: block.cpp:290
ndn::to_string
std::string to_string(const T &val)
Definition: backports.hpp:102
ndn::name::Convention::TYPED
@ TYPED
typed name components (revision 2)
ndn::name::detail::ComponentTypeTable::get
const ComponentType & get(uint32_t type) const
Retrieve ComponentType by TLV-TYPE.
Definition: name-component-types.hpp:346
ndn::name
Definition: name-component-types.hpp:33
ndn::Block::hasWire
bool hasWire() const noexcept
Check if the Block contains a fully encoded wire representation.
Definition: block.hpp:230
ndn::name::Convention::MARKER
@ MARKER
component markers (revision 1)
ndn::name::Component::fromImplicitSha256Digest
static Component fromImplicitSha256Digest(ConstBufferPtr digest)
Create ImplicitSha256DigestComponent component.
Definition: name-component.cpp:422
ndn::name::SEQUENCE_NUMBER_MARKER
@ SEQUENCE_NUMBER_MARKER
Definition: name-component.hpp:57
ndn::name::detail::ComponentType::getSuccessor
virtual std::pair< bool, Component > getSuccessor(const Component &comp) const
Calculate the successor of comp.
Definition: name-component-types.hpp:59
ndn::name::NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS
NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(Component)
ndn::name::Component::fromEscapedString
static Component fromEscapedString(const char *input, size_t beginOffset, size_t endOffset)
Decode NameComponent from a URI component.
Definition: name-component.hpp:238
ndn::name::Component::Component
Component(uint32_t type=tlv::GenericNameComponent)
Construct a NameComponent of TLV-TYPE type, using empty TLV-VALUE.
Definition: name-component.cpp:109
ndn::tlv::ByteOffsetNameComponent
@ ByteOffsetNameComponent
Definition: tlv.hpp:120
ndn::Block::wire
const uint8_t * wire() const
Return a raw pointer to the beginning of the encoded wire.
Definition: block.cpp:281
name-component.hpp
ndn::name::Component::isParametersSha256Digest
bool isParametersSha256Digest() const
Check if the component is ParametersSha256DigestComponent.
Definition: name-component.cpp:434
ndn::encoding::makeBinaryBlock
Block makeBinaryBlock(uint32_t type, const uint8_t *value, size_t length)
Create a TLV block copying TLV-VALUE from raw buffer.
Definition: block-helpers.cpp:181
ndn::ConstBufferPtr
shared_ptr< const Buffer > ConstBufferPtr
Definition: buffer.hpp:126
ndn::to_underlying
constexpr std::underlying_type_t< T > to_underlying(T val) noexcept
Definition: backports.hpp:141
ndn::WireEncodableWithEncodingBuffer
a concept check for TLV abstraction with .wireEncode method
Definition: concepts.hpp:61
ndn::encoding::makeStringBlock
Block makeStringBlock(uint32_t type, const std::string &value)
Create a TLV block containing a string.
Definition: block-helpers.cpp:116
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-strategy-choice-helper.hpp:34
ndn::encoding::EncodingBuffer
EncodingImpl< EncoderTag > EncodingBuffer
Definition: encoding-buffer-fwd.hpp:38
ndn::name::detail::Sha256ComponentType::match
bool match(const Component &comp) const
Definition: name-component-types.hpp:183
ndn::name::detail::ComponentType::check
virtual void check(const Component &comp) const
Throw Component::Error if comp is invalid.
Definition: name-component-types.hpp:49
ndn::name::UriFormat
UriFormat
Identify a format of URI representation.
Definition: name-component.hpp:35
ndn::name::getConventionDecoding
Convention getConventionDecoding()
Return which Naming Conventions style(s) to accept while decoding.
Definition: name-component.cpp:66