Component holds a read-only name component value. More...
#include <name-component.hpp>
Classes | |
class | Error |
Error that can be thrown from name::Component. More... | |
Public Types | |
using | element_const_iterator = element_container::const_iterator |
using | element_container = std::vector< Block > |
using | element_iterator = element_container::iterator |
Public Member Functions | |
Component () | |
Create a new name::Component with an empty value. More... | |
Component (const Block &wire) | |
Create name::Component from a wire block. More... | |
Component (const ConstBufferPtr &buffer) | |
Create a new name::Component from the buffer pointer (buffer pointer will be copied) More... | |
Component (const Buffer &buffer) | |
Create a new name::Component from the buffer (data from buffer will be copied) More... | |
Component (const uint8_t *buffer, size_t bufferSize) | |
Create a new name::Component from the buffer (data from buffer will be copied) More... | |
template<class Iterator > | |
Component (Iterator first, Iterator last) | |
Create a new name::Component frome the range [first , last ) of bytes. More... | |
Component (const char *str) | |
Create a new name::Component from the C string (data from string will be copied) More... | |
Component (const std::string &str) | |
Create a new name::Component from the STL string (data from string will be copied) More... | |
Buffer::const_iterator | begin () const |
Get begin iterator of encoded wire. More... | |
Block | blockFromValue () const |
int | compare (const Component &other) const |
Compare this to the other Component using NDN canonical ordering. More... | |
const element_container & | elements () const |
Get container of sub elements. More... | |
element_const_iterator | elements_begin () const |
Equivalent to elements().begin() More... | |
element_const_iterator | elements_end () const |
Equivalent to elements().end() More... | |
size_t | elements_size () const |
Equivalent to elements().size() More... | |
bool | empty () const |
void | encode () |
Encode sub elements into TLV-VALUE. More... | |
Buffer::const_iterator | end () const |
Get end iterator of encoded wire. More... | |
bool | equals (const Component &other) const |
Check if this is the same component as other. More... | |
element_iterator | erase (element_const_iterator position) |
Erase a sub element. More... | |
element_iterator | erase (element_const_iterator first, element_const_iterator last) |
Erase a range of sub elements. More... | |
element_const_iterator | find (uint32_t type) const |
Find the first sub element of specified TLV-TYPE. More... | |
const Block & | get (uint32_t type) const |
Get the first sub element of specified TLV-TYPE. More... | |
shared_ptr< const Buffer > | getBuffer () const |
Get underlying buffer. More... | |
Component | getSuccessor () const |
bool | hasValue () const |
Get begin iterator of TLV-VALUE. More... | |
bool | hasWire () const |
Check if the Block has fully encoded wire. More... | |
element_iterator | insert (element_const_iterator pos, const Block &element) |
Insert a sub element. More... | |
bool | isGeneric () const |
Check if the component is GenericComponent. More... | |
bool | isImplicitSha256Digest () const |
Check if the component is ImplicitSha256DigestComponent. More... | |
bool | isNumber () const |
Check if the component is nonNegativeInteger. More... | |
bool | isNumberWithMarker (uint8_t marker) const |
Check if the component is NameComponentWithMarker per NDN naming conventions. More... | |
bool | isSegment () const |
Check if the component is segment number per NDN naming conventions. More... | |
bool | isSegmentOffset () const |
Check if the component is segment offset per NDN naming conventions. More... | |
bool | isSequenceNumber () const |
Check if the component is sequence number per NDN naming conventions. More... | |
bool | isTimestamp () const |
Check if the component is timestamp per NDN naming conventions. More... | |
bool | isVersion () const |
Check if the component is version per NDN naming conventions. More... | |
operator boost::asio::const_buffer () const | |
Implicit conversion to const_buffer. More... | |
bool | operator!= (const Component &other) const |
Check if this is not the same component as other. More... | |
bool | operator< (const Component &other) const |
Check if the *this is less than the other in NDN canonical ordering. More... | |
bool | operator<= (const Component &other) const |
Check if the *this is less than or equal to the other in NDN canonical ordering. More... | |
bool | operator== (const Component &other) const |
Check if this is the same component as other. More... | |
bool | operator> (const Component &other) const |
Check if the *this is greater than the other in NDN canonical ordering. More... | |
bool | operator>= (const Component &other) const |
Check if the *this is greater or equal than the other in NDN canonical ordering. More... | |
void | parse () const |
Parse TLV-VALUE into sub elements. More... | |
void | push_back (const Block &element) |
Append a sub element. More... | |
void | remove (uint32_t type) |
Remove all sub elements of specified TLV-TYPE. More... | |
void | reset () |
Reset wire buffer of the element. More... | |
void | resetWire () |
Reset wire buffer but keep TLV-TYPE and sub elements (if any) More... | |
size_t | size () const |
Get size of encoded wire, including Type-Length-Value. More... | |
uint64_t | toNumber () const |
Interpret this name component as nonNegativeInteger. More... | |
uint64_t | toNumberWithMarker (uint8_t marker) const |
Interpret this name component as NameComponentWithMarker. More... | |
uint64_t | toSegment () const |
Interpret as segment number component using NDN naming conventions. More... | |
uint64_t | toSegmentOffset () const |
Interpret as segment offset component using NDN naming conventions. More... | |
uint64_t | toSequenceNumber () const |
Interpret as sequence number component using NDN naming conventions. More... | |
time::system_clock::TimePoint | toTimestamp () const |
Interpret as timestamp component using NDN naming conventions. More... | |
void | toUri (std::ostream &os) const |
Write *this to the output stream, escaping characters according to the NDN URI Scheme. More... | |
std::string | toUri () const |
Convert *this by escaping characters according to the NDN URI Scheme. More... | |
uint64_t | toVersion () const |
Interpret as version component using NDN naming conventions. More... | |
uint32_t | type () const |
Get TLV-TYPE. More... | |
const uint8_t * | value () const |
Get pointer to TLV-VALUE. More... | |
Buffer::const_iterator | value_begin () const |
Get begin iterator of TLV-VALUE. More... | |
Buffer::const_iterator | value_end () const |
Get end iterator of TLV-VALUE. More... | |
size_t | value_size () const |
Get size of TLV-VALUE aka TLV-LENGTH. More... | |
const uint8_t * | wire () const |
Get pointer to encoded wire. More... | |
void | wireDecode (const Block &wire) |
Decode from the wire format. More... | |
template<encoding::Tag TAG> | |
size_t | wireEncode (EncodingImpl< TAG > &encoder) const |
Fast encoding or block size estimation. More... | |
const Block & | wireEncode () const |
Encode to a wire format. More... | |
Static Public Member Functions | |
static std::tuple< bool, Block > | fromBuffer (ConstBufferPtr buffer, size_t offset) |
Try to parse Block from a wire buffer. More... | |
static std::tuple< bool, Block > | fromBuffer (const uint8_t *buf, size_t bufSize) |
Try to parse Block from a raw buffer. More... | |
static Component | fromEscapedString (const char *escapedString, size_t beginOffset, size_t endOffset) |
Create name::Component by decoding the escapedString between beginOffset and endOffset according to the NDN URI Scheme. More... | |
static Component | fromEscapedString (const char *escapedString) |
Create name::Component by decoding the escapedString according to the NDN URI Scheme. More... | |
static Component | fromEscapedString (const std::string &escapedString) |
Create name::Component by decoding the escapedString according to the NDN URI Scheme. More... | |
static Component | fromImplicitSha256Digest (const ConstBufferPtr &digest) |
Create ImplicitSha256DigestComponent component. More... | |
static Component | fromImplicitSha256Digest (const uint8_t *digest, size_t digestSize) |
Create ImplicitSha256DigestComponent component. More... | |
static Component | fromNumber (uint64_t number) |
Create a component encoded as nonNegativeInteger. More... | |
static Component | fromNumberWithMarker (uint8_t marker, uint64_t number) |
Create a component encoded as NameComponentWithMarker. More... | |
static Component | fromSegment (uint64_t segmentNo) |
Create segment number component using NDN naming conventions. More... | |
static Component | fromSegmentOffset (uint64_t offset) |
Create segment offset component using NDN naming conventions. More... | |
static Component | fromSequenceNumber (uint64_t seqNo) |
Create sequence number component using NDN naming conventions. More... | |
static Block | fromStream (std::istream &is) |
Parse Block from an input stream. More... | |
static Component | fromTimestamp (const time::system_clock::TimePoint &timePoint) |
Create sequence number component using NDN naming conventions. More... | |
static Component | fromVersion (uint64_t version) |
Create version component using NDN naming conventions. More... | |
Protected Attributes | |
Buffer::const_iterator | m_begin |
shared_ptr< const Buffer > | m_buffer |
underlying buffer storing TLV-VALUE and possibly TLV-TYPE and TLV-LENGTH fields More... | |
element_container | m_elements |
sub elements More... | |
Buffer::const_iterator | m_end |
uint32_t | m_size |
total size including Type-Length-Value More... | |
uint32_t | m_type |
TLV-TYPE. More... | |
Buffer::const_iterator | m_valueBegin |
Buffer::const_iterator | m_valueEnd |
Component holds a read-only name component value.
Definition at line 47 of file name-component.hpp.
|
inherited |
|
inherited |
|
inherited |
ndn::name::Component::Component | ( | ) |
Create a new name::Component with an empty value.
Definition at line 53 of file name-component.cpp.
ndn::name::Component::Component | ( | const Block & | wire | ) |
Create name::Component from a wire block.
wire | tlv::NameComponent Block from which to create name::Component |
Error | if wire.type() is not tlv::NameComponent |
Any block can be implicitly converted to name::Component
Definition at line 58 of file name-component.cpp.
|
explicit |
Create a new name::Component from the buffer pointer (buffer pointer will be copied)
buffer | A pointer to an immutable buffer |
This constructor will create a new tlv::NameComponent Block with buffer
as a payload. Note that this method will not allocate new memory for and copy the payload until toWire() method is called.
Definition at line 66 of file name-component.cpp.
|
explicit |
Create a new name::Component from the buffer (data from buffer will be copied)
buffer | A reference to the buffer |
This constructor will create a new tlv::NameComponent Block with buffer
as a payload. Note that this method will allocate new memory for and copy the payload.
Definition at line 71 of file name-component.cpp.
ndn::name::Component::Component | ( | const uint8_t * | buffer, |
size_t | bufferSize | ||
) |
Create a new name::Component from the buffer (data from buffer will be copied)
buffer | A pointer to the first byte of the buffer |
bufferSize | Size of the buffer |
This constructor will create a new tlv::NameComponent Block with buffer
as a payload. Note that this method will allocate new memory for and copy the payload.
Definition at line 76 of file name-component.cpp.
|
inline |
Create a new name::Component frome the range [first
, last
) of bytes.
first | Iterator pointing to the beginning of the buffer |
last | Iterator pointing to the ending of the buffer |
Iterator | iterator type satisfying at least InputIterator concept. Implementation is more optimal when the iterator type satisfies RandomAccessIterator concept. It is required that sizeof(std::iterator_traits<Iterator>::value_type) == 1. |
This constructor will create a new tlv::NameComponent Block with buffer
as a payload. Note that this method will allocate new memory for and copy the payload.
Definition at line 581 of file name-component.hpp.
|
explicit |
Create a new name::Component from the C string (data from string will be copied)
str | Zero-ended string. Note that this string will be interpreted as is (i.e., it will not be interpreted as URI) |
This constructor will create a new tlv::NameComponent Block with buffer
as a payload. Note that this method will allocate new memory for and copy the payload.
Definition at line 81 of file name-component.cpp.
|
explicit |
Create a new name::Component from the STL string (data from string will be copied)
str | Const reference to STL string. Note that this string will be interpreted as is (i.e., it will not be interpreted as URI) |
This constructor will create a new tlv::NameComponent Block with buffer
as a payload. Note that this method will allocate new memory for and copy the payload.
Definition at line 86 of file name-component.cpp.
|
inherited |
int ndn::name::Component::compare | ( | const Component & | other | ) | const |
Compare this to the other Component using NDN canonical ordering.
other | The other Component to compare with. |
negative | this comes before other in canonical ordering |
zero | this equals other |
positive | this comes after other in canonical ordering |
Definition at line 395 of file name-component.cpp.
|
inlineinherited |
|
inlineinherited |
Equivalent to elements().begin()
|
inlineinherited |
Equivalent to elements().end()
|
inlineinherited |
Equivalent to elements().size()
|
inline |
Definition at line 463 of file name-component.hpp.
|
inherited |
Encode sub elements into TLV-VALUE.
|
inherited |
bool ndn::name::Component::equals | ( | const Component & | other | ) | const |
Check if this is the same component as other.
other | The other Component to compare with |
Definition at line 386 of file name-component.cpp.
|
inherited |
|
inherited |
|
inherited |
Find the first sub element of specified TLV-TYPE.
|
staticinherited |
|
staticinherited |
Try to parse Block from a raw buffer.
buf | pointer to the first octet of an TLV element |
bufSize | size of the raw buffer; may be more than size of the TLV element |
|
static |
Create name::Component by decoding the escapedString between beginOffset and endOffset according to the NDN URI Scheme.
If the escaped string is "", "." or ".." then return an empty name::Component. Note that an empty name::Component should not be added to Name and if attempted, an exception will be thrown.
escapedString | String containing NDN URI-encoded name component. [escapedString+beginOffset, beginOffset+endOffset) must be a valid memory buffer. |
beginOffset | The offset in escapedString of the beginning of the portion to decode. |
endOffset | The offset in escapedString of the end of the portion to decode. |
Definition at line 92 of file name-component.cpp.
|
inlinestatic |
Create name::Component by decoding the escapedString according to the NDN URI Scheme.
This overload is a convenience wrapper for fromEscapedString(char*,size_t,size)
Definition at line 190 of file name-component.hpp.
|
inlinestatic |
Create name::Component by decoding the escapedString according to the NDN URI Scheme.
This overload is a convenience wrapper for fromEscapedString(char*,size_t,size)
Definition at line 201 of file name-component.hpp.
|
static |
Create ImplicitSha256DigestComponent component.
Definition at line 364 of file name-component.cpp.
|
static |
Create ImplicitSha256DigestComponent component.
Definition at line 374 of file name-component.cpp.
|
static |
Create a component encoded as nonNegativeInteger.
number | The non-negative number |
Definition at line 291 of file name-component.cpp.
|
static |
Create a component encoded as NameComponentWithMarker.
NameComponentWithMarker is defined as:
NameComponentWithMarker ::= NAME-COMPONENT-TYPE TLV-LEGTH Marker includedNonNegativeInteger Marker ::= BYTE includedNonNegativeInteger ::= BYTE{1,2,4,8} NDN-TLV := TLV-TYPE TLV-LENGTH TLV-VALUE? TLV-TYPE := VAR-NUMBER TLV-LENGTH := VAR-NUMBER TLV-VALUE := BYTE+
marker | 1-byte marker octet |
number | The non-negative number |
Definition at line 297 of file name-component.cpp.
|
static |
Create segment number component using NDN naming conventions.
Definition at line 323 of file name-component.cpp.
|
static |
Create segment offset component using NDN naming conventions.
Definition at line 329 of file name-component.cpp.
|
static |
Create sequence number component using NDN naming conventions.
Definition at line 343 of file name-component.cpp.
|
staticinherited |
Parse Block from an input stream.
tlv::Error | TLV-LENGTH is zero or exceeds upper bound |
|
static |
Create sequence number component using NDN naming conventions.
Definition at line 335 of file name-component.cpp.
|
static |
Create version component using NDN naming conventions.
Definition at line 317 of file name-component.cpp.
|
inherited |
|
inlineinherited |
Component ndn::name::Component::getSuccessor | ( | ) | const |
Definition at line 420 of file name-component.cpp.
|
inlineinherited |
|
inherited |
|
inherited |
Insert a sub element.
pos | position of new sub element |
element | new sub element |
bool ndn::name::Component::isGeneric | ( | ) | const |
Check if the component is GenericComponent.
Definition at line 351 of file name-component.cpp.
bool ndn::name::Component::isImplicitSha256Digest | ( | ) | const |
Check if the component is ImplicitSha256DigestComponent.
Definition at line 357 of file name-component.cpp.
bool ndn::name::Component::isNumber | ( | ) | const |
Check if the component is nonNegativeInteger.
Definition at line 191 of file name-component.cpp.
bool ndn::name::Component::isNumberWithMarker | ( | uint8_t | marker | ) | const |
Check if the component is NameComponentWithMarker per NDN naming conventions.
Definition at line 198 of file name-component.cpp.
bool ndn::name::Component::isSegment | ( | ) | const |
Check if the component is segment number per NDN naming conventions.
Definition at line 212 of file name-component.cpp.
bool ndn::name::Component::isSegmentOffset | ( | ) | const |
Check if the component is segment offset per NDN naming conventions.
Definition at line 218 of file name-component.cpp.
bool ndn::name::Component::isSequenceNumber | ( | ) | const |
Check if the component is sequence number per NDN naming conventions.
Definition at line 230 of file name-component.cpp.
bool ndn::name::Component::isTimestamp | ( | ) | const |
Check if the component is timestamp per NDN naming conventions.
Definition at line 224 of file name-component.cpp.
bool ndn::name::Component::isVersion | ( | ) | const |
Check if the component is version per NDN naming conventions.
Definition at line 206 of file name-component.cpp.
|
inherited |
|
inline |
Check if this is not the same component as other.
other | The other Component to compare with |
Definition at line 508 of file name-component.hpp.
|
inline |
Check if the *this is less than the other in NDN canonical ordering.
other | The other Component to compare with |
Definition at line 532 of file name-component.hpp.
|
inline |
Check if the *this is less than or equal to the other in NDN canonical ordering.
other | The other Component to compare with |
Definition at line 520 of file name-component.hpp.
|
inline |
Check if this is the same component as other.
other | The other Component to compare with. |
Definition at line 497 of file name-component.hpp.
|
inline |
Check if the *this is greater than the other in NDN canonical ordering.
other | The other Component to compare with |
Definition at line 556 of file name-component.hpp.
|
inline |
Check if the *this is greater or equal than the other in NDN canonical ordering.
other | The other Component to compare with |
Definition at line 544 of file name-component.hpp.
|
inherited |
Parse TLV-VALUE into sub elements.
tlv::Error | TLV-VALUE is not a sequence of TLV elements |
|
inherited |
|
inherited |
Remove all sub elements of specified TLV-TYPE.
|
inherited |
|
inherited |
Reset wire buffer but keep TLV-TYPE and sub elements (if any)
|
inherited |
uint64_t ndn::name::Component::toNumber | ( | ) | const |
Interpret this name component as nonNegativeInteger.
Definition at line 238 of file name-component.cpp.
uint64_t ndn::name::Component::toNumberWithMarker | ( | uint8_t | marker | ) | const |
Interpret this name component as NameComponentWithMarker.
marker | 1-byte octet of the marker |
Error | if name component does not have the specified marker. tlv::Error if format does not follow NameComponentWithMarker specification. |
Definition at line 247 of file name-component.cpp.
uint64_t ndn::name::Component::toSegment | ( | ) | const |
Interpret as segment number component using NDN naming conventions.
Error | if name component does not have the specified marker. tlv::Error if format does not follow NameComponentWithMarker specification. |
Definition at line 264 of file name-component.cpp.
uint64_t ndn::name::Component::toSegmentOffset | ( | ) | const |
Interpret as segment offset component using NDN naming conventions.
Error | if name component does not have the specified marker. tlv::Error if format does not follow NameComponentWithMarker specification. |
Definition at line 270 of file name-component.cpp.
uint64_t ndn::name::Component::toSequenceNumber | ( | ) | const |
Interpret as sequence number component using NDN naming conventions.
Error | if name component does not have the specified marker. tlv::Error if format does not follow NameComponentWithMarker specification. |
Definition at line 283 of file name-component.cpp.
time::system_clock::TimePoint ndn::name::Component::toTimestamp | ( | ) | const |
Interpret as timestamp component using NDN naming conventions.
Error | if name component does not have the specified marker. tlv::Error if format does not follow NameComponentWithMarker specification. |
Definition at line 276 of file name-component.cpp.
void ndn::name::Component::toUri | ( | std::ostream & | os | ) | const |
Write *this to the output stream, escaping characters according to the NDN URI Scheme.
This also adds "..." to a value with zero or more "."
os | The output stream to where write the URI escaped version *this |
Definition at line 131 of file name-component.cpp.
std::string ndn::name::Component::toUri | ( | ) | const |
Convert *this by escaping characters according to the NDN URI Scheme.
This also adds "..." to a value with zero or more "."
Definition at line 181 of file name-component.cpp.
uint64_t ndn::name::Component::toVersion | ( | ) | const |
Interpret as version component using NDN naming conventions.
Error | if name component does not have the specified marker. tlv::Error if format does not follow NameComponentWithMarker specification. |
Definition at line 258 of file name-component.cpp.
|
inlineinherited |
|
inherited |
|
inlineinherited |
Get begin iterator of TLV-VALUE.
|
inlineinherited |
Get end iterator of TLV-VALUE.
|
inherited |
|
inherited |
void ndn::name::Component::wireDecode | ( | const Block & | wire | ) |
Decode from the wire format.
Definition at line 478 of file name-component.cpp.
size_t ndn::name::Component::wireEncode | ( | EncodingImpl< TAG > & | encoder | ) | const |
Fast encoding or block size estimation.
Definition at line 449 of file name-component.cpp.
const Block & ndn::name::Component::wireEncode | ( | ) | const |
Encode to a wire format.
Definition at line 462 of file name-component.cpp.
|
protectedinherited |
|
protectedinherited |
underlying buffer storing TLV-VALUE and possibly TLV-TYPE and TLV-LENGTH fields
If m_buffer is nullptr, this is an empty Block with TLV-TYPE given in m_type. Otherwise,
|
mutableprotectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |