10 #ifndef NDN_NAME_COMPONENT_HPP
11 #define NDN_NAME_COMPONENT_HPP
75 template<
class InputIterator>
113 fromEscapedString(
const char* escapedString,
size_t beginOffset,
size_t endOffset);
159 std::ostringstream result;
320 throw Error(
"Constructing name component from non name component TLV wire block");
341 template<
class InputIterator>
364 std::string trimmedString(escapedString + beginOffset, escapedString + endOffset);
368 if (value.find_first_not_of(
".") == std::string::npos) {
370 if (value.size() <= 2)
375 return Component(reinterpret_cast<const uint8_t*>(&value[3]), value.size() - 3);
378 return Component(reinterpret_cast<const uint8_t*>(&value[0]), value.size());
385 const uint8_t* valuePtr =
value();
388 bool gotNonDot =
false;
389 for (
unsigned i = 0; i < valueSize; ++i) {
390 if (valuePtr[i] != 0x2e) {
398 for (
size_t i = 0; i < valueSize; ++i)
403 std::ios::fmtflags saveFlags = result.flags(std::ios::hex | std::ios::uppercase);
405 for (
size_t i = 0; i < valueSize; ++i) {
406 uint8_t x = valuePtr[i];
408 if ((x >= 0x30 && x <= 0x39) || (x >= 0x41 && x <= 0x5a) ||
409 (x >= 0x61 && x <= 0x7a) || x == 0x2b || x == 0x2d ||
410 x == 0x2e || x == 0x5f)
416 result << (
unsigned int)x;
421 result.flags(saveFlags);
475 size_t totalLength = 0;
478 totalLength += block.prependVarNumber (
value_size());
498 const_cast<Component&
>(*this) = buffer.block();
509 throw Error(
"wireDecode name component from non name component TLV wire block");
518 #endif // NDN_NAME_COMPONENT_HPP
static Component fromNumber(uint64_t number)
Create a component encoded as nonNegativeInteger.
bool hasValue() const
Check if the Block has value block (no type and length are encoded)
void toEscapedString(std::ostream &result) const
Write the value to result, escaping characters according to the NDN URI Scheme.
Block nonNegativeIntegerBlock(uint32_t type, uint64_t value)
int compare(const Component &other) const
Compare this to the other Component using NDN canonical ordering.
static Component fromEscapedString(const char *escapedString, size_t beginOffset, size_t endOffset)
Make a Blob value by decoding the escapedString between beginOffset and endOffset according to the ND...
const Block & wireEncode() const
Encode to a wire format.
std::string toUri() const
Buffer::const_iterator end() const
bool operator==(const Component &other) const
Check if this is the same component as other.
std::ostream & operator<<(std::ostream &os, const Component &component)
Class representing wire element of the NDN packet.
bool operator<(const Component &other) const
Return true if this is less than the other Component in the NDN canonical ordering.
uint64_t readNonNegativeInteger(const Block &block)
Buffer::const_iterator value_begin() const
Buffer::const_iterator value_end() const
ptr_lib::shared_ptr< const Buffer > ConstBufferPtr
uint64_t toVersion() const
An alias for toNumber()
static Component fromEscapedString(const char *escapedString)
Make a Blob value by decoding the escapedString according to the NDN URI Scheme.
uint64_t toSegment() const
An alias for toNumber()
static Component fromEscapedString(const std::string &escapedString)
Make a Blob value by decoding the escapedString according to the NDN URI Scheme.
Component()
Create a new Name::Component with a null value.
std::string toEscapedString() const
Convert the value by escaping characters according to the NDN URI Scheme.
bool operator<=(const Component &other) const
Return true if this is less than or equal to the other Component in the NDN canonical ordering...
bool operator!=(const Component &other) const
Check if this is not the same component as other.
std::string unescape(const std::string &str)
Return a copy of str, converting each escaped "%XX" to the char value.
void toUri(std::ostream &result) const
size_t value_size() const
Component holds a read-only name component value.
void wireDecode(const Block &wire)
Decode from the wire format.
const uint8_t * wire() const
bool hasWire() const
Check if the Block has fully encoded wire.
void trim(std::string &str)
Modify str in place to erase whitespace on the left and right.
const uint8_t * value() const
bool equals(const Component &other) const
Check if this is the same component as other.
uint64_t toNumber() const
Interpret this name component as nonNegativeInteger.
Class representing a general-use automatically managed/resized buffer.
bool operator>=(const Component &other) const
Return true if this is less than or equal to the other Component in the NDN canonical ordering...
Error that can be thrown from Block.
Class representing wire element of the NDN packet.
Buffer::const_iterator begin() const
bool operator>(const Component &other) const
Return true if this is greater than the other Component in the NDN canonical ordering.
Error that can be thrown from name::Component.
Error(const std::string &what)