Ignition Common

API Reference

4.4.0

#include <URI.hh>

Public Member Functions

 URIAuthority ()
 Constructor. More...
 
 URIAuthority (const URIAuthority &_path)
 Copy constructor. More...
 
 URIAuthority (const std::string &_str)
 Construct a URIAuthority object from a string. More...
 
virtual ~URIAuthority ()
 Destructor. 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...
 
URIAuthorityoperator= (const URIAuthority &_auth)
 Assignment operator. 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) const
 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) const
 Set the host. More...
 
void SetPort (int _port) const
 Set the port number. More...
 
void SetUserInfo (const std::string &_userInfo) const
 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:

Constructor & Destructor Documentation

◆ URIAuthority() [1/3]

Constructor.

◆ URIAuthority() [2/3]

URIAuthority ( const URIAuthority _path)

Copy constructor.

Parameters
[in]_pathAnother URIAuthority.

◆ URIAuthority() [3/3]

URIAuthority ( const std::string _str)
explicit

Construct a URIAuthority object from a string.

Parameters
[in]_strA string.

◆ ~URIAuthority()

virtual ~URIAuthority ( )
virtual

Destructor.

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=()

URIAuthority& operator= ( const URIAuthority _auth)

Assignment operator.

Parameters
[in]_authAnother URIAuthority.
Returns
Itself.

◆ operator==()

bool operator== ( const URIAuthority _auth) const

Return true if the two authorities match.

Parameters
[in]_authAuthority. return True of the authorities match.

◆ Parse()

bool Parse ( const std::string _str,
bool  _emptyHostValid = false 
)

Parse a string as URIAuthority.

Parameters
[in]_strA string.
[in]_emptyHostValidSet 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) const

Set whether an empty host is considered valid. This should only be set to true if the corresponding URIScheme is "file".

Parameters
[in]_validTrue if an empty host is valid.

◆ SetHost()

void SetHost ( const std::string _host) const

Set the host.

Parameters
[in]_hostThe host.

◆ SetPort()

void SetPort ( int  _port) const

Set the port number.

◆ SetUserInfo()

void SetUserInfo ( const std::string _userInfo) const

Set the user information.

Parameters
[in]_userInfoThe 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]

static bool Valid ( const std::string _str,
bool  _emptyHostValid = false 
)
static

Return true if the string is a valid path.

Parameters
[in]_strString to check.
[in]_emptyHostValidSet 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.

◆ Valid() [2/2]

bool Valid ( ) const

Return true if this is a valid authority.

Returns
True if this is a valid URI authority.

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