![]() |
Gorgon Game Engine
|
Represents an unfolded URI. More...
Public Member Functions | |
URI ()=default | |
Empty constructor. Does not set scheme thus would not be a valid URI. More... | |
URI (const char *str) | |
Builds a new URI from the given string. More... | |
URI (const std::string &scheme, const std::string &host, const std::string &path, const std::string &query="", const std::string &fragment="") | |
Creates a new URI by filling in fields. More... | |
URI (const std::string &scheme, const std::string &host, int port, const std::string &path, const std::string &query="", const std::string &fragment="") | |
Creates a new URI by filling in fields. More... | |
URI (const std::string &str, bool inpagelink=false) | |
Builds a new URI from the given string. More... | |
void | Combine (const std::string &link) |
Combines a relative URI into this URI. More... | |
std::string | Convert () const |
Converts this URI to a properly encoded string. More... | |
bool | IsValid () const |
Returns if this URI is valid. More... | |
operator bool () const | |
Returns if this URI is valid. More... | |
operator std::string () const | |
Converts this URI to a properly encoded string. More... | |
bool | operator!= (const URI &other) const |
Compares two URIs in their simplest forms. More... | |
URI | operator+ (const std::string &link) |
bool | operator== (const URI &other) const |
Compares two URIs in their simplest forms. More... | |
Public Attributes | |
std::string | fragment |
Fragment of the resource (anchor in HTML) More... | |
std::string | host |
Host address, either IP/domain name or empty, ex: darkgaze.org. More... | |
std::string | path |
Path of the resource. Segments must be separated by /. You may use URIPath to construct a path. More... | |
int | port |
The port number, 0 means it is not defined. More... | |
std::string | query |
Query for the resource, must be properly escaped and encoded, you may use HTTPQuery to build http query string. More... | |
std::string | scheme |
Scheme of the URI, ex: http. More... | |
std::string | userinfo |
User information. More... | |
Represents an unfolded URI.
Can be used to parse a URI string or build one according to RFC 3986.
URI | ( | const std::string & | scheme, |
const std::string & | host, | ||
const std::string & | path, | ||
const std::string & | query = "" , |
||
const std::string & | fragment = "" |
||
) |
Creates a new URI by filling in fields.
URI | ( | const std::string & | scheme, |
const std::string & | host, | ||
int | port, | ||
const std::string & | path, | ||
const std::string & | query = "" , |
||
const std::string & | fragment = "" |
||
) |
Creates a new URI by filling in fields.
URI | ( | const std::string & | str, |
bool | inpagelink = false |
||
) |
Builds a new URI from the given string.
May throw URIError. This constructor will not check if the URI is really valid. Use IsValid function for this purpose. If this URI is embedded inside another URI and possibly a relative link, set inpagelink to true. Otherwise, URIs without scheme will be treated having a host. For instance when inpagelink is false, in URI darkgaze.org/my/path darkgaze.org would be treated as host name.
References URI::fragment, URI::host, URI::path, URI::port, URI::query, URI::scheme, and URI::userinfo.
URI | ( | const char * | str | ) |
void Combine | ( | const std::string & | link | ) |
Combines a relative URI into this URI.
Can be used to normalize links in a document. Care should be taken while using URIPath with this function as URIPath cannot represent relative paths.
References URI::URI(), URI::fragment, URI::host, URI::path, URI::query, and URI::scheme.
std::string Convert | ( | ) | const |
Converts this URI to a properly encoded string.
bool IsValid | ( | ) | const |
Returns if this URI is valid.
This function checks if scheme is valid in format. Additionally, if the scheme is http, https and ftp, checks if the host is set.
References URI::host, Gorgon::Encoding::PCTEncode(), and URI::scheme.
operator bool | ( | ) | const |
Returns if this URI is valid.
References URI::IsValid().
operator std::string | ( | ) | const |
Converts this URI to a properly encoded string.
References Gorgon::Encoding::PCTEncode(), and Gorgon::String::ToLower().
bool operator!= | ( | const URI & | other | ) | const |
Compares two URIs in their simplest forms.
Note that URIs with different fragments point to different places in the same resource and will not be used in comparison. This is also recommended by RFC 3986
URI operator+ | ( | const std::string & | link | ) |
References URI::Combine().
bool operator== | ( | const URI & | other | ) | const |
Compares two URIs in their simplest forms.
Note that URIs with different fragments point to different places in the same resource and will not be used in comparison. This is also recommended by RFC 3986
References URI::host, URI::path, URI::port, URI::query, URI::scheme, Gorgon::String::ToLower(), and URI::userinfo.
std::string fragment |
Fragment of the resource (anchor in HTML)
std::string host |
Host address, either IP/domain name or empty, ex: darkgaze.org.
std::string path |
Path of the resource. Segments must be separated by /. You may use URIPath to construct a path.
int port |
The port number, 0 means it is not defined.
std::string query |
Query for the resource, must be properly escaped and encoded, you may use HTTPQuery to build http query string.
std::string scheme |
Scheme of the URI, ex: http.
Scheme cannot be encoded, thus should only start with an alpha character and should only contain Alphanumeric characters as well as +, - and .
std::string userinfo |
User information.
Use : to separate password. Use of password is no longer recommended by RFC unless it is empty.