MySQL 8.4.2
Source Code Documentation
mysqlrouter::URI Class Reference

Parse and create URIs according to RFC3986. More...

#include <uri.h>

Public Member Functions

 URI (const std::string &uri, bool allow_path_rootless=true, bool allow_schemeless=false, bool path_keep_last_slash=false, bool query_single_parameter_when_cant_parse=false)
 Default constructor. More...
 
bool operator== (const URI &u2) const
 
bool operator!= (const URI &u2) const
 
std::string str () const
 return string representation of the URI More...
 
 URI ()
 overload More...
 
void set_uri (const std::string &uri)
 Sets URI using the given URI string. More...
 
std::string get_path_as_string (bool needs_first_slash=true) const
 Path part of the URI as string. More...
 
void set_path_from_string (const std::string &p)
 Set the path part of the URI as string. More...
 
std::string get_query_as_string () const
 Get the URIs path part. More...
 
void set_query_from_string (const std::string &q)
 Set the URI query part by reparsing query string. More...
 

Public Attributes

std::string scheme
 Scheme of the URI. More...
 
std::string host
 Host part found in the Authority. More...
 
uint16_t port
 Port found in the Authority. More...
 
std::string username
 Username part found in the Authority. More...
 
std::string password
 Password part found in the Authority. More...
 
URIPath path
 Path part of the URI. More...
 
URIQuery query
 Query part of the URI. More...
 
std::string fragment
 Fragment part of the URI. More...
 

Static Public Attributes

static const char query_delimiter = '&'
 Delimiter used in the Query part. More...
 

Private Member Functions

void init_from_uri (const std::string &uri)
 Sets information using the given URI. More...
 

Private Attributes

std::string uri_
 Copy of the original given URI. More...
 
bool allow_path_rootless_
 all URIs like mail:foo@e.nosp@m.xamp.nosp@m.le.or.nosp@m.g which don't have a authority More...
 
bool allow_schemeless_
 all URIs like foo@e.nosp@m.xamp.nosp@m.le.or.nosp@m.g which don't have a scheme More...
 
bool path_keep_last_slash_
 
bool query_single_parameter_when_cant_parse_
 
bool query_is_signle_parameter_ {false}
 

Friends

ROUTER_UTILS_EXPORT std::ostream & operator<< (std::ostream &strm, const URI &uri)
 

Detailed Description

Parse and create URIs according to RFC3986.

This class will parse and make the elements of the URI available as members.

Links:

Constructor & Destructor Documentation

◆ URI() [1/2]

mysqlrouter::URI::URI ( const std::string &  uri,
bool  allow_path_rootless = true,
bool  allow_schemeless = false,
bool  path_keep_last_slash = false,
bool  query_single_parameter_when_cant_parse = false 
)
inline

Default constructor.

Rootless URIs like "mailto:user@example.com" may be forbidden to make sure that simple "host:addr" doesn't get parsed as (scheme='host', path='addr')

Parameters
uriURI string to decode
allow_path_rootlessif parsing rootless URIs is allowed
allow_schemelessdefine if schema is mandatory
path_keep_last_slashparsing the URL keeps last slash
query_single_parameter_when_cant_parseThis parameter allows to handles query parameter that follows the RFC but is not accepted by default implementation of URL

◆ URI() [2/2]

mysqlrouter::URI::URI ( )
inline

overload

Member Function Documentation

◆ get_path_as_string()

std::string mysqlrouter::URI::get_path_as_string ( bool  needs_first_slash = true) const

Path part of the URI as string.

◆ get_query_as_string()

std::string mysqlrouter::URI::get_query_as_string ( ) const

Get the URIs path part.

◆ init_from_uri()

void mysqlrouter::URI::init_from_uri ( const std::string &  uri)
private

Sets information using the given URI.

Takes a and parsers out all URI elements.

Throws URIError on errors.

Parameters
uriURI to use

◆ operator!=()

bool mysqlrouter::URI::operator!= ( const URI u2) const

◆ operator==()

bool mysqlrouter::URI::operator== ( const URI u2) const

◆ set_path_from_string()

void mysqlrouter::URI::set_path_from_string ( const std::string &  p)

Set the path part of the URI as string.

Parameters
ppath string to decode and store in URI object

◆ set_query_from_string()

void mysqlrouter::URI::set_query_from_string ( const std::string &  q)

Set the URI query part by reparsing query string.

Parameters
qquery string to decode and store in URI object

◆ set_uri()

void mysqlrouter::URI::set_uri ( const std::string &  uri)
inline

Sets URI using the given URI string.

Parameters
uriURI as string

◆ str()

std::string mysqlrouter::URI::str ( ) const

return string representation of the URI

Friends And Related Function Documentation

◆ operator<<

ROUTER_UTILS_EXPORT std::ostream & operator<< ( std::ostream &  strm,
const URI uri 
)
friend

Member Data Documentation

◆ allow_path_rootless_

bool mysqlrouter::URI::allow_path_rootless_
private

all URIs like mail:foo@e.nosp@m.xamp.nosp@m.le.or.nosp@m.g which don't have a authority

◆ allow_schemeless_

bool mysqlrouter::URI::allow_schemeless_
private

all URIs like foo@e.nosp@m.xamp.nosp@m.le.or.nosp@m.g which don't have a scheme

◆ fragment

std::string mysqlrouter::URI::fragment

Fragment part of the URI.

◆ host

std::string mysqlrouter::URI::host

Host part found in the Authority.

◆ password

std::string mysqlrouter::URI::password

Password part found in the Authority.

◆ path

URIPath mysqlrouter::URI::path

Path part of the URI.

◆ path_keep_last_slash_

bool mysqlrouter::URI::path_keep_last_slash_
private

◆ port

uint16_t mysqlrouter::URI::port

Port found in the Authority.

◆ query

URIQuery mysqlrouter::URI::query

Query part of the URI.

◆ query_delimiter

const char mysqlrouter::URI::query_delimiter = '&'
static

Delimiter used in the Query part.

◆ query_is_signle_parameter_

bool mysqlrouter::URI::query_is_signle_parameter_ {false}
private

◆ query_single_parameter_when_cant_parse_

bool mysqlrouter::URI::query_single_parameter_when_cant_parse_
private

◆ scheme

std::string mysqlrouter::URI::scheme

Scheme of the URI.

◆ uri_

std::string mysqlrouter::URI::uri_
private

Copy of the original given URI.

◆ username

std::string mysqlrouter::URI::username

Username part found in the Authority.


The documentation for this class was generated from the following files: