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)
 Append a component to this name with the bytes in the given buffer. More...
 
ndn_Error append (const BlobLite &value)
 Append a component to this name with the bytes in the given blob. More...
 
ndn_Error append (const NameLite::Component &component)
 Append a component to this name with the bytes in the given component. More...
 
ndn_Error append (const char *value)
 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 set (const NameLite &other)
 Set this name to have the values from the other name. 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_1_1WireFormatLite
 

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 
)

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.
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)
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.
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::Component component)
inline

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

Parameters
componentA Component with the bytes of the component. 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 char *  value)

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.
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::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.
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: