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

A NameLite::Component holds a pointer to the component value. More...

#include <name-lite.hpp>

Inheritance diagram for ndn::NameLite::Component:
ndn_NameComponent

Public Member Functions

 Component ()
 Create a NameLite::Component of zero size.
 
 Component (const uint8_t *value, size_t valueLength)
 Create a NameLite::Component with the given value. More...
 
const BlobLitegetValue () const
 
uint64_t toNumber () const
 Interpret the name component as a network-ordered number and return an integer. More...
 
ndn_Error toNumberWithMarker (uint8_t marker, uint64_t &result) const
 Interpret the name component as a network-ordered number with a marker and return an integer. More...
 
ndn_Error toNumberWithPrefix (const uint8_t *prefix, size_t prefixLength, uint64_t &result) const
 Interpret the 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...
 
ndn_Error toSegment (uint64_t &result) const
 Interpret this name component as a segment number according to NDN naming conventions for "Segment number" (marker 0x00). More...
 
ndn_Error toSegmentOffset (uint64_t &result) const
 Interpret this name component as a segment byte offset according to NDN naming conventions for segment "Byte offset" (marker 0xFB). More...
 
ndn_Error toVersion (uint64_t &result) const
 Interpret this name component as a version number according to NDN naming conventions for "Versioning" (marker 0xFD). More...
 
ndn_Error toTimestamp (uint64_t &result) const
 Interpret this name component as a timestamp according to NDN naming conventions for "Timestamp" (marker 0xFC). More...
 
ndn_Error toSequenceNumber (uint64_t &result) const
 Interpret this name component as a sequence number according to NDN naming conventions for "Sequencing" (marker 0xFE). More...
 
int compare (const Component &other) const
 Compare this component to the other component using NDN component ordering. More...
 

Static Public Member Functions

static ComponentupCast (ndn_NameComponent &component)
 Upcast the reference to the ndn_NameComponent struct to a NameLite::Component. More...
 
static const ComponentupCast (const ndn_NameComponent &component)
 

Detailed Description

A NameLite::Component holds a pointer to the component value.

Constructor & Destructor Documentation

ndn::NameLite::Component::Component ( const uint8_t *  value,
size_t  valueLength 
)

Create a NameLite::Component with the given value.

Parameters
valueThe pre-allocated buffer for the value.
valueLengthThe number of bytes in value.

Member Function Documentation

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

Compare this component to the other component using NDN component ordering.

A component is less if it is shorter, otherwise if equal length do a byte comparison.

Parameters
otherThe other name component to compare with.
Returns
-1 if self is less than other, 1 if greater or 0 if equal.
bool ndn::NameLite::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.
uint64_t ndn::NameLite::Component::toNumber ( ) const

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

Returns
The integer number.
ndn_Error ndn::NameLite::Component::toNumberWithMarker ( uint8_t  marker,
uint64_t &  result 
) const

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

Parameters
markerThe required first byte of the component.
resultReturn the integer number.
Returns
0 for success, or an error code if the first byte of the component does not equal the marker.
ndn_Error ndn::NameLite::Component::toNumberWithPrefix ( const uint8_t *  prefix,
size_t  prefixLength,
uint64_t &  result 
) const

Interpret the 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.
resultReturn the integer number.
Returns
0 for success, or an error code if the first bytes of the component do not equal the prefix.
ndn_Error ndn::NameLite::Component::toSegment ( uint64_t &  result) const

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

Parameters
resultReturn the integer segment number.
Returns
0 for success, or an error code if the first byte of the component is not the expected marker.
ndn_Error ndn::NameLite::Component::toSegmentOffset ( uint64_t &  result) const

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

Parameters
resultReturn the integer segment byte offset.
Returns
0 for success, or an error code if the first byte of the component is not the expected marker.
ndn_Error ndn::NameLite::Component::toSequenceNumber ( uint64_t &  result) const

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

Parameters
resultReturn the integer sequence number.
Returns
0 for success, or an error code if the first byte of the component is not the expected marker.
ndn_Error ndn::NameLite::Component::toTimestamp ( uint64_t &  result) const

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

Parameters
resultReturn the number of microseconds since the UNIX epoch (Thursday, 1 January 1970) not counting leap seconds.
Returns
0 for success, or an error code if the first byte of the component is not the expected marker.
ndn_Error ndn::NameLite::Component::toVersion ( uint64_t &  result) const

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.

Parameters
resultReturn the integer version number.
Returns
0 for success, or an error code if the first byte of the component is not the expected marker.
static Component& ndn::NameLite::Component::upCast ( ndn_NameComponent component)
inlinestatic

Upcast the reference to the ndn_NameComponent struct to a NameLite::Component.

Parameters
componentA reference to the ndn_NameComponent struct.
Returns
The same reference as NameLite::Component.

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