#include <URI.hh>
Public Member Functions | |
URIAuthority () | |
Constructor. More... | |
URIAuthority (const std::string &_str) | |
Construct a URIAuthority object from a string. More... | |
void | Clear () |
Remove all parts of the authority. More... | |
bool | EmptyHostValid () const |
True if an empty host is considered valid. More... | |
std::string | Host () const |
Get the host. More... | |
bool | operator== (const URIAuthority &_auth) const |
Return true if the two authorities match. More... | |
bool | Parse (const std::string &_str, bool _emptyHostValid=false) |
Parse a string as URIAuthority. More... | |
std::optional< int > | Port () const |
Get the port. More... | |
void | SetEmptyHostValid (bool _valid) |
Set whether an empty host is considered valid. This should only be set to true if the corresponding URIScheme is "file". More... | |
void | SetHost (const std::string &_host) |
Set the host. More... | |
void | SetPort (int _port) |
Set the port number. More... | |
void | SetUserInfo (const std::string &_userInfo) |
Set the user information. More... | |
std::string | Str () const |
Get the complete authoriy as a string. More... | |
std::string | UserInfo () const |
Get the user information. More... | |
bool | Valid () const |
Return true if this is a valid authority. More... | |
Static Public Member Functions | |
static bool | Valid (const std::string &_str, bool _emptyHostValid=false) |
Return true if the string is a valid path. More... | |
Detailed Description
A URI authority contains userinfo, host, and port data. The format of a URI authority is //userinfo@host:port
. The userinfo
and port
components are optional.
A URI Authority requires the existence of host information, except when a Scheme is file
. When a scheme is file
, then the following are considered valid URIs and equivalent:
Keep in mind that a URI path must start with a forward slash when an authority, as indicated by two forward slashes, is present. This means relative file paths cannot be specified with an empty authority. For example, file://abs/path
will result in a host value of abs
and the URI path will be /path
. You can specify a relative path using file:abs/path
.
URIs that are set not to have an authority (i.e. Authority() == false
) preserve the legacy behaviour, which is:
file:/abs/path
has the path/abs/path
file://abs/path
has the pathabs/path
file:///abs/path
has the path/abs/path
Constructor & Destructor Documentation
◆ URIAuthority() [1/2]
URIAuthority | ( | ) |
Constructor.
◆ URIAuthority() [2/2]
|
explicit |
Construct a URIAuthority object from a string.
- Parameters
-
[in] _str A string.
Member Function Documentation
◆ Clear()
void Clear | ( | ) |
Remove all parts of the authority.
◆ EmptyHostValid()
bool EmptyHostValid | ( | ) | const |
True if an empty host is considered valid.
- Returns
- True if an empty host is valid.
◆ Host()
std::string Host | ( | ) | const |
Get the host.
- Returns
- The host.
◆ operator==()
bool operator== | ( | const URIAuthority & | _auth | ) | const |
Return true if the two authorities match.
- Parameters
-
[in] _auth Authority. return True of the authorities match.
◆ Parse()
bool Parse | ( | const std::string & | _str, |
bool | _emptyHostValid = false |
||
) |
Parse a string as URIAuthority.
- Parameters
-
[in] _str A string. [in] _emptyHostValid Set this to true if an empty host is valid. This should only be set to true if the corresponding URIScheme is "file".
- Returns
- True if the string could be parsed as a URIAuthority.
◆ Port()
std::optional<int> Port | ( | ) | const |
Get the port.
- Returns
- The port number, which is optional.
◆ SetEmptyHostValid()
void SetEmptyHostValid | ( | bool | _valid | ) |
Set whether an empty host is considered valid. This should only be set to true if the corresponding URIScheme is "file".
- Parameters
-
[in] _valid True if an empty host is valid.
◆ SetHost()
void SetHost | ( | const std::string & | _host | ) |
Set the host.
- Parameters
-
[in] _host The host.
◆ SetPort()
void SetPort | ( | int | _port | ) |
Set the port number.
◆ SetUserInfo()
void SetUserInfo | ( | const std::string & | _userInfo | ) |
Set the user information.
- Parameters
-
[in] _userInfo The user information string.
◆ Str()
std::string Str | ( | ) | const |
Get the complete authoriy as a string.
- Returns
- The authority as a string.
◆ UserInfo()
std::string UserInfo | ( | ) | const |
Get the user information.
- Returns
- User information, or an empty string if the user information is not set.
◆ Valid() [1/2]
bool Valid | ( | ) | const |
Return true if this is a valid authority.
- Returns
- True if this is a valid URI authority.
◆ Valid() [2/2]
|
static |
Return true if the string is a valid path.
- Parameters
-
[in] _str String to check. [in] _emptyHostValid Set this to true if an empty host is valid. This should only be set to true if the corresponding URIScheme is "file".
- Returns
- True if _str is a valid URI path.
The documentation for this class was generated from the following file: