22 #ifndef NDN_CXX_NAME_COMPONENT_HPP
23 #define NDN_CXX_NAME_COMPONENT_HPP
193 template<
class Iterator>
202 template<
class Iterator>
228 template<encoding::Tag TAG>
#define NDN_CXX_NODISCARD
Represents a TLV element of the NDN packet format.
const uint8_t * wire() const
Return a raw pointer to the beginning of the encoded wire.
uint32_t type() const
Return the TLV-TYPE of the Block.
size_t value_size() const noexcept
Return the size of TLV-VALUE, aka TLV-LENGTH.
const uint8_t * value() const noexcept
Return a raw pointer to the beginning of TLV-VALUE.
Represents a name component.
uint64_t toSegment() const
Interpret as segment number component using NDN naming conventions.
Component(ConstBufferPtr buffer)
Construct a GenericNameComponent, using TLV-VALUE from buffer.
static Component fromSegment(uint64_t segmentNo)
Create a segment number component using NDN naming conventions.
Component(uint32_t type, const uint8_t *value, size_t count)
Construct a NameComponent of TLV-TYPE type, copying count bytes at value as TLV-VALUE.
const Block & wireEncode() const
Encode to a wire format.
Component getSuccessor() const
Get the successor of this name component.
bool isGeneric() const
Check if the component is GenericNameComponent.
static Component fromEscapedString(const char *input, size_t beginOffset, size_t endOffset)
Decode NameComponent from a URI component.
Component(const uint8_t *value, size_t count)
Construct a GenericNameComponent, copying count bytes at value as TLV-VALUE.
static Component fromNumber(uint64_t number, uint32_t type=tlv::GenericNameComponent)
Create a component encoded as NonNegativeInteger.
static Component fromTimestamp(const time::system_clock::time_point &timePoint)
Create a timestamp component using NDN naming conventions.
bool isByteOffset() const
Check if the component is a byte offset per NDN naming conventions.
static Component fromEscapedString(const char *input)
Decode NameComponent from a URI component.
bool isSegment() const
Check if the component is a segment number per NDN naming conventions.
static Component fromParametersSha256Digest(ConstBufferPtr digest)
Create ParametersSha256DigestComponent component.
uint64_t toNumberWithMarker(uint8_t marker) const
Interpret this name component as NameComponentWithMarker.
friend bool operator>(const Component &lhs, const Component &rhs)
friend bool operator>=(const Component &lhs, const Component &rhs)
bool isTimestamp() const
Check if the component is a timestamp per NDN naming conventions.
bool isParametersSha256Digest() const
Check if the component is ParametersSha256DigestComponent.
static Component fromSequenceNumber(uint64_t seqNo)
Create a sequence number component using NDN naming conventions.
uint64_t toByteOffset() const
Interpret as byte offset component using NDN naming conventions.
static Component fromVersion(uint64_t version)
Create a version component using NDN naming conventions.
uint64_t toSequenceNumber() const
Interpret as sequence number component using NDN naming conventions.
bool isSequenceNumber() const
Check if the component is a sequence number per NDN naming conventions.
Component(Iterator first, Iterator last)
Construct a GenericNameComponent, copying TLV-VALUE from a range.
Component(uint32_t type=tlv::GenericNameComponent)
Construct a NameComponent of TLV-TYPE type and with empty TLV-VALUE.
friend std::ostream & operator<<(std::ostream &os, const Component &component)
Component(span< const uint8_t > buffer)
Construct a GenericNameComponent, copying TLV-VALUE from buffer.
static Component fromByteOffset(uint64_t offset)
Create a byte offset component using NDN naming conventions.
bool isVersion() const
Check if the component is a version per NDN naming conventions.
bool isNumberWithMarker(uint8_t marker) const
Check if the component is a NameComponentWithMarker per NDN naming conventions rev1.
friend bool operator<(const Component &lhs, const Component &rhs)
bool isNumber() const
Check if the component is a NonNegativeInteger.
static Component fromNumberWithMarker(uint8_t marker, uint64_t number)
Create a component encoded as NameComponentWithMarker.
void toUri(std::ostream &os, UriFormat format=UriFormat::DEFAULT) const
Write *this to the output stream, escaping characters according to the NDN URI format.
void wireDecode(const Block &wire)
Decode from the wire format.
time::system_clock::time_point toTimestamp() const
Interpret as timestamp component using NDN naming conventions.
friend bool operator!=(const Component &lhs, const Component &rhs)
static Component fromImplicitSha256Digest(ConstBufferPtr digest)
Create ImplicitSha256DigestComponent component.
bool equals(const Component &other) const
Check if this is the same component as other.
friend bool operator<=(const Component &lhs, const Component &rhs)
Component(uint32_t type, Iterator first, Iterator last)
Construct a NameComponent of TLV-TYPE type, copying TLV-VALUE from a range.
int compare(const Component &other) const
Compare this to the other Component using NDN canonical ordering.
uint64_t toNumber() const
Interpret this name component as NonNegativeInteger.
bool isImplicitSha256Digest() const
Check if the component is ImplicitSha256DigestComponent.
friend bool operator==(const Component &lhs, const Component &rhs)
uint64_t toVersion() const
Interpret as version component using NDN naming conventions.
boost::chrono::time_point< system_clock > time_point
Error(const char *expectedType, uint32_t actualType)
Common includes and macros used throughout the library.
#define NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(ClassName)
Block makeBinaryBlock(uint32_t type, span< const uint8_t > value)
Create a TLV block copying the TLV-VALUE from a byte range.
Convention
Identify a style of NDN Naming Conventions.
@ MARKER
Component markers (revision 1)
@ TYPED
Typed name components (revision 3)
void setConventionDecoding(Convention convention)
Set which Naming Conventions style(s) to accept while decoding.
Convention getConventionEncoding()
Return which Naming Conventions style to use while encoding.
void setConventionEncoding(Convention convention)
Set which Naming Conventions style to use while encoding.
Convention getConventionDecoding()
Return which Naming Conventions style(s) to accept while decoding.
UriFormat
Format used for the URI representation of a name.
@ CANONICAL
Always use <type-number>=<percent-encoded-value> format.
@ DEFAULT
Use the library's default format; currently equivalent to UriFormat::ENV_OR_ALTERNATE.
@ ALTERNATE
Always prefer the alternate format when available.
@ ENV_OR_ALTERNATE
Same as UriFormat::ALTERNATE, unless NDN_NAME_ALT_URI environment variable is set to '0'.
@ ENV_OR_CANONICAL
Same as UriFormat::CANONICAL, unless NDN_NAME_ALT_URI environment variable is set to '1'.
shared_ptr< const Buffer > ConstBufferPtr