RAVENNAKIT
Loading...
Searching...
No Matches
rav::Uri Struct Reference

URI parser and encoder. More...

#include <uri.hpp>

Public Member Functions

std::string to_string () const
 Encodes the URI into a string.

Static Public Member Functions

static Uri parse (const std::string &encoded_uri)
 Parse a string into a URI.
static std::string encode (std::string_view str, bool encode_plus=false, bool encode_slash=false)
 Encode a string to be used in a URI.
static std::string encode (std::string_view scheme, std::string_view host, std::string_view path)
 Shortcut to create a basic encoded URI.
static std::string decode (std::string_view encoded, bool decode_plus=false)
 Decodes a percent-encoded string.
static std::map< std::string, std::string > parse_query (std::string_view)
 Parse a query string into a map.

Public Attributes

std::string scheme
std::string user
std::string password
std::string host
std::optional< uint16_t > port
std::string path
std::map< std::string, std::string > query
std::string fragment

Detailed Description

URI parser and encoder.

Should be enough for the common case, but it's not a full implementation.

Definition at line 37 of file uri.hpp.

Member Function Documentation

◆ decode()

std::string rav::Uri::decode ( std::string_view encoded,
bool decode_plus = false )
staticnodiscard

Decodes a percent-encoded string.

Parameters
encodedEncoded string.
decode_plusWhether to decode '+' as space.
Returns
Decoded string.

◆ encode() [1/2]

std::string rav::Uri::encode ( std::string_view scheme,
std::string_view host,
std::string_view path )
static

Shortcut to create a basic encoded URI.

Parameters
schemeScheme.
hostHost.
pathPath.
Returns
Encoded URI string.

◆ encode() [2/2]

std::string rav::Uri::encode ( std::string_view str,
bool encode_plus = false,
bool encode_slash = false )
static

Encode a string to be used in a URI.

Parameters
strString to encode.
encode_plusWhether to encode '+' as '%2B'.
encode_slashWhether to encode '/' as '%2F'.
Returns
Encoded string.

◆ parse()

Uri rav::Uri::parse ( const std::string & encoded_uri)
static

Parse a string into a URI.

Parameters
encoded_uriEncoded URI string.
Returns
Parsed URI.

◆ parse_query()

std::map< std::string, std::string > rav::Uri::parse_query ( std::string_view )
static

Parse a query string into a map.

Returns
Map of query parameters.

◆ to_string()

std::string rav::Uri::to_string ( ) const
nodiscard

Encodes the URI into a string.

Returns
Encoded URI string.

Member Data Documentation

◆ fragment

std::string rav::Uri::fragment

Definition at line 45 of file uri.hpp.

◆ host

std::string rav::Uri::host

Definition at line 41 of file uri.hpp.

◆ password

std::string rav::Uri::password

Definition at line 40 of file uri.hpp.

◆ path

std::string rav::Uri::path

Definition at line 43 of file uri.hpp.

◆ port

std::optional<uint16_t> rav::Uri::port

Definition at line 42 of file uri.hpp.

◆ query

std::map<std::string, std::string> rav::Uri::query

Definition at line 44 of file uri.hpp.

◆ scheme

std::string rav::Uri::scheme

Definition at line 38 of file uri.hpp.

◆ user

std::string rav::Uri::user

Definition at line 39 of file uri.hpp.


The documentation for this struct was generated from the following file: