24 #include <ndn-cpp/c/name-types.h>
25 #include <ndn-cpp/c/errors.h>
26 #include "util/blob.h"
38 static __inline
void ndn_NameComponent_initialize(
struct ndn_NameComponent *
self,
const uint8_t *value,
size_t valueLength)
40 ndn_Blob_initialize(&self->value, value, valueLength);
53 return self->value.length >= 1 &&
self->value.value[0] == 0x00 ? 1 : 0;
66 return self->value.length >= 1 &&
self->value.value[0] == 0xFB ? 1 : 0;
79 return self->value.length >= 1 &&
self->value.value[0] == 0xFD ? 1 : 0;
92 return self->value.length >= 1 &&
self->value.value[0] == 0xFC ? 1 : 0;
105 return self->value.length >= 1 &&
self->value.value[0] == 0xFE ? 1 : 0;
122 ndn_Error ndn_NameComponent_toNumberWithMarker
134 static __inline ndn_Error
135 ndn_NameComponent_toSegment
138 return ndn_NameComponent_toNumberWithMarker(
self, 0x00, result);
150 static __inline ndn_Error
151 ndn_NameComponent_toSegmentOffset
154 return ndn_NameComponent_toNumberWithMarker(
self, 0xFB, result);
168 static __inline ndn_Error
169 ndn_NameComponent_toVersion
172 return ndn_NameComponent_toNumberWithMarker(
self, 0xFD, result);
185 static __inline ndn_Error
186 ndn_NameComponent_toTimestamp
189 return ndn_NameComponent_toNumberWithMarker(
self, 0xFC, result);
201 static __inline ndn_Error
202 ndn_NameComponent_toSequenceNumber
205 return ndn_NameComponent_toNumberWithMarker(
self, 0xFE, result);
216 ndn_Error ndn_NameComponent_toNumberWithPrefix
218 size_t prefixLength, uint64_t *result);
228 ndn_NameComponent_hasPrefix
230 size_t prefixLength);
240 int ndn_NameComponent_compare
249 ndn_NameComponent_setFromNameComponent
268 ndn_NameComponent_setFromNumber
270 size_t bufferLength);
286 ndn_NameComponent_setFromNumberWithMarker
288 uint8_t *buffer,
size_t bufferLength);
303 static __inline ndn_Error
304 ndn_NameComponent_setSegment
308 return ndn_NameComponent_setFromNumberWithMarker
309 (
self, segment, 0x00, buffer, bufferLength);
325 static __inline ndn_Error
326 ndn_NameComponent_setSegmentOffset
330 return ndn_NameComponent_setFromNumberWithMarker
331 (
self, segmentOffset, 0xFB, buffer, bufferLength);
348 static __inline ndn_Error
349 ndn_NameComponent_setVersion
353 return ndn_NameComponent_setFromNumberWithMarker
354 (
self, version, 0xFD, buffer, bufferLength);
371 static __inline ndn_Error
372 ndn_NameComponent_setTimestamp
376 return ndn_NameComponent_setFromNumberWithMarker
377 (
self, timestamp, 0xFC, buffer, bufferLength);
393 static __inline ndn_Error
394 ndn_NameComponent_setSequenceNumber
398 return ndn_NameComponent_setFromNumberWithMarker
399 (
self, sequenceNumber, 0xFE, buffer, bufferLength);
408 static __inline
void ndn_Name_initialize(
struct ndn_Name *
self,
struct ndn_NameComponent *components,
size_t maxComponents)
410 self->components = components;
411 self->maxComponents = maxComponents;
412 self->nComponents = 0;
420 ndn_Name_clear(
struct ndn_Name *
self) {
self->nComponents = 0; }
430 int ndn_Name_equals(
const struct ndn_Name *
self,
const struct ndn_Name *name);
438 int ndn_Name_match(
const struct ndn_Name *
self,
const struct ndn_Name *name);
447 ndn_Error ndn_Name_appendComponent(
struct ndn_Name *
self,
const uint8_t* value,
size_t valueLength);
455 static __inline ndn_Error ndn_Name_appendBlob(
struct ndn_Name *
self,
struct ndn_Blob *value)
457 return ndn_Name_appendComponent(
self, value->
value, value->
length);
466 ndn_Error ndn_Name_appendString(
struct ndn_Name *
self,
const char * value);
size_t length
the number of bytes in value.
Definition: blob-types.h:35
Copyright (C) 2015-2016 Regents of the University of California.
Definition: name-types.h:33
An ndn_Name holds an array of ndn_NameComponent.
Definition: name-types.h:40
const uint8_t * value
pointer to the pre-allocated buffer for the value.
Definition: blob-types.h:34
Copyright (C) 2015-2016 Regents of the University of California.
Definition: blob-types.h:33