35 return std::string_view(
reinterpret_cast<const char*
>(
value),
size);
112 size_t toUri(
char* buf,
size_t bufSize)
const;
122 Error encode(uint8_t* buf,
size_t bufSize,
size_t& encodedLen)
const;
210 uint32_t
hash()
const;
220 bool empty()
const {
return numComponents_ == 0; }
226 const uint8_t*
wireValue()
const {
return buffer_.data(); }
236 std::array<uint8_t, NAME_MAX_LENGTH> buffer_{};
242 struct ComponentOffset {
246 std::array<ComponentOffset, NAME_MAX_COMPONENTS> components_{};
247 uint8_t numComponents_ = 0;
255 Error appendComponentInternal(
const uint8_t* value,
size_t len);
Error encode(uint8_t *buf, size_t bufSize, size_t &encodedLen) const
Encode the Name to TLV wire format.
size_t wireLength() const
Get the length of the internal buffer.
static Result< Name > fromWire(const uint8_t *buf, size_t len, size_t *bytesRead=nullptr)
Decode a Name from TLV wire format.
bool empty() const
Check if the Name is empty.
uint32_t hash() const
Compute hash value of the Name.
Error appendComponent(std::string_view comp)
Append a string component.
size_t toUri(char *buf, size_t bufSize) const
Convert the Name to a URI string.
int compare(const Name &other) const
Compare with another Name.
Name()=default
Default constructor.
size_t componentCount() const
Get the number of components.
NameComponent component(size_t index) const
Get the component at a given index.
bool equals(const Name &other) const
Check equality with another Name.
bool isPrefixOf(const Name &other) const
Check if this Name is a prefix of another Name.
static Result< Name > fromUri(std::string_view uri)
Create a Name from a URI string.
const uint8_t * wireValue() const
Get pointer to the internal buffer.
Common definitions for the NDN protocol stack.
bool operator<(const Name &lhs, const Name &rhs)
Less-than operator.
bool operator==(const Name &lhs, const Name &rhs)
Equality operator.
bool operator!=(const Name &lhs, const Name &rhs)
Inequality operator.
std::string_view asString() const
Get the component as a string view.
const uint8_t * value
Pointer to the component value.
size_t size
Size of the component in bytes.