ndn::name::Component Class Reference

Represents a name component. More...

#include <name-component.hpp>

+ Inheritance diagram for ndn::name::Component:
+ Collaboration diagram for ndn::name::Component:

Classes

class  Error
 

Public Types

using element_const_iterator = element_container::const_iterator
 
using element_container = std::vector< Block >
 
using element_iterator = element_container::iterator
 

Public Member Functions

 Component (uint32_t type=tlv::GenericNameComponent)
 Construct a NameComponent of TLV-TYPE type, using empty TLV-VALUE. More...
 
 Component (const Block &wire)
 Construct a NameComponent from block. More...
 
 Component (uint32_t type, ConstBufferPtr buffer)
 Construct a NameComponent of TLV-TYPE type, using TLV-VALUE from buffer. More...
 
 Component (ConstBufferPtr buffer)
 Construct a GenericNameComponent, using TLV-VALUE from buffer. More...
 
 Component (uint32_t type, const Buffer &buffer)
 Construct a NameComponent of TLV-TYPE type, copying TLV-VALUE from buffer. More...
 
 Component (const Buffer &buffer)
 Construct a GenericNameComponent, copying TLV-VALUE from buffer. More...
 
 Component (uint32_t type, const uint8_t *value, size_t count)
 Construct a NameComponent of TLV-TYPE type, copying count bytes at value as TLV-VALUE. More...
 
 Component (const uint8_t *value, size_t count)
 Construct a GenericNameComponent, copying count bytes at value as TLV-VALUE. More...
 
template<class Iterator >
 Component (uint32_t type, Iterator first, Iterator last)
 Construct a NameComponent of TLV-TYPE type, copying TLV-VALUE from a range. More...
 
template<class Iterator >
 Component (Iterator first, Iterator last)
 Construct a GenericNameComponent, copying TLV-VALUE from a range. More...
 
 Component (const char *str)
 Construct a GenericNameComponent, copying TLV-VALUE from a null-terminated string. More...
 
 Component (const std::string &str)
 Construct a GenericNameComponent, copying TLV-VALUE from a string. More...
 
Buffer::const_iterator begin () const
 Get begin iterator of encoded wire. More...
 
Block blockFromValue () const
 
int compare (const Component &other) const
 Compare this to the other Component using NDN canonical ordering. More...
 
const element_containerelements () const
 Get container of sub elements. More...
 
element_const_iterator elements_begin () const
 Equivalent to elements().begin() More...
 
element_const_iterator elements_end () const
 Equivalent to elements().end() More...
 
size_t elements_size () const
 Equivalent to elements().size() More...
 
bool empty () const
 
void encode ()
 Encode sub elements into TLV-VALUE. More...
 
Buffer::const_iterator end () const
 Get end iterator of encoded wire. More...
 
bool equals (const Component &other) const
 Check if this is the same component as other. More...
 
element_iterator erase (element_const_iterator position)
 Erase a sub element. More...
 
element_iterator erase (element_const_iterator first, element_const_iterator last)
 Erase a range of sub elements. More...
 
element_const_iterator find (uint32_t type) const
 Find the first sub element of specified TLV-TYPE. More...
 
const Blockget (uint32_t type) const
 Get the first sub element of specified TLV-TYPE. More...
 
shared_ptr< const BuffergetBuffer () const
 Get underlying buffer. More...
 
Component getSuccessor () const
 Get the successor of this name component. More...
 
bool hasValue () const
 Get begin iterator of TLV-VALUE. More...
 
bool hasWire () const
 Check if the Block has fully encoded wire. More...
 
element_iterator insert (element_const_iterator pos, const Block &element)
 Insert a sub element. More...
 
bool isGeneric () const
 Check if the component is GenericComponent. More...
 
bool isImplicitSha256Digest () const
 Check if the component is ImplicitSha256DigestComponent. More...
 
bool isNumber () const
 Check if the component is nonNegativeInteger. More...
 
bool isNumberWithMarker (uint8_t marker) const
 Check if the component is NameComponentWithMarker per NDN naming conventions. More...
 
bool isParametersSha256Digest () const
 Check if the component is ParametersSha256DigestComponent. More...
 
bool isSegment () const
 Check if the component is segment number per NDN naming conventions. More...
 
bool isSegmentOffset () const
 Check if the component is segment offset per NDN naming conventions. More...
 
bool isSequenceNumber () const
 Check if the component is sequence number per NDN naming conventions. More...
 
bool isTimestamp () const
 Check if the component is timestamp per NDN naming conventions. More...
 
bool isVersion () const
 Check if the component is version per NDN naming conventions. More...
 
 operator boost::asio::const_buffer () const
 Implicit conversion to const_buffer. More...
 
bool operator!= (const Component &other) const
 Check if this is not the same component as other. More...
 
bool operator< (const Component &other) const
 Check if the *this is less than the other in NDN canonical ordering. More...
 
bool operator<= (const Component &other) const
 Check if the *this is less than or equal to the other in NDN canonical ordering. More...
 
bool operator== (const Component &other) const
 Check if this is the same component as other. More...
 
bool operator> (const Component &other) const
 Check if the *this is greater than the other in NDN canonical ordering. More...
 
bool operator>= (const Component &other) const
 Check if the *this is greater or equal than the other in NDN canonical ordering. More...
 
void parse () const
 Parse TLV-VALUE into sub elements. More...
 
void push_back (const Block &element)
 Append a sub element. More...
 
void remove (uint32_t type)
 Remove all sub elements of specified TLV-TYPE. More...
 
void reset ()
 Reset wire buffer of the element. More...
 
void resetWire ()
 Reset wire buffer but keep TLV-TYPE and sub elements (if any) More...
 
size_t size () const
 Get size of encoded wire, including Type-Length-Value. More...
 
uint64_t toNumber () const
 Interpret this name component as nonNegativeInteger. More...
 
uint64_t toNumberWithMarker (uint8_t marker) const
 Interpret this name component as NameComponentWithMarker. More...
 
uint64_t toSegment () const
 Interpret as segment number component using NDN naming conventions. More...
 
uint64_t toSegmentOffset () const
 Interpret as segment offset component using NDN naming conventions. More...
 
uint64_t toSequenceNumber () const
 Interpret as sequence number component using NDN naming conventions. More...
 
time::system_clock::TimePoint toTimestamp () const
 Interpret as timestamp component using NDN naming conventions. More...
 
void toUri (std::ostream &os) const
 Write *this to the output stream, escaping characters according to the NDN URI Scheme. More...
 
std::string toUri () const
 Convert *this by escaping characters according to the NDN URI Scheme. More...
 
uint64_t toVersion () const
 Interpret as version component using NDN naming conventions. More...
 
uint32_t type () const
 Get TLV-TYPE. More...
 
const uint8_t * value () const
 Get pointer to TLV-VALUE. More...
 
Buffer::const_iterator value_begin () const
 Get begin iterator of TLV-VALUE. More...
 
Buffer::const_iterator value_end () const
 Get end iterator of TLV-VALUE. More...
 
size_t value_size () const
 Get size of TLV-VALUE aka TLV-LENGTH. More...
 
const uint8_t * wire () const
 Get pointer to encoded wire. More...
 
void wireDecode (const Block &wire)
 Decode from the wire format. More...
 
template<encoding::Tag TAG>
size_t wireEncode (EncodingImpl< TAG > &encoder) const
 Fast encoding or block size estimation. More...
 
const BlockwireEncode () const
 Encode to a wire format. More...
 

Static Public Member Functions

static std::tuple< bool, BlockfromBuffer (ConstBufferPtr buffer, size_t offset)
 Try to parse Block from a wire buffer. More...
 
static std::tuple< bool, BlockfromBuffer (const uint8_t *buf, size_t bufSize)
 Try to parse Block from a raw buffer. More...
 
static Component fromEscapedString (const char *input, size_t beginOffset, size_t endOffset)
 Decode NameComponent from a URI component. More...
 
static Component fromEscapedString (const char *input)
 Decode NameComponent from a URI component. More...
 
static Component fromEscapedString (const std::string &input)
 Decode NameComponent from a URI component. More...
 
static Component fromImplicitSha256Digest (ConstBufferPtr digest)
 Create ImplicitSha256DigestComponent component. More...
 
static Component fromImplicitSha256Digest (const uint8_t *digest, size_t digestSize)
 Create ImplicitSha256DigestComponent component. More...
 
static Component fromNumber (uint64_t number)
 Create a component encoded as nonNegativeInteger. More...
 
static Component fromNumberWithMarker (uint8_t marker, uint64_t number)
 Create a component encoded as NameComponentWithMarker. More...
 
static Component fromParametersSha256Digest (ConstBufferPtr digest)
 Create ParametersSha256DigestComponent component. More...
 
static Component fromParametersSha256Digest (const uint8_t *digest, size_t digestSize)
 Create ParametersSha256DigestComponent component. More...
 
static Component fromSegment (uint64_t segmentNo)
 Create segment number component using NDN naming conventions. More...
 
static Component fromSegmentOffset (uint64_t offset)
 Create segment offset component using NDN naming conventions. More...
 
static Component fromSequenceNumber (uint64_t seqNo)
 Create sequence number component using NDN naming conventions. More...
 
static Block fromStream (std::istream &is)
 Parse Block from an input stream. More...
 
static Component fromTimestamp (const time::system_clock::TimePoint &timePoint)
 Create sequence number component using NDN naming conventions. More...
 
static Component fromVersion (uint64_t version)
 Create version component using NDN naming conventions. More...
 

Protected Attributes

Buffer::const_iterator m_begin
 
shared_ptr< const Bufferm_buffer
 underlying buffer storing TLV-VALUE and possibly TLV-TYPE and TLV-LENGTH fields More...
 
element_container m_elements
 sub elements More...
 
Buffer::const_iterator m_end
 
size_t m_size = 0
 total size including Type-Length-Value More...
 
uint32_t m_type = std::numeric_limits<uint32_t>::max()
 TLV-TYPE. More...
 
Buffer::const_iterator m_valueBegin
 
Buffer::const_iterator m_valueEnd
 

Detailed Description

Represents a name component.

The Component class provides a read-only view of a Block interpreted as a name component. Although it inherits mutation methods from Block base class, they must not be used, because the enclosing Name would not be updated correctly.

Definition at line 50 of file name-component.hpp.

Member Typedef Documentation

using ndn::Block::element_const_iterator = element_container::const_iterator
inherited

Definition at line 47 of file block.hpp.

using ndn::Block::element_container = std::vector<Block>
inherited

Definition at line 45 of file block.hpp.

using ndn::Block::element_iterator = element_container::iterator
inherited

Definition at line 46 of file block.hpp.

Constructor & Destructor Documentation

ndn::name::Component::Component ( uint32_t  type = tlv::GenericNameComponent)
explicit

Construct a NameComponent of TLV-TYPE type, using empty TLV-VALUE.

Exceptions
Errorthe NameComponent is invalid (see ensureValid).

Definition at line 52 of file name-component.cpp.

ndn::name::Component::Component ( const Block wire)

Construct a NameComponent from block.

Exceptions
Errorthe NameComponent is invalid (see ensureValid).

This contructor enables implicit conversion from Block.

Definition at line 58 of file name-component.cpp.

ndn::name::Component::Component ( uint32_t  type,
ConstBufferPtr  buffer 
)

Construct a NameComponent of TLV-TYPE type, using TLV-VALUE from buffer.

Exceptions
Errorthe NameComponent is invalid (see ensureValid).

This constructor does not copy the underlying buffer, but retains a pointer to it. Therefore, the caller must not change the underlying buffer.

Definition at line 64 of file name-component.cpp.

ndn::name::Component::Component ( ConstBufferPtr  buffer)
inlineexplicit

Construct a GenericNameComponent, using TLV-VALUE from buffer.

Exceptions
Errorthe NameComponent is invalid (see ensureValid).

This constructor does not copy the underlying buffer, but retains a pointer to it. Therefore, the caller must not change the underlying buffer.

Definition at line 92 of file name-component.hpp.

ndn::name::Component::Component ( uint32_t  type,
const Buffer buffer 
)
inline

Construct a NameComponent of TLV-TYPE type, copying TLV-VALUE from buffer.

Definition at line 100 of file name-component.hpp.

ndn::name::Component::Component ( const Buffer buffer)
inlineexplicit

Construct a GenericNameComponent, copying TLV-VALUE from buffer.

Definition at line 109 of file name-component.hpp.

ndn::name::Component::Component ( uint32_t  type,
const uint8_t *  value,
size_t  count 
)

Construct a NameComponent of TLV-TYPE type, copying count bytes at value as TLV-VALUE.

Definition at line 70 of file name-component.cpp.

ndn::name::Component::Component ( const uint8_t *  value,
size_t  count 
)
inline

Construct a GenericNameComponent, copying count bytes at value as TLV-VALUE.

Definition at line 123 of file name-component.hpp.

template<class Iterator >
ndn::name::Component::Component ( uint32_t  type,
Iterator  first,
Iterator  last 
)
inline

Construct a NameComponent of TLV-TYPE type, copying TLV-VALUE from a range.

Template Parameters
Iteratoran InputIterator dereferencing to a one-octet value type. More efficient implementation is available when it is a RandomAccessIterator.
Parameters
typethe TLV-TYPE.
firstbeginning of the range.
lastpast-end of the range.

Definition at line 137 of file name-component.hpp.

template<class Iterator >
ndn::name::Component::Component ( Iterator  first,
Iterator  last 
)
inline

Construct a GenericNameComponent, copying TLV-VALUE from a range.

Definition at line 146 of file name-component.hpp.

ndn::name::Component::Component ( const char *  str)
explicit

Construct a GenericNameComponent, copying TLV-VALUE from a null-terminated string.

Bytes from the string are copied as is, and not interpreted as URI component.

Definition at line 76 of file name-component.cpp.

ndn::name::Component::Component ( const std::string &  str)
explicit

Construct a GenericNameComponent, copying TLV-VALUE from a string.

Bytes from the string are copied as is, and not interpreted as URI component.

Definition at line 81 of file name-component.cpp.

Member Function Documentation

Buffer::const_iterator ndn::Block::begin ( ) const
inherited

Get begin iterator of encoded wire.

Precondition
hasWire() == true

Definition at line 271 of file block.cpp.

Block ndn::Block::blockFromValue ( ) const
inherited

Definition at line 322 of file block.cpp.

int ndn::name::Component::compare ( const Component other) const

Compare this to the other Component using NDN canonical ordering.

Parameters
otherThe other Component to compare with.
Return values
negativethis comes before other in canonical ordering
zerothis equals other
positivethis comes after other in canonical ordering
See also
https://named-data.net/doc/NDN-packet-spec/current/name.html#canonical-order

Definition at line 355 of file name-component.cpp.

const element_container& ndn::Block::elements ( ) const
inlineinherited

Get container of sub elements.

Precondition
parse() has been executed

Definition at line 361 of file block.hpp.

element_const_iterator ndn::Block::elements_begin ( ) const
inlineinherited

Equivalent to elements().begin()

Definition at line 369 of file block.hpp.

element_const_iterator ndn::Block::elements_end ( ) const
inlineinherited

Equivalent to elements().end()

Definition at line 377 of file block.hpp.

size_t ndn::Block::elements_size ( ) const
inlineinherited

Equivalent to elements().size()

Definition at line 385 of file block.hpp.

bool ndn::name::Component::empty ( ) const
inline

Definition at line 485 of file name-component.hpp.

void ndn::Block::encode ( )
inherited

Encode sub elements into TLV-VALUE.

Postcondition
TLV-VALUE contains sub elements from elements()

Definition at line 361 of file block.cpp.

Buffer::const_iterator ndn::Block::end ( ) const
inherited

Get end iterator of encoded wire.

Precondition
hasWire() == true

Definition at line 280 of file block.cpp.

bool ndn::name::Component::equals ( const Component other) const

Check if this is the same component as other.

Parameters
otherThe other Component to compare with
Returns
true if the components are equal, otherwise false.

Definition at line 346 of file name-component.cpp.

Block::element_iterator ndn::Block::erase ( Block::element_const_iterator  position)
inherited

Erase a sub element.

Definition at line 451 of file block.cpp.

Block::element_iterator ndn::Block::erase ( Block::element_const_iterator  first,
Block::element_const_iterator  last 
)
inherited

Erase a range of sub elements.

Definition at line 458 of file block.cpp.

Block::element_const_iterator ndn::Block::find ( uint32_t  type) const
inherited

Find the first sub element of specified TLV-TYPE.

Precondition
parse() has been executed
Returns
iterator in elements() to the found sub element, otherwise elements_end()

Definition at line 434 of file block.cpp.

std::tuple< bool, Block > ndn::Block::fromBuffer ( ConstBufferPtr  buffer,
size_t  offset 
)
staticinherited

Try to parse Block from a wire buffer.

Parameters
buffera Buffer containing an TLV element at offset offset
offsetbegin position of the TLV element within buffer
Note
This function does not throw exceptions upon decoding failure.
Returns
true and the Block if parsing succeeds; otherwise false

Definition at line 193 of file block.cpp.

std::tuple< bool, Block > ndn::Block::fromBuffer ( const uint8_t *  buf,
size_t  bufSize 
)
staticinherited

Try to parse Block from a raw buffer.

Parameters
bufpointer to the first octet of an TLV element
bufSizesize of the raw buffer; may be more than size of the TLV element
Note
This function does not throw exceptions upon decoding failure.
This overload copies the TLV element into an internal wire buffer.
Returns
true and the Block if parsing succeeds; otherwise false

Definition at line 219 of file block.cpp.

static Component ndn::name::Component::fromEscapedString ( const char *  input,
size_t  beginOffset,
size_t  endOffset 
)
inlinestatic

Decode NameComponent from a URI component.

The URI component is read from [input+beginOffset, input+endOffset) range.

Exceptions
ErrorURI component does not represent a valid NameComponent.

Definition at line 195 of file name-component.hpp.

static Component ndn::name::Component::fromEscapedString ( const char *  input)
inlinestatic

Decode NameComponent from a URI component.

Exceptions
ErrorURI component does not represent a valid NameComponent.

Definition at line 205 of file name-component.hpp.

Component ndn::name::Component::fromEscapedString ( const std::string &  input)
static

Decode NameComponent from a URI component.

Exceptions
ErrorURI component does not represent a valid NameComponent.

Definition at line 102 of file name-component.cpp.

Component ndn::name::Component::fromImplicitSha256Digest ( ConstBufferPtr  digest)
static

Create ImplicitSha256DigestComponent component.

Definition at line 314 of file name-component.cpp.

Component ndn::name::Component::fromImplicitSha256Digest ( const uint8_t *  digest,
size_t  digestSize 
)
static

Create ImplicitSha256DigestComponent component.

Definition at line 320 of file name-component.cpp.

Component ndn::name::Component::fromNumber ( uint64_t  number)
static

Create a component encoded as nonNegativeInteger.

See also
https://named-data.net/doc/NDN-packet-spec/current/tlv.html#non-negative-integer-encoding
Parameters
numberThe non-negative number
Returns
The component value.

Definition at line 242 of file name-component.cpp.

Component ndn::name::Component::fromNumberWithMarker ( uint8_t  marker,
uint64_t  number 
)
static

Create a component encoded as NameComponentWithMarker.

NameComponentWithMarker is defined as:

NameComponentWithMarker ::= NAME-COMPONENT-TYPE TLV-LEGTH
                              Marker
                              includedNonNegativeInteger
Marker ::= BYTE
includedNonNegativeInteger ::= BYTE{1,2,4,8}
NDN-TLV := TLV-TYPE TLV-LENGTH TLV-VALUE?
TLV-TYPE := VAR-NUMBER
TLV-LENGTH := VAR-NUMBER
TLV-VALUE := BYTE+
See also
NDN Naming Conventions https://named-data.net/doc/tech-memos/naming-conventions.pdf
Parameters
marker1-byte marker octet
numberThe non-negative number
Returns
The component value.

Definition at line 248 of file name-component.cpp.

Component ndn::name::Component::fromParametersSha256Digest ( ConstBufferPtr  digest)
static

Create ParametersSha256DigestComponent component.

Definition at line 332 of file name-component.cpp.

Component ndn::name::Component::fromParametersSha256Digest ( const uint8_t *  digest,
size_t  digestSize 
)
static

Create ParametersSha256DigestComponent component.

Definition at line 338 of file name-component.cpp.

Component ndn::name::Component::fromSegment ( uint64_t  segmentNo)
static

Create segment number component using NDN naming conventions.

See also
NDN Naming Conventions https://named-data.net/doc/tech-memos/naming-conventions.pdf

Definition at line 274 of file name-component.cpp.

Component ndn::name::Component::fromSegmentOffset ( uint64_t  offset)
static

Create segment offset component using NDN naming conventions.

See also
NDN Naming Conventions https://named-data.net/doc/tech-memos/naming-conventions.pdf

Definition at line 280 of file name-component.cpp.

Component ndn::name::Component::fromSequenceNumber ( uint64_t  seqNo)
static

Create sequence number component using NDN naming conventions.

See also
NDN Naming Conventions https://named-data.net/doc/tech-memos/naming-conventions.pdf

Definition at line 294 of file name-component.cpp.

Block ndn::Block::fromStream ( std::istream &  is)
staticinherited

Parse Block from an input stream.

Exceptions
tlv::ErrorTLV-LENGTH is zero or exceeds upper bound
Warning
If decoding fails, bytes are still consumed from the input stream.

Definition at line 161 of file block.cpp.

Component ndn::name::Component::fromTimestamp ( const time::system_clock::TimePoint timePoint)
static

Create sequence number component using NDN naming conventions.

See also
NDN Naming Conventions https://named-data.net/doc/tech-memos/naming-conventions.pdf

Definition at line 286 of file name-component.cpp.

Component ndn::name::Component::fromVersion ( uint64_t  version)
static

Create version component using NDN naming conventions.

See also
NDN Naming Conventions https://named-data.net/doc/tech-memos/naming-conventions.pdf

Definition at line 268 of file name-component.cpp.

const Block & ndn::Block::get ( uint32_t  type) const
inherited

Get the first sub element of specified TLV-TYPE.

Precondition
parse() has been executed
Exceptions
Errorsub element of type does not exist

Definition at line 422 of file block.cpp.

shared_ptr<const Buffer> ndn::Block::getBuffer ( ) const
inlineinherited

Get underlying buffer.

Definition at line 240 of file block.hpp.

Component ndn::name::Component::getSuccessor ( ) const

Get the successor of this name component.

The successor of a name component is defined as follows:

C represents the set of name components, and X,Y ∈ C.
Operator < is defined by canonical order on C.
Y is the successor of X, if (a) X < Y, and (b) ∄ Z ∈ C s.t. X < Z < Y.

In plain words, successor of a name component is the next possible name component.

Examples:

  • successor of sha256digest=0000000000000000000000000000000000000000000000000000000000000000 is sha256digest=0000000000000000000000000000000000000000000000000000000000000001.
  • successor of sha256digest=ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff is params-sha256=0000000000000000000000000000000000000000000000000000000000000000.
  • successor of params-sha256=0000000000000000000000000000000000000000000000000000000000000000 is params-sha256=0000000000000000000000000000000000000000000000000000000000000001.
  • successor of params-sha256=ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff is 3=....
  • successor of ... is %00.
  • successor of A is B.
  • successor of FF is %00%00.

Definition at line 380 of file name-component.cpp.

bool ndn::Block::hasValue ( ) const
inlineinherited

Get begin iterator of TLV-VALUE.

This property reflects whether the underlying buffer contains TLV-VALUE. If this is false, TLV-VALUE has zero-length. If this is true, TLV-VALUE may be zero-length.

Definition at line 260 of file block.hpp.

bool ndn::Block::hasWire ( ) const
inherited

Check if the Block has fully encoded wire.

A Block has fully encoded wire if the underlying buffer exists and contains full Type-Length-Value instead of just TLV-VALUE field.

Definition at line 249 of file block.cpp.

Block::element_iterator ndn::Block::insert ( Block::element_const_iterator  pos,
const Block element 
)
inherited

Insert a sub element.

Parameters
posposition of new sub element
elementnew sub element
Returns
iterator in elements() to the new sub element

Definition at line 472 of file block.cpp.

bool ndn::name::Component::isGeneric ( ) const

Check if the component is GenericComponent.

Definition at line 302 of file name-component.cpp.

bool ndn::name::Component::isImplicitSha256Digest ( ) const

Check if the component is ImplicitSha256DigestComponent.

Definition at line 308 of file name-component.cpp.

bool ndn::name::Component::isNumber ( ) const

Check if the component is nonNegativeInteger.

See also
https://named-data.net/doc/NDN-packet-spec/current/tlv.html#non-negative-integer-encoding

Definition at line 142 of file name-component.cpp.

bool ndn::name::Component::isNumberWithMarker ( uint8_t  marker) const

Check if the component is NameComponentWithMarker per NDN naming conventions.

See also
NDN Naming Conventions https://named-data.net/doc/tech-memos/naming-conventions.pdf

Definition at line 149 of file name-component.cpp.

bool ndn::name::Component::isParametersSha256Digest ( ) const

Check if the component is ParametersSha256DigestComponent.

Definition at line 326 of file name-component.cpp.

bool ndn::name::Component::isSegment ( ) const

Check if the component is segment number per NDN naming conventions.

See also
NDN Naming Conventions https://named-data.net/doc/tech-memos/naming-conventions.pdf

Definition at line 163 of file name-component.cpp.

bool ndn::name::Component::isSegmentOffset ( ) const

Check if the component is segment offset per NDN naming conventions.

See also
NDN Naming Conventions https://named-data.net/doc/tech-memos/naming-conventions.pdf

Definition at line 169 of file name-component.cpp.

bool ndn::name::Component::isSequenceNumber ( ) const

Check if the component is sequence number per NDN naming conventions.

See also
NDN Naming Conventions https://named-data.net/doc/tech-memos/naming-conventions.pdf

Definition at line 181 of file name-component.cpp.

bool ndn::name::Component::isTimestamp ( ) const

Check if the component is timestamp per NDN naming conventions.

See also
NDN Naming Conventions https://named-data.net/doc/tech-memos/naming-conventions.pdf

Definition at line 175 of file name-component.cpp.

bool ndn::name::Component::isVersion ( ) const

Check if the component is version per NDN naming conventions.

See also
NDN Naming Conventions https://named-data.net/doc/tech-memos/naming-conventions.pdf

Definition at line 157 of file name-component.cpp.

ndn::Block::operator boost::asio::const_buffer ( ) const
inherited

Implicit conversion to const_buffer.

Definition at line 480 of file block.cpp.

bool ndn::name::Component::operator!= ( const Component other) const
inline

Check if this is not the same component as other.

Parameters
otherThe other Component to compare with
Returns
true if the components are not equal, otherwise false

Definition at line 530 of file name-component.hpp.

bool ndn::name::Component::operator< ( const Component other) const
inline

Check if the *this is less than the other in NDN canonical ordering.

Parameters
otherThe other Component to compare with
See also
https://named-data.net/doc/NDN-packet-spec/current/name.html#canonical-order

Definition at line 554 of file name-component.hpp.

bool ndn::name::Component::operator<= ( const Component other) const
inline

Check if the *this is less than or equal to the other in NDN canonical ordering.

Parameters
otherThe other Component to compare with
See also
https://named-data.net/doc/NDN-packet-spec/current/name.html#canonical-order

Definition at line 542 of file name-component.hpp.

bool ndn::name::Component::operator== ( const Component other) const
inline

Check if this is the same component as other.

Parameters
otherThe other Component to compare with.
Returns
true if the components are equal, otherwise false.

Definition at line 519 of file name-component.hpp.

bool ndn::name::Component::operator> ( const Component other) const
inline

Check if the *this is greater than the other in NDN canonical ordering.

Parameters
otherThe other Component to compare with
See also
https://named-data.net/doc/NDN-packet-spec/current/name.html#canonical-order

Definition at line 578 of file name-component.hpp.

bool ndn::name::Component::operator>= ( const Component other) const
inline

Check if the *this is greater or equal than the other in NDN canonical ordering.

Parameters
otherThe other Component to compare with
See also
https://named-data.net/doc/NDN-packet-spec/current/name.html#canonical-order

Definition at line 566 of file name-component.hpp.

void ndn::Block::parse ( ) const
inherited

Parse TLV-VALUE into sub elements.

Postcondition
elements() reflects sub elements found in TLV-VALUE
Exceptions
tlv::ErrorTLV-VALUE is not a sequence of TLV elements
Note
This method does not perform recursive parsing.
This method has no effect if elements() is already populated.
This method is not really const, but it does not modify any data.

Definition at line 333 of file block.cpp.

void ndn::Block::push_back ( const Block element)
inherited

Append a sub element.

Definition at line 465 of file block.cpp.

void ndn::Block::remove ( uint32_t  type)
inherited

Remove all sub elements of specified TLV-TYPE.

Precondition
parse() has been executed
Postcondition
find(type) == elements_end()

Definition at line 441 of file block.cpp.

void ndn::Block::reset ( )
inherited

Reset wire buffer of the element.

Postcondition
empty() == true

Definition at line 255 of file block.cpp.

void ndn::Block::resetWire ( )
inherited

Reset wire buffer but keep TLV-TYPE and sub elements (if any)

Postcondition
hasWire() == false
hasValue() == false

Definition at line 264 of file block.cpp.

size_t ndn::Block::size ( ) const
inherited

Get size of encoded wire, including Type-Length-Value.

Precondition
empty() == false

Definition at line 298 of file block.cpp.

uint64_t ndn::name::Component::toNumber ( ) const

Interpret this name component as nonNegativeInteger.

See also
https://named-data.net/doc/NDN-packet-spec/current/tlv.html#non-negative-integer-encoding
Returns
The integer number.

Definition at line 189 of file name-component.cpp.

uint64_t ndn::name::Component::toNumberWithMarker ( uint8_t  marker) const

Interpret this name component as NameComponentWithMarker.

See also
NDN Naming Conventions https://named-data.net/doc/tech-memos/naming-conventions.pdf
Parameters
marker1-byte octet of the marker
Returns
The integer number.
Exceptions
Errorif name component does not have the specified marker. tlv::Error if format does not follow NameComponentWithMarker specification.

Definition at line 198 of file name-component.cpp.

uint64_t ndn::name::Component::toSegment ( ) const

Interpret as segment number component using NDN naming conventions.

See also
NDN Naming Conventions https://named-data.net/doc/tech-memos/naming-conventions.pdf
Exceptions
Errorif name component does not have the specified marker. tlv::Error if format does not follow NameComponentWithMarker specification.

Definition at line 215 of file name-component.cpp.

uint64_t ndn::name::Component::toSegmentOffset ( ) const

Interpret as segment offset component using NDN naming conventions.

See also
NDN Naming Conventions https://named-data.net/doc/tech-memos/naming-conventions.pdf
Exceptions
Errorif name component does not have the specified marker. tlv::Error if format does not follow NameComponentWithMarker specification.

Definition at line 221 of file name-component.cpp.

uint64_t ndn::name::Component::toSequenceNumber ( ) const

Interpret as sequence number component using NDN naming conventions.

See also
NDN Naming Conventions https://named-data.net/doc/tech-memos/naming-conventions.pdf
Exceptions
Errorif name component does not have the specified marker. tlv::Error if format does not follow NameComponentWithMarker specification.

Definition at line 234 of file name-component.cpp.

time::system_clock::TimePoint ndn::name::Component::toTimestamp ( ) const

Interpret as timestamp component using NDN naming conventions.

See also
NDN Naming Conventions https://named-data.net/doc/tech-memos/naming-conventions.pdf
Exceptions
Errorif name component does not have the specified marker. tlv::Error if format does not follow NameComponentWithMarker specification.

Definition at line 227 of file name-component.cpp.

void ndn::name::Component::toUri ( std::ostream &  os) const

Write *this to the output stream, escaping characters according to the NDN URI Scheme.

This also adds "..." to a value with zero or more "."

Parameters
osThe output stream where to write the URI escaped version of *this

Definition at line 126 of file name-component.cpp.

std::string ndn::name::Component::toUri ( ) const

Convert *this by escaping characters according to the NDN URI Scheme.

This also adds "..." to a value with zero or more "."

Returns
The escaped string

Definition at line 132 of file name-component.cpp.

uint64_t ndn::name::Component::toVersion ( ) const

Interpret as version component using NDN naming conventions.

See also
NDN Naming Conventions https://named-data.net/doc/tech-memos/naming-conventions.pdf
Exceptions
Errorif name component does not have the specified marker. tlv::Error if format does not follow NameComponentWithMarker specification.

Definition at line 209 of file name-component.cpp.

uint32_t ndn::Block::type ( ) const
inlineinherited

Get TLV-TYPE.

Definition at line 249 of file block.hpp.

const uint8_t * ndn::Block::value ( ) const
inherited

Get pointer to TLV-VALUE.

Definition at line 310 of file block.cpp.

Buffer::const_iterator ndn::Block::value_begin ( ) const
inlineinherited

Get begin iterator of TLV-VALUE.

Precondition
hasValue() == true

Definition at line 269 of file block.hpp.

Buffer::const_iterator ndn::Block::value_end ( ) const
inlineinherited

Get end iterator of TLV-VALUE.

Precondition
hasValue() == true

Definition at line 278 of file block.hpp.

size_t ndn::Block::value_size ( ) const
inherited

Get size of TLV-VALUE aka TLV-LENGTH.

Definition at line 316 of file block.cpp.

const uint8_t * ndn::Block::wire ( ) const
inherited

Get pointer to encoded wire.

Precondition
hasWire() == true

Definition at line 289 of file block.cpp.

void ndn::name::Component::wireDecode ( const Block wire)

Decode from the wire format.

Definition at line 426 of file name-component.cpp.

template<encoding::Tag TAG>
size_t ndn::name::Component::wireEncode ( EncodingImpl< TAG > &  encoder) const

Fast encoding or block size estimation.

Definition at line 397 of file name-component.cpp.

const Block & ndn::name::Component::wireEncode ( ) const

Encode to a wire format.

Definition at line 410 of file name-component.cpp.

Member Data Documentation

Buffer::const_iterator ndn::Block::m_begin
protectedinherited
See also
m_buffer

Definition at line 423 of file block.hpp.

shared_ptr<const Buffer> ndn::Block::m_buffer
protectedinherited

underlying buffer storing TLV-VALUE and possibly TLV-TYPE and TLV-LENGTH fields

If m_buffer is nullptr, this is an empty Block with TLV-TYPE given in m_type. Otherwise,

  • [m_valueBegin, m_valueEnd) point to TLV-VALUE within m_buffer.
  • If m_begin != m_end, [m_begin,m_end) point to Type-Length-Value of this Block within m_buffer. Otherwise, m_buffer does not contain TLV-TYPE and TLV-LENGTH fields.

Definition at line 422 of file block.hpp.

element_container ndn::Block::m_elements
mutableprotectedinherited

sub elements

This field is valid only if parse() has been executed.

Definition at line 441 of file block.hpp.

Buffer::const_iterator ndn::Block::m_end
protectedinherited
See also
m_buffer

Definition at line 424 of file block.hpp.

size_t ndn::Block::m_size = 0
protectedinherited

total size including Type-Length-Value

This field is valid only if empty() is false.

Definition at line 435 of file block.hpp.

uint32_t ndn::Block::m_type = std::numeric_limits<uint32_t>::max()
protectedinherited

TLV-TYPE.

Definition at line 429 of file block.hpp.

Buffer::const_iterator ndn::Block::m_valueBegin
protectedinherited
See also
m_buffer

Definition at line 426 of file block.hpp.

Buffer::const_iterator ndn::Block::m_valueEnd
protectedinherited
See also
m_buffer

Definition at line 427 of file block.hpp.