Public Member Functions | Static Public Member Functions | List of all members
ndn::Name::Component Class Reference

A Name::Component holds a read-only name component value. More...

#include <name.hpp>

Public Member Functions

 Component ()
 Create a new Name::Component with a zero-length value.
 
 Component (const std::vector< uint8_t > &value)
 Create a new Name::Component, copying the given value. More...
 
 Component (const uint8_t *value, size_t valueLen)
 Create a new Name::Component, copying the given value. More...
 
 Component (const char *value)
 Create a new Name::Component, copying the bytes from the value string. More...
 
 Component (const std::string &value)
 Create a new Name::Component, copying the bytes from the value string. More...
 
 Component (const Blob &value)
 Create a new Name::Component, taking another pointer to the Blob value. More...
 
void get (struct ndn_NameComponent &componentStruct) const
 Set the componentStruct to point to this component, without copying any memory. More...
 
const BlobgetValue () const
 
void toEscapedString (std::ostringstream &result) const
 Write this component value to result, escaping characters according to the NDN URI Scheme. More...
 
std::string toEscapedString () const
 Convert this component value by escaping characters according to the NDN URI Scheme. More...
 
uint64_t toNumber () const
 Interpret this name component as a network-ordered number and return an integer. More...
 
uint64_t toNumberWithMarker (uint8_t marker) const
 Interpret this name component as a network-ordered number with a marker and return an integer. More...
 
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. More...
 
bool hasPrefix (const uint8_t *prefix, size_t prefixLength) const
 Check if this name component begins with the given prefix. More...
 
uint64_t toSegment () const
 Interpret this name component as a segment number according to NDN naming conventions for "Segment number" (marker 0x00). More...
 
uint64_t toSegmentOffset () const
 Interpret this name component as a segment byte offset according to NDN naming conventions for segment "Byte offset" (marker 0xFB). More...
 
uint64_t DEPRECATED_IN_NDN_CPP toSeqNum () const
 
bool DEPRECATED_IN_NDN_CPP isFinalSegment () const
 
uint64_t DEPRECATED_IN_NDN_CPP toFinalSegment () const
 
uint64_t toVersion () const
 Interpret this name component as a version number according to NDN naming conventions for "Versioning" (marker 0xFD). More...
 
uint64_t toTimestamp () const
 Interpret this name component as a timestamp according to NDN naming conventions for "Timestamp" (marker 0xFC). More...
 
uint64_t toSequenceNumber () const
 Interpret this name component as a sequence number according to NDN naming conventions for "Sequencing" (marker 0xFE). More...
 
bool equals (const Component &other) const
 Check if this is the same component as other. 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 this is not the same component as other. More...
 
int compare (const Component &other) const
 Compare this to the other Component using NDN canonical ordering. More...
 
bool operator<= (const Component &other) const
 Return true if this is less than or equal to the other Component in the NDN canonical ordering. More...
 
bool operator< (const Component &other) const
 Return true if this is less than the other Component in the NDN canonical ordering. More...
 
bool operator>= (const Component &other) const
 Return true if this is less than or equal to the other Component in the NDN canonical ordering. More...
 
bool operator> (const Component &other) const
 Return true if this is greater than the other Component in the NDN canonical ordering. More...
 

Static Public Member Functions

static Component fromNumber (uint64_t number)
 Create a component whose value is the nonNegativeInteger encoding of the number. More...
 
static Component fromNumberWithMarker (uint64_t number, uint8_t marker)
 Create a component whose value is the marker appended with the nonNegativeInteger encoding of the number. More...
 
static Component fromNumberWithPrefix (uint64_t number, const uint8_t *prefix, size_t prefixLength)
 Create a component whose value is the prefix appended with the network-ordered encoding of the number. More...
 
static const uint8_t * getFinalSegmentPrefix ()
 
static size_t getFinalSegmentPrefixLength ()
 

Detailed Description

A Name::Component holds a read-only name component value.

Constructor & Destructor Documentation

ndn::Name::Component::Component ( const std::vector< uint8_t > &  value)
inline

Create a new Name::Component, copying the given value.

Parameters
valueThe value byte array.
ndn::Name::Component::Component ( const uint8_t *  value,
size_t  valueLen 
)
inline

Create a new Name::Component, copying the given value.

Parameters
valuePointer to the value byte array.
valueLenLength of value.
ndn::Name::Component::Component ( const char *  value)
inline

Create a new Name::Component, copying the bytes from the value string.

NOTE: This does not escape XX values. If you need to escape, use Name::fromEscapedString. Also, if the string has "/", this does not split into separate components. If you need that then use Name(value).

Parameters
valueA null-terminated string with the bytes to copy.
ndn::Name::Component::Component ( const std::string &  value)
inline

Create a new Name::Component, copying the bytes from the value string.

NOTE: This does not escape XX values. If you need to escape, use Name::fromEscapedString. Also, if the string has "/", this does not split into separate components. If you need that then use Name(value).

Parameters
valueA string with the bytes to copy.
ndn::Name::Component::Component ( const Blob value)
inline

Create a new Name::Component, taking another pointer to the Blob value.

Parameters
valueA blob with a pointer to an immutable array. The pointer is copied.

Member Function Documentation

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.
Returns
0 If they compare equal, -1 if *this comes before other in the canonical ordering, or 1 if *this comes after other in the canonical ordering.
See also
http://named-data.net/doc/0.2/technical/CanonicalOrder.html
bool ndn::Name::Component::equals ( 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.
Name::Component ndn::Name::Component::fromNumber ( uint64_t  number)
static

Create a component whose value is the nonNegativeInteger encoding of the number.

Parameters
numberThe number to be encoded.
Returns
The component value.
Name::Component ndn::Name::Component::fromNumberWithMarker ( uint64_t  number,
uint8_t  marker 
)
static

Create a component whose value is the marker appended with the nonNegativeInteger encoding of the number.

Parameters
numberThe number to be encoded.
markerThe marker to use as the first byte of the component.
Returns
The component value.
Name::Component ndn::Name::Component::fromNumberWithPrefix ( uint64_t  number,
const uint8_t *  prefix,
size_t  prefixLength 
)
static

Create a component whose value is the prefix appended with the network-ordered encoding of the number.

Note: if the number is zero, no bytes are used for the number - the result will have only the prefix.

Parameters
numberThe number to be encoded.
prefixThe prefix to use as the first bytes of the component.
prefixLengthThe length of prefix.
Returns
The component value.
void ndn::Name::Component::get ( struct ndn_NameComponent & componentStruct  ) const

Set the componentStruct to point to this component, without copying any memory.

WARNING: The resulting pointer in componentStruct is invalid after a further use of this object which could reallocate memory.

Parameters
componentStructThe C ndn_NameComponent struct to receive the pointer.
static const uint8_t* ndn::Name::Component::getFinalSegmentPrefix ( )
inlinestatic
static size_t ndn::Name::Component::getFinalSegmentPrefixLength ( )
inlinestatic
bool ndn::Name::Component::hasPrefix ( const uint8_t *  prefix,
size_t  prefixLength 
) const

Check if this name component begins with the given prefix.

Parameters
prefixThe required prefix of the component.
prefixLengthThe length of prefix.
Returns
true if this component begins with the prefix.
bool DEPRECATED_IN_NDN_CPP ndn::Name::Component::isFinalSegment ( ) const
inline
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.
bool ndn::Name::Component::operator< ( const Component other) const
inline

Return true if this is less than the other Component in the NDN canonical ordering.

Parameters
otherThe other Component to compare with.
See also
http://named-data.net/doc/0.2/technical/CanonicalOrder.html
bool ndn::Name::Component::operator<= ( const Component other) const
inline

Return true if this is less than or equal to the other Component in the NDN canonical ordering.

Parameters
otherThe other Component to compare with.
See also
http://named-data.net/doc/0.2/technical/CanonicalOrder.html
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.
bool ndn::Name::Component::operator> ( const Component other) const
inline

Return true if this is greater than the other Component in the NDN canonical ordering.

Parameters
otherThe other Component to compare with.
See also
http://named-data.net/doc/0.2/technical/CanonicalOrder.html
bool ndn::Name::Component::operator>= ( const Component other) const
inline

Return true if this is less than or equal to the other Component in the NDN canonical ordering.

Parameters
otherThe other Component to compare with.
See also
http://named-data.net/doc/0.2/technical/CanonicalOrder.html
void ndn::Name::Component::toEscapedString ( std::ostringstream &  result) const
inline

Write this component value to result, escaping characters according to the NDN URI Scheme.

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

Parameters
resultthe string stream to write to.
std::string ndn::Name::Component::toEscapedString ( ) const
inline

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

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

Returns
The escaped string.
uint64_t DEPRECATED_IN_NDN_CPP ndn::Name::Component::toFinalSegment ( ) const
inline
uint64_t ndn::Name::Component::toNumber ( ) const

Interpret this name component as a network-ordered number and return an integer.

Returns
The integer number.
uint64_t ndn::Name::Component::toNumberWithMarker ( uint8_t  marker) const

Interpret this name component as a network-ordered number with a marker and return an integer.

Parameters
markerThe required first byte of the component.
Returns
The integer number.
Exceptions
runtime_errorIf the first byte of the component does not equal the marker.
uint64_t ndn::Name::Component::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.

Parameters
prefixThe required prefix of the component.
prefixLengthThe length of prefix.
Returns
The integer number.
Exceptions
runtime_errorIf the first bytes of the component do not equal the prefix.
uint64_t ndn::Name::Component::toSegment ( ) const
inline

Interpret this name component as a segment number according to NDN naming conventions for "Segment number" (marker 0x00).

http://named-data.net/doc/tech-memos/naming-conventions.pdf

Returns
The integer segment number.
Exceptions
runtime_errorIf the first byte of the component is not the expected marker.
uint64_t ndn::Name::Component::toSegmentOffset ( ) const
inline

Interpret this name component as a segment byte offset according to NDN naming conventions for segment "Byte offset" (marker 0xFB).

http://named-data.net/doc/tech-memos/naming-conventions.pdf

Returns
The integer segment byte offset.
Exceptions
runtime_errorIf the first byte of the component is not the expected marker.
uint64_t DEPRECATED_IN_NDN_CPP ndn::Name::Component::toSeqNum ( ) const
inline
Deprecated:
Use toSegment.
uint64_t ndn::Name::Component::toSequenceNumber ( ) const
inline

Interpret this name component as a sequence number according to NDN naming conventions for "Sequencing" (marker 0xFE).

http://named-data.net/doc/tech-memos/naming-conventions.pdf

Returns
The integer sequence number.
Exceptions
runtime_errorIf the first byte of the component is not the expected marker.
uint64_t ndn::Name::Component::toTimestamp ( ) const
inline

Interpret this name component as a timestamp according to NDN naming conventions for "Timestamp" (marker 0xFC).

http://named-data.net/doc/tech-memos/naming-conventions.pdf

Returns
The number of microseconds since the UNIX epoch (Thursday, 1 January 1970) not counting leap seconds.
Exceptions
runtime_errorIf the first byte of the component is not the expected marker.
uint64_t ndn::Name::Component::toVersion ( ) const
inline

Interpret this name component as a version number according to NDN naming conventions for "Versioning" (marker 0xFD).

Note that this returns the exact number from the component without converting it to a time representation.

Returns
The integer version number.
Exceptions
runtime_errorIf the first byte of the component is not the expected marker.

The documentation for this class was generated from the following files: