qb
2.0.0.0
C++17 Actor Framework
|
Class for parsing, manipulating, and representing URIs. More...
#include <uri.h>
Public Member Functions | |
uri ()=default | |
Default constructor. | |
uri (uri &&rhs) noexcept | |
Move constructor. | |
uri (uri const &rhs) | |
Copy constructor. | |
uri (std::string const &str, int af=AF_INET) | |
Constructor from a string. | |
uri (std::string &&str, int af=AF_INET) noexcept | |
Constructor from a string (move version) | |
uri & | operator= (uri const &rhs) |
Copy assignment operator. | |
uri & | operator= (uri &&rhs) noexcept |
Move assignment operator. | |
uri & | operator= (std::string const &str) |
String assignment operator. | |
uri & | operator= (std::string &&str) noexcept |
String move assignment operator. | |
auto | af () const |
Returns the address family of this URI. | |
const auto & | source () const |
Returns the source string of this URI. | |
auto | scheme () const |
Returns the scheme of this URI. | |
auto | user_info () const |
Returns the user information of this URI. | |
auto | host () const |
Returns the host name or IP address of this URI. | |
auto | port () const |
Returns the port number of this URI. | |
uint16_t | u_port () const |
Returns the port number of this URI as a numeric value. | |
auto | path () const |
Returns the path of this URI. | |
const auto & | encoded_queries () const |
Returns the raw query string of this URI. | |
const auto & | queries () const |
Returns the parsed query parameters of this URI. | |
auto & | queries () |
Returns the parsed query parameters of this URI (non-const version) | |
template<typename T> | |
std::string const & | query (T &&name, std::size_t const index=0, std::string const ¬_found="") const |
Returns the value of a specific query parameter. | |
auto | fragment () const |
Returns the fragment of this URI. |
Static Public Member Functions | |
template<typename _IT> | |
static std::string | decode (_IT begin, _IT end) noexcept |
Decodes a sequence of URI-encoded characters. | |
template<typename _IT> | |
static std::string | encode (_IT begin, _IT end) noexcept |
Encodes a sequence of characters in URI format. | |
static std::string | decode (std::string_view input) noexcept |
Decodes a URI-encoded string view. | |
static std::string | encode (std::string_view input) noexcept |
Encodes a string view in URI format. | |
static std::string | decode (const char *input, std::size_t size) noexcept |
Decodes a URI-encoded memory block. | |
static std::string | encode (const char *input, std::size_t size) noexcept |
Encodes a memory block in URI format. | |
static uri | parse (std::string const &str, int af=AF_INET) noexcept |
Creates and parses a URI from a string. | |
static bool | is_valid_scheme (std::string_view scheme) noexcept |
Validates if a string is a valid URI scheme. | |
static bool | is_valid_host (std::string_view host) noexcept |
Validates if a string is a valid URI host. | |
static bool | normalize_path (std::string &path) noexcept |
Normalizes a path by resolving '. |
Class for parsing, manipulating, and representing URIs.
This class implements URIs according to RFC 3986 and supports URI components such as scheme, authority (including host and port), path, query, and fragment. It also handles encoding and decoding of special characters and supports IPv4 and IPv6 addressing formats.
|
noexcept |
Move constructor.
rhs | Source URI to move from |
qb::io::uri::uri | ( | uri const & | rhs | ) |
Copy constructor.
rhs | Source URI to copy from |
qb::io::uri::uri | ( | std::string const & | str, |
int | af = AF_INET ) |
Constructor from a string.
str | The source string for the URI |
af | The address family (defaults to AF_INET) |
|
noexcept |
Constructor from a string (move version)
str | The source string for the URI (will be moved) |
af | The address family (defaults to AF_INET) |
|
inlinestaticnoexcept |
Decodes a sequence of URI-encoded characters.
Converts XX sequences to corresponding characters
_IT | Iterator type |
begin | Begin iterator |
end | End iterator |
|
inlinestaticnoexcept |
Encodes a sequence of characters in URI format.
Converts special characters to XX sequences
_IT | Iterator type |
begin | Begin iterator |
end | End iterator |
|
staticnoexcept |
Decodes a URI-encoded string view.
input | The string view to decode |
|
staticnoexcept |
Encodes a string view in URI format.
input | The string view to encode |
|
staticnoexcept |
Decodes a URI-encoded memory block.
input | Pointer to the data to decode |
size | Size of the data |
|
staticnoexcept |
Encodes a memory block in URI format.
input | Pointer to the data to encode |
size | Size of the data |
|
staticnoexcept |
Creates and parses a URI from a string.
str | The source string for the URI |
af | The address family (defaults to AF_INET) |
Copy assignment operator.
rhs | Source URI to copy from |
Move assignment operator.
rhs | Source URI to move from |
uri & qb::io::uri::operator= | ( | std::string const & | str | ) |
String assignment operator.
str | The source string for the URI |
|
noexcept |
String move assignment operator.
str | The source string for the URI (will be moved) |
|
inlinenodiscard |
Returns the address family of this URI.
|
inlinenodiscard |
Returns the source string of this URI.
|
inlinenodiscard |
Returns the scheme of this URI.
|
inlinenodiscard |
Returns the user information of this URI.
|
inlinenodiscard |
Returns the host name or IP address of this URI.
|
inlinenodiscard |
Returns the port number of this URI.
|
inlinenodiscard |
Returns the port number of this URI as a numeric value.
|
inlinenodiscard |
Returns the path of this URI.
|
inlinenodiscard |
Returns the raw query string of this URI.
|
inlinenodiscard |
Returns the parsed query parameters of this URI.
|
inlinenodiscard |
Returns the parsed query parameters of this URI (non-const version)
|
inlinenodiscard |
Returns the value of a specific query parameter.
T | Parameter name type |
name | Name of the parameter to retrieve |
index | Index of the value to retrieve (for multi-value parameters) |
not_found | Value to return if the parameter is not found |
|
inlinenodiscard |
Returns the fragment of this URI.
|
staticnoexcept |
Validates if a string is a valid URI scheme.
scheme | The scheme to validate |
|
staticnoexcept |
Validates if a string is a valid URI host.
host | The host to validate |
|
staticnoexcept |
Normalizes a path by resolving '.
', '..' segments and standardizing slashes
path | Path to normalize (will be modified) |