A NameLite holds an array of NameLite::Component. More...
#include <name-lite.hpp>
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 Component & | get (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 NameLite & | downCast (ndn_Name &name) |
Downcast the reference to the ndn_Name struct to a NameLite. More... | |
static const NameLite & | downCast (const ndn_Name &name) |
Friends | |
class | Tlv0_1_1WireFormatLite |
A NameLite holds an array of NameLite::Component.
ndn::NameLite::NameLite | ( | ndn_NameComponent * | components, |
size_t | maxComponents | ||
) |
Create a NameLite to use the components array.
components | the 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. |
maxComponents | the number of elements in the allocated components array. |
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.
value | A pointer to the buffer with the bytes of the component. This does not copy the bytes. |
valueLength | The number of bytes in value. |
|
inline |
Append a component to this name with the bytes in the given blob.
value | A BlobLite with the bytes of the component. This does not copy the bytes. |
|
inline |
Append a component to this name with the bytes in the given component.
component | A Component with the bytes of the component. This does not copy the bytes. |
ndn_Error ndn::NameLite::append | ( | const char * | value | ) |
Append a component to this name with the bytes in raw string value.
value | The null-terminated string, treated as a byte array. This does not copy the bytes. |
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
segment | The segment number. |
buffer | The 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. |
bufferLength | The number of bytes in the allocated buffer. This should be at least 9 bytes to hold a marker plus a 64-bit value. |
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
segmentOffset | The segment byte offset. |
buffer | The 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. |
bufferLength | The number of bytes in the allocated buffer. This should be at least 9 bytes to hold a marker plus a 64-bit value. |
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
sequenceNumber | The sequence number. |
buffer | The 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. |
bufferLength | The number of bytes in the allocated buffer. This should be at least 9 bytes to hold a marker plus a 64-bit value. |
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
timestamp | The number of microseconds since the UNIX epoch (Thursday, 1 January 1970) not counting leap seconds. |
buffer | The 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. |
bufferLength | The number of bytes in the allocated buffer. This should be at least 9 bytes to hold a marker plus a 64-bit value. |
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.
version | The version number. |
buffer | The 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. |
bufferLength | The number of bytes in the allocated buffer. This should be at least 9 bytes to hold a marker plus a 64-bit value. |
bool ndn::NameLite::equals | ( | const NameLite & | name | ) |
Check if this name has the same component count and components as the given name.
name | The Name to check. |
|
inline |
Get the component at the given index.
This does not check if i is out of bounds.
i | The index of the component, starting from 0. However, if i is negative, return the component at size() - (-i). |
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.
name | The Name to check. |
ndn_Error ndn::NameLite::set | ( | const NameLite & | other | ) |
Set this name to have the values from the other name.
other | The other NameLite to get values from. |
|
inline |
Get the number of components.