Gazebo Common

API Reference

6.0.0

#include <URI.hh>

Public Member Functions

 URIAuthority ()
 Constructor.
 
 URIAuthority (const std::string &_str)
 Construct a URIAuthority object from a string.
 
void Clear ()
 Remove all parts of the authority.
 
bool EmptyHostValid () const
 True if an empty host is considered valid.
 
std::string Host () const
 Get the host.
 
bool operator== (const URIAuthority &_auth) const
 Return true if the two authorities match.
 
bool Parse (const std::string &_str, bool _emptyHostValid=false)
 Parse a string as URIAuthority.
 
std::optional< int > Port () const
 Get the port.
 
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".
 
void SetHost (const std::string &_host)
 Set the host.
 
void SetPort (int _port)
 Set the port number.
 
void SetUserInfo (const std::string &_userInfo)
 Set the user information.
 
std::string Str () const
 Get the complete authoriy as a string.
 
std::string UserInfo () const
 Get the user information.
 
bool Valid () const
 Return true if this is a valid authority.
 

Static Public Member Functions

static bool Valid (const std::string &_str, bool _emptyHostValid=false)
 Return true if the string is a valid path.
 

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/2]

Constructor.

◆ URIAuthority() [2/2]

URIAuthority ( const std::string _str)
explicit

Construct a URIAuthority object from a string.

Parameters
[in]_strA 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]_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)

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)

Set the host.

Parameters
[in]_hostThe host.

◆ SetPort()

void SetPort ( int  _port)

Set the port number.

◆ SetUserInfo()

void SetUserInfo ( const std::string _userInfo)

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]

bool Valid ( ) const

Return true if this is a valid authority.

Returns
True if this is a valid URI authority.

◆ Valid() [2/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.

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