All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Public Member Functions | Static Public Member Functions | Friends | 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 GENERIC NameLite::Component of zero size.
 
 Component (const uint8_t *value, size_t valueLength, ndn_NameComponentType type=ndn_NameComponentType_GENERIC, int otherTypeCode=-1)
 Create a NameLite::Component with the given value. More...
 
 Component (const BlobLite &value, ndn_NameComponentType type=ndn_NameComponentType_GENERIC, int otherTypeCode=-1)
 Create a NameLite::Component taking the pointer and size from the BlobLite value. More...
 
const BlobLitegetValue () const
 Get the component value. More...
 
ndn_NameComponentType getType () const
 Get the name component type. More...
 
int getOtherTypeCode () const
 Get the component type code from the packet which is other than a recognized ndn_NameComponentType enum value. More...
 
bool isSegment () const
 Check if this component is a segment number according to NDN naming conventions for "Segment number" (marker 0x00) and return an integer. More...
 
bool isSegmentOffset () const
 Check if this component is a segment byte offset according to NDN naming conventions for "Byte offset" (marker 0xFB) and return an integer. More...
 
bool isVersion () const
 Check if this component is a version number according to NDN naming conventions for "Versioning" (marker 0xFD) and return an integer. More...
 
bool isTimestamp () const
 Check if this component is a timestamp according to NDN naming conventions for "Timestamp" (marker 0xFC) and return an integer. More...
 
bool isSequenceNumber () const
 Check if this component is a sequence number according to NDN naming conventions for "Sequencing" (marker 0xFE) and return an integer. More...
 
bool isGeneric () const
 Check if this component is a generic component. More...
 
bool isImplicitSha256Digest () const
 Check if this component is an ImplicitSha256Digest component. More...
 
bool isParametersSha256Digest () const
 Check if this component is a ParametersSha256Digest component. More...
 
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...
 
bool equals (const Component &other) const
 Check if this is the same component as other. More...
 
int compare (const Component &other) const
 Compare this component to the other component using NDN component ordering. More...
 
ndn_Error setFromNumber (uint64_t number, uint8_t *buffer, size_t bufferLength, ndn_NameComponentType type=ndn_NameComponentType_GENERIC, int otherTypeCode=-1)
 Set this name component to have a value which is the nonNegativeInteger encoding of the number. More...
 
ndn_Error setFromNumberWithMarker (uint64_t number, uint8_t marker, uint8_t *buffer, size_t bufferLength)
 Set this name component to have a value which is the marker appended with the nonNegativeInteger encoding of the number. More...
 
ndn_Error setSegment (uint64_t segment, uint8_t *buffer, size_t bufferLength)
 Set this name component to have the encoded segment number according to NDN naming conventions for "Segment number" (marker 0x00). More...
 
ndn_Error setSegmentOffset (uint64_t segmentOffset, uint8_t *buffer, size_t bufferLength)
 Set this name component to have the encoded segment byte offset according to NDN naming conventions for segment "Byte offset" (marker 0xFB). More...
 
ndn_Error setVersion (uint64_t version, uint8_t *buffer, size_t bufferLength)
 Set this name component to have the encoded version number according to NDN naming conventions for "Versioning" (marker 0xFD). More...
 
ndn_Error setTimestamp (uint64_t timestamp, uint8_t *buffer, size_t bufferLength)
 Set this name component to have the encoded timestamp according to NDN naming conventions for "Timestamp" (marker 0xFC). More...
 
ndn_Error setSequenceNumber (uint64_t sequenceNumber, uint8_t *buffer, size_t bufferLength)
 Set this name component to have the encoded sequence number according to NDN naming conventions for "Sequencing" (marker 0xFE). More...
 
ndn_Error setImplicitSha256Digest (const uint8_t *digest, size_t digestLength)
 Set this name component to have type ImplicitSha256DigestComponent with the given digest value, so that isImplicitSha256Digest() is true. More...
 
ndn_Error setImplicitSha256Digest (const BlobLite &digest)
 Set this name component to have type ImplicitSha256DigestComponent with the given digest value, so that isImplicitSha256Digest() is true. More...
 
ndn_Error setParametersSha256Digest (const uint8_t *digest, size_t digestLength)
 Set this name component to have type ParametersSha256DigestComponent with the given digest value, so that isParametersSha256Digest() is true. More...
 
ndn_Error setParametersSha256Digest (const BlobLite &digest)
 Set this name component to have type ParametersSha256DigestComponent with the given digest value, so that isParametersSha256Digest() is true. More...
 

Static Public Member Functions

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

Friends

class NameLite
 
class ExcludeLite
 

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,
ndn_NameComponentType  type = ndn_NameComponentType_GENERIC,
int  otherTypeCode = -1 
)

Create a NameLite::Component with the given value.

Parameters
valueThe pre-allocated buffer for the value.
valueLengthThe number of bytes in value.
type(optional) The component type as an int from the ndn_NameComponentType enum. If the name component type is not a recognized ndn_NameComponentType enum value, then set this to ndn_NameComponentType_OTHER_CODE and use the otherTypeCode parameter. If omitted, use ndn_NameComponentType_GENERIC.
otherTypeCode(optional) If type is ndn_NameComponentType_OTHER_CODE, then this is the packet's unrecognized content type code, which must be non-negative.
ndn::NameLite::Component::Component ( const BlobLite value,
ndn_NameComponentType  type = ndn_NameComponentType_GENERIC,
int  otherTypeCode = -1 
)

Create a NameLite::Component taking the pointer and size from the BlobLite value.

Parameters
valueThe BlobLite with the pointer to use for this component.
type(optional) The component type as an int from the ndn_NameComponentType enum. If the name component type is not a recognized ndn_NameComponentType enum value, then set this to ndn_NameComponentType_OTHER_CODE and use the otherTypeCode parameter. If omitted, use ndn_NameComponentType_GENERIC.
otherTypeCode(optional) If type is ndn_NameComponentType_OTHER_CODE, then this is the packet's unrecognized content type code, which must be non-negative.

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.
static Component& ndn::NameLite::Component::downCast ( ndn_NameComponent component)
inlinestatic

Downcast 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.
bool ndn::NameLite::Component::equals ( const Component other) const

Check if this is the same component as other.

Parameters
otherThe other name component to check.
Returns
True if the components are equal, false if not.
int ndn::NameLite::Component::getOtherTypeCode ( ) const
inline

Get the component type code from the packet which is other than a recognized ndn_NameComponentType enum value.

This is only meaningful if getType() is ndn_NameComponentType_OTHER_CODE.

Returns
The type code.
ndn_NameComponentType ndn::NameLite::Component::getType ( ) const
inline

Get the name component type.

Returns
The name component type enum value. If this is ndn_NameComponentType_OTHER_CODE, then call getOtherTypeCode() to get the unrecognized component type code.
const BlobLite& ndn::NameLite::Component::getValue ( ) const
inline

Get the component value.

Returns
The component value.
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.
bool ndn::NameLite::Component::isGeneric ( ) const

Check if this component is a generic component.

Returns
True if this is a generic component.
bool ndn::NameLite::Component::isImplicitSha256Digest ( ) const

Check if this component is an ImplicitSha256Digest component.

Returns
True if this is an ImplicitSha256Digest component.
bool ndn::NameLite::Component::isParametersSha256Digest ( ) const

Check if this component is a ParametersSha256Digest component.

Returns
True if this is a ParametersSha256Digest component.
bool ndn::NameLite::Component::isSegment ( ) const

Check if this component is a segment number according to NDN naming conventions for "Segment number" (marker 0x00) and return an integer.

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

Returns
True if this is a segment number.
bool ndn::NameLite::Component::isSegmentOffset ( ) const

Check if this component is a segment byte offset according to NDN naming conventions for "Byte offset" (marker 0xFB) and return an integer.

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

Returns
True if this is a segment byte offset.
bool ndn::NameLite::Component::isSequenceNumber ( ) const

Check if this component is a sequence number according to NDN naming conventions for "Sequencing" (marker 0xFE) and return an integer.

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

Returns
True if this is a sequence number.
bool ndn::NameLite::Component::isTimestamp ( ) const

Check if this component is a timestamp according to NDN naming conventions for "Timestamp" (marker 0xFC) and return an integer.

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

Returns
True if this is a timestamp.
bool ndn::NameLite::Component::isVersion ( ) const

Check if this component is a version number according to NDN naming conventions for "Versioning" (marker 0xFD) and return an integer.

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

Returns
True if this is a version number.
ndn_Error ndn::NameLite::Component::setFromNumber ( uint64_t  number,
uint8_t *  buffer,
size_t  bufferLength,
ndn_NameComponentType  type = ndn_NameComponentType_GENERIC,
int  otherTypeCode = -1 
)

Set this name component to have a value which is the nonNegativeInteger encoding of the number.

Also set the type to ndn_NameComponentType_GENERIC.

Parameters
numberThe number to be encoded.
bufferThe allocated buffer to hold the name component value. This buffer must remain valid during the life of the name component. It is the caller's responsibility to free this buffer if necessary when finished with it.
bufferLengthThe number of bytes in the allocated buffer. This should be at least 8 bytes to hold a 64-bit value.
type(optional) The component type as an int from the ndn_NameComponentType enum. If the name component type is not a recognized ndn_NameComponentType enum value, then set this to ndn_NameComponentType_OTHER_CODE and use the otherTypeCode parameter. If omitted, use ndn_NameComponentType_GENERIC.
otherTypeCode(optional) If type is ndn_NameComponentType_OTHER_CODE, then this is the packet's unrecognized content type code, which must be non-negative.
Returns
0 for success, or an error code if bufferLength is too small.
ndn_Error ndn::NameLite::Component::setFromNumberWithMarker ( uint64_t  number,
uint8_t  marker,
uint8_t *  buffer,
size_t  bufferLength 
)

Set this name component to have a value which is the marker appended with the nonNegativeInteger encoding of the number.

Also set the type to ndn_NameComponentType_GENERIC.

Parameters
numberThe number to be encoded.
markerThe marker to use as the first byte of the component.
bufferThe allocated buffer to hold the name component value. This buffer must remain valid during the life of the name component. It is the caller's responsibility to free this buffer if necessary when finished with it.
bufferLengthThe number of bytes in the allocated buffer. This should be at least 9 bytes to hold a marker plus a 64-bit value.
Returns
0 for success, or an error code if bufferLength is too small.
ndn_Error ndn::NameLite::Component::setImplicitSha256Digest ( const uint8_t *  digest,
size_t  digestLength 
)

Set this name component to have type ImplicitSha256DigestComponent with the given digest value, so that isImplicitSha256Digest() is true.

Parameters
digestThe pre-allocated buffer for the SHA-256 digest value.
digestLengthThe length of digest, which must be ndn_SHA256_DIGEST_SIZE.
Returns
0 for success, or an error code if digestLength is not ndn_SHA256_DIGEST_SIZE.
ndn_Error ndn::NameLite::Component::setImplicitSha256Digest ( const BlobLite digest)
inline

Set this name component to have type ImplicitSha256DigestComponent with the given digest value, so that isImplicitSha256Digest() is true.

Parameters
digestThe BlobLite with the pre-allocated buffer for the SHA-256 digest value. Its size must be ndn_SHA256_DIGEST_SIZE.
Returns
0 for success, or an error code if digest.size() is not ndn_SHA256_DIGEST_SIZE.
ndn_Error ndn::NameLite::Component::setParametersSha256Digest ( const uint8_t *  digest,
size_t  digestLength 
)

Set this name component to have type ParametersSha256DigestComponent with the given digest value, so that isParametersSha256Digest() is true.

Parameters
digestThe pre-allocated buffer for the SHA-256 digest value.
digestLengthThe length of digest, which must be ndn_SHA256_DIGEST_SIZE.
Returns
0 for success, or an error code if digestLength is not ndn_SHA256_DIGEST_SIZE.
ndn_Error ndn::NameLite::Component::setParametersSha256Digest ( const BlobLite digest)
inline

Set this name component to have type ParametersSha256DigestComponent with the given digest value, so that isParametersSha256Digest() is true.

Parameters
digestThe pre-allocated buffer for the SHA-256 digest value.
digestLengthThe length of digest, which must be ndn_SHA256_DIGEST_SIZE.
Returns
0 for success, or an error code if digestLength is not ndn_SHA256_DIGEST_SIZE.
ndn_Error ndn::NameLite::Component::setSegment ( uint64_t  segment,
uint8_t *  buffer,
size_t  bufferLength 
)

Set this name component to have the encoded segment number according to NDN naming conventions for "Segment number" (marker 0x00).

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

Parameters
segmentThe segment number.
bufferThe allocated buffer to hold the name component value. This buffer must remain valid during the life of the name component. It is the caller's responsibility to free this buffer if necessary when finished with it.
bufferLengthThe number of bytes in the allocated buffer. This should be at least 9 bytes to hold a marker plus a 64-bit value.
Returns
0 for success, or an error code if bufferLength is too small.
ndn_Error ndn::NameLite::Component::setSegmentOffset ( uint64_t  segmentOffset,
uint8_t *  buffer,
size_t  bufferLength 
)

Set this name component to have the encoded 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
segmentOffsetThe segment byte offset.
bufferThe allocated buffer to hold the name component value. This buffer must remain valid during the life of the name component. It is the caller's responsibility to free this buffer if necessary when finished with it.
bufferLengthThe number of bytes in the allocated buffer. This should be at least 9 bytes to hold a marker plus a 64-bit value.
Returns
0 for success, or an error code if bufferLength is too small.
ndn_Error ndn::NameLite::Component::setSequenceNumber ( uint64_t  sequenceNumber,
uint8_t *  buffer,
size_t  bufferLength 
)

Set this name component to have the encoded sequence number according to NDN naming conventions for "Sequencing" (marker 0xFE).

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

Parameters
sequenceNumberThe sequence number.
bufferThe allocated buffer to hold the name component value. This buffer must remain valid during the life of the name component. It is the caller's responsibility to free this buffer if necessary when finished with it.
bufferLengthThe number of bytes in the allocated buffer. This should be at least 9 bytes to hold a marker plus a 64-bit value.
Returns
0 for success, or an error code if bufferLength is too small.
ndn_Error ndn::NameLite::Component::setTimestamp ( uint64_t  timestamp,
uint8_t *  buffer,
size_t  bufferLength 
)

Set this name component to have the encoded timestamp according to NDN naming conventions for "Timestamp" (marker 0xFC).

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

Parameters
timestampThe number of microseconds since the UNIX epoch (Thursday, 1 January 1970) not counting leap seconds.
bufferThe allocated buffer to hold the name component value. This buffer must remain valid during the life of the name component. It is the caller's responsibility to free this buffer if necessary when finished with it.
bufferLengthThe number of bytes in the allocated buffer. This should be at least 9 bytes to hold a marker plus a 64-bit value.
Returns
0 for success, or an error code if bufferLength is too small.
ndn_Error ndn::NameLite::Component::setVersion ( uint64_t  version,
uint8_t *  buffer,
size_t  bufferLength 
)

Set this name component to have the encoded version number according to NDN naming conventions for "Versioning" (marker 0xFD).

http://named-data.net/doc/tech-memos/naming-conventions.pdf Note that this encodes the exact value of version without converting from a time representation.

Parameters
versionThe version number.
bufferThe allocated buffer to hold the name component value. This buffer must remain valid during the life of the name component. It is the caller's responsibility to free this buffer if necessary when finished with it.
bufferLengthThe number of bytes in the allocated buffer. This should be at least 9 bytes to hold a marker plus a 64-bit value.
Returns
0 for success, or an error code if bufferLength is too small.
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.

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