Class Variable

Class Documentation

class URI::Template::Variable

URI-template variable definition.

This class represent a variable defined in the template. After the operator (if any), each expression in the template contains a list of one or more comma-separated variable specifiers which are handled as instances of this class.

Public Functions

Variable(std::string &&name, std::shared_ptr<Modifier> &&modifier, unsigned length)

Parametrized constructor.

Creates a variable with known name and modifiers.

Parameters
Variable(const Variable&) = default

Copy constructor.

Variable &operator=(const Variable&) = default

Copy assignment.

Variable(Variable&&) noexcept = default

Move constructor.

Variable &operator=(Variable&&) noexcept = default

Move assignment.

~Variable() = default

Destructor.

bool IsPrefixed() const

Check if the variable has ModifierType::LENGTH modifier.

bool IsExploded() const

Check if the variable has ModifierType::EXPLODE modifier.

const std::string &Name() const

Get the variable name.

const Modifier &Mod() const

Get the variable modifier.

unsigned Length() const

Get the variable prefix length.

bool operator==(const Variable &rhs) const

Compares two variables.

bool operator!=(const Variable &rhs) const

Compares two variables.

Public Static Attributes

static const std::unordered_set<char> kNameChars

Collection of allowed characters for variable name: ALPHA / DIGIT / “_” / pct-encoded / “.”.

static const std::unordered_set<char> kValueChars

Collection of unreserved characters allowed for variable value: ALPHA / DIGIT / “-” / “.” / “_” / “~”/ “%” / “,”.

static const std::unordered_set<char> kReservedChars

Collection of reserved characters allowed for variable value: “:” / “/” / “?” / “#” / “[” / “]” / “@” / “!” / “$” / “&” / “’” / “(” / “)” / “*” / “+” / “,” / “;” / “=”.