All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Classes | Public Member Functions | Static Public Member Functions | Friends | List of all members
ndn::NameLite Class Reference

A NameLite holds an array of NameLite::Component. More...

#include <name-lite.hpp>

Inheritance diagram for ndn::NameLite:
ndn_Name

Classes

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

Public Member Functions

 NameLite (ndn_NameComponent *components, size_t maxComponents)
 Create a NameLite to use the components array. More...
 
const Componentget (int i) const
 Get the component at the given index. More...
 
size_t size () const
 Get the number of components. More...
 
bool equals (const NameLite &name)
 Check if this name has the same component count and components as the given name. More...
 
bool match (const NameLite &name) const
 Check if the N components of this name are the same as the first N components of the given name. More...
 
void clear ()
 Clear all the components.
 
ndn_Error append (const uint8_t *value, size_t valueLength, ndn_NameComponentType type=ndn_NameComponentType_GENERIC, int otherTypeCode=-1)
 Append a component to this name with the bytes in the given buffer. More...
 
ndn_Error append (const BlobLite &value, ndn_NameComponentType type=ndn_NameComponentType_GENERIC, int otherTypeCode=-1)
 Append a component to this name with the bytes in the given blob. More...
 
ndn_Error append (const Component &component)
 Append a component to this name with the bytes in the given component's value and the component's type. More...
 
ndn_Error append (const NameLite &name)
 Append all of the components of the given name to this name, including each component's type. More...
 
ndn_Error append (const char *value, ndn_NameComponentType type=ndn_NameComponentType_GENERIC, int otherTypeCode=-1)
 Append a component to this name with the bytes in raw string value. More...
 
ndn_Error appendSegment (uint64_t segment, uint8_t *buffer, size_t bufferLength)
 Append a component with the encoded segment number according to NDN naming conventions for "Segment number" (marker 0x00). More...
 
ndn_Error appendSegmentOffset (uint64_t segmentOffset, uint8_t *buffer, size_t bufferLength)
 Append a component with the encoded segment byte offset according to NDN naming conventions for segment "Byte offset" (marker 0xFB). More...
 
ndn_Error appendVersion (uint64_t version, uint8_t *buffer, size_t bufferLength)
 Append a component with the encoded version number according to NDN naming conventions for "Versioning" (marker 0xFD). More...
 
ndn_Error appendTimestamp (uint64_t timestamp, uint8_t *buffer, size_t bufferLength)
 Append a component with the encoded timestamp according to NDN naming conventions for "Timestamp" (marker 0xFC). More...
 
ndn_Error appendSequenceNumber (uint64_t sequenceNumber, uint8_t *buffer, size_t bufferLength)
 Append a component with the encoded sequence number according to NDN naming conventions for "Sequencing" (marker 0xFE). More...
 
ndn_Error appendImplicitSha256Digest (const uint8_t *digest, size_t digestLength)
 Append a component of type ImplicitSha256DigestComponent to this name with the given digest value, so that isImplicitSha256Digest() is true. More...
 
ndn_Error appendImplicitSha256Digest (const BlobLite &digest)
 Append a component of type ImplicitSha256DigestComponent to this name with the given digest value, so that isImplicitSha256Digest() is true. More...
 
ndn_Error appendParametersSha256Digest (const uint8_t *digest, size_t digestLength)
 Append a component of type ParametersSha256DigestComponent to this name with the given digest value, so that isParametersSha256Digest() is true. More...
 
ndn_Error appendParametersSha256Digest (const BlobLite &digest)
 Append a component of type ParametersSha256DigestComponent to this name with the given digest value, so that isParametersSha256Digest() is true. More...
 
ndn_Error set (const NameLite &other)
 Set this name to have the values from the other name. More...
 
const Componentpop ()
 Remove and return the last name component. More...
 

Static Public Member Functions

static NameLitedownCast (ndn_Name &name)
 Downcast the reference to the ndn_Name struct to a NameLite. More...
 
static const NameLitedownCast (const ndn_Name &name)
 

Friends

class Tlv0_2WireFormatLite
 

Additional Inherited Members

- Public Attributes inherited from ndn_Name
struct ndn_NameComponentcomponents
 pointer to the array of components. More...
 
size_t maxComponents
 the number of elements in the allocated components array
 
size_t nComponents
 the number of components in the name
 

Detailed Description

A NameLite holds an array of NameLite::Component.

Constructor & Destructor Documentation

ndn::NameLite::NameLite ( ndn_NameComponent components,
size_t  maxComponents 
)

Create a NameLite to use the components array.

Parameters
componentsthe pre-allocated array of ndn_NameComponent. Instead of an array of NameLite::Component, this is an array of the underlying ndn_NameComponent struct so that it doesn't run the default constructor unnecessarily.
maxComponentsthe number of elements in the allocated components array.

Member Function Documentation

ndn_Error ndn::NameLite::append ( const uint8_t *  value,
size_t  valueLength,
ndn_NameComponentType  type = ndn_NameComponentType_GENERIC,
int  otherTypeCode = -1 
)

Append a component to this name with the bytes in the given buffer.

Parameters
valueA pointer to the buffer with the bytes of the component. This does not copy the bytes.
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.
Returns
0 for success, or an error code if there is no more room in the components array.
ndn_Error ndn::NameLite::append ( const BlobLite value,
ndn_NameComponentType  type = ndn_NameComponentType_GENERIC,
int  otherTypeCode = -1 
)
inline

Append a component to this name with the bytes in the given blob.

Parameters
valueA BlobLite with the bytes of the component. This does not copy the bytes.
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 there is no more room in the components array.
ndn_Error ndn::NameLite::append ( const Component component)

Append a component to this name with the bytes in the given component's value and the component's type.

Parameters
componentA Component with the bytes of the component value. This does not copy the bytes.
Returns
0 for success, or an error code if there is no more room in the components array.
ndn_Error ndn::NameLite::append ( const NameLite name)

Append all of the components of the given name to this name, including each component's type.

Parameters
nameThe NameLite with the components to copy.
Returns
0 for success, or an error code if there is no more room in the components array.
ndn_Error ndn::NameLite::append ( const char *  value,
ndn_NameComponentType  type = ndn_NameComponentType_GENERIC,
int  otherTypeCode = -1 
)

Append a component to this name with the bytes in raw string value.

Parameters
valueThe null-terminated string, treated as a byte array. This does not copy the bytes.
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 there is no more room in the components array (nComponents is already maxComponents).
ndn_Error ndn::NameLite::appendImplicitSha256Digest ( const uint8_t *  digest,
size_t  digestLength 
)

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

Parameters
sequenceNumberThe sequence number.
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, or if there is no more room in the components array (nComponents is already maxComponents).
ndn_Error ndn::NameLite::appendImplicitSha256Digest ( const BlobLite digest)
inline

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

Parameters
sequenceNumberThe sequence number.
digestThe pre-allocated SHA-256 digest value, whose size must be ndn_SHA256_DIGEST_SIZE.
Returns
0 for success, or an error code if digestLength is not ndn_SHA256_DIGEST_SIZE, or if there is no more room in the components array (nComponents is already maxComponents).
ndn_Error ndn::NameLite::appendParametersSha256Digest ( const uint8_t *  digest,
size_t  digestLength 
)

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

Parameters
sequenceNumberThe sequence number.
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, or if there is no more room in the components array (nComponents is already maxComponents).
ndn_Error ndn::NameLite::appendParametersSha256Digest ( const BlobLite digest)
inline

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

Parameters
sequenceNumberThe sequence number.
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, or if there is no more room in the components array (nComponents is already maxComponents).
ndn_Error ndn::NameLite::appendSegment ( uint64_t  segment,
uint8_t *  buffer,
size_t  bufferLength 
)

Append a component with 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 there is no more room in the components array or if bufferLength is too small.
ndn_Error ndn::NameLite::appendSegmentOffset ( uint64_t  segmentOffset,
uint8_t *  buffer,
size_t  bufferLength 
)

Append a component with 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 there is no more room in the components array or if bufferLength is too small.
ndn_Error ndn::NameLite::appendSequenceNumber ( uint64_t  sequenceNumber,
uint8_t *  buffer,
size_t  bufferLength 
)

Append a component with 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 there is no more room in the components array or if bufferLength is too small.
ndn_Error ndn::NameLite::appendTimestamp ( uint64_t  timestamp,
uint8_t *  buffer,
size_t  bufferLength 
)

Append a component with 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 there is no more room in the components array or if bufferLength is too small.
ndn_Error ndn::NameLite::appendVersion ( uint64_t  version,
uint8_t *  buffer,
size_t  bufferLength 
)

Append a component with 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 there is no more room in the components array or if bufferLength is too small.
static NameLite& ndn::NameLite::downCast ( ndn_Name name)
inlinestatic

Downcast the reference to the ndn_Name struct to a NameLite.

Parameters
nameA reference to the ndn_Name struct.
Returns
The same reference as NameLite.
bool ndn::NameLite::equals ( const NameLite name)

Check if this name has the same component count and components as the given name.

Parameters
nameThe Name to check.
Returns
true if this matches the given name, otherwise false. This always returns true if this name is empty.
const Component& ndn::NameLite::get ( int  i) const
inline

Get the component at the given index.

This does not check if i is out of bounds.

Parameters
iThe index of the component, starting from 0. However, if i is negative, return the component at size() - (-i).
Returns
The name component at the index.
bool ndn::NameLite::match ( const NameLite name) const

Check if the N components of this name are the same as the first N components of the given name.

Parameters
nameThe Name to check.
Returns
true if this matches the given name, otherwise false. This always returns true if this name is empty.
const NameLite::Component * ndn::NameLite::pop ( )

Remove and return the last name component.

Returns
A pointer to the last name component that was removed. If size() is already zero then return a null pointer.
ndn_Error ndn::NameLite::set ( const NameLite other)

Set this name to have the values from the other name.

Parameters
otherThe other NameLite to get values from.
Returns
0 for success, or an error code if there is not enough room in this object's components array.
size_t ndn::NameLite::size ( ) const
inline

Get the number of components.

Returns
The number of components.

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