roar
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Roar::Url Struct Reference

#include <url.hpp>

Collaboration diagram for Roar::Url:

Classes

struct  Authority
 
struct  Host
 
struct  UserInfo
 

Public Member Functions

std::string toString (bool doUrlEncode=true, bool includeFragment=true) const
 Converts the url to a string containing all parts: https://u:p@bla.com:80/path?k=v.
 
std::string pathAsString (bool doUrlEncode=true) const
 Will only create the path as a string with a leading slash: "/path/to/resource".
 
std::string hostAsString () const
 Returns the host part of the url as a string. Does not include the port! IPv6 addresses will be enclosed in square brackets.
 
std::string getAuthority (bool doUrlEncode) const
 Converts the entire authority part to string: "user:password@domain.com:770".
 
std::string schemeAndAuthority (bool doUrlEncode=true) const
 Converts the authority part and scheme to string: "https://user:password@domain.com:770".
 

Static Public Member Functions

static boost::leaf::result< UrlfromString (std::string url)
 Parses a string that is a url.
 
static boost::leaf::result< std::vector< std::string > > parsePath (std::string const &path)
 Splits up a path string into a vector compatible with this class. An empty path returns an empty vector.
 

Public Attributes

std::string scheme
 
Authority authority
 
std::vector< std::string > path
 
std::unordered_map< std::string, std::string > query
 
std::string fragment
 

Member Function Documentation

◆ fromString()

boost::leaf::result< Url > Roar::Url::fromString ( std::string  url)
static

Parses a string that is a url.

Parameters
urlA url string.
Returns
std::optional<Url> A url or a runtime_error.

◆ getAuthority()

std::string Roar::Url::getAuthority ( bool  doUrlEncode) const

Converts the entire authority part to string: "user:password@domain.com:770".

Parameters
doUrlEncodeWill url encode necessary characters when true.
Returns
std::string The authority part of the url as string.

◆ hostAsString()

std::string Roar::Url::hostAsString ( ) const

Returns the host part of the url as a string. Does not include the port! IPv6 addresses will be enclosed in square brackets.

Returns
std::string The domain/ip of the url.

◆ parsePath()

boost::leaf::result< std::vector< std::string > > Roar::Url::parsePath ( std::string const &  path)
static

Splits up a path string into a vector compatible with this class. An empty path returns an empty vector.

Parameters
pathA path string starting with a leading slash: "/path/to/resource".
Returns
Fallible<std::vector<std::string>> The path segments ["path", "to", "resource"].

◆ pathAsString()

std::string Roar::Url::pathAsString ( bool  doUrlEncode = true) const

Will only create the path as a string with a leading slash: "/path/to/resource".

Parameters
doUrlEncodeWill url encode necessary characters when true.
Returns
std::string the path part of the url.

◆ schemeAndAuthority()

std::string Roar::Url::schemeAndAuthority ( bool  doUrlEncode = true) const

Converts the authority part and scheme to string: "https://user:password@domain.com:770".

Parameters
doUrlEncodeWill url encode necessary characters when true.
Returns
std::string The scheme and authority of the url.

◆ toString()

std::string Roar::Url::toString ( bool  doUrlEncode = true,
bool  includeFragment = true 
) const

Converts the url to a string containing all parts: https://u:p@bla.com:80/path?k=v.

Parameters
doUrlEncodeWill url encode necessary characters when true.
includeFragmentThe fragment part will not be added when false.
Returns
std::string the url

Member Data Documentation

◆ authority

Authority Roar::Url::authority

◆ fragment

std::string Roar::Url::fragment

◆ path

std::vector<std::string> Roar::Url::path

◆ query

std::unordered_map<std::string, std::string> Roar::Url::query

◆ scheme

std::string Roar::Url::scheme

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