Gazebo Common

API Reference

6.0.1

A URI path contains a sequence of segments separated by /. The path may be empty in a valid URI. When an authority is present, the path must start with a /. More...

#include <URI.hh>

Public Member Functions

 URIPath ()
 Constructor.
 
 URIPath (const std::string &_str)
 Construct a URIPath object from a string.
 
void Clear ()
 Remove all parts of the path.
 
bool IsAbsolute () const
 Returns whether the path is absolute or not.
 
const URIPath operator/ (const std::string &_part) const
 Get the current path with the _part added to the end.
 
const URIPathoperator/= (const std::string &_part)
 Compound assignment operator.
 
bool operator== (const URIPath &_path) const
 Return true if the two paths match.
 
bool Parse (const std::string &_str)
 Parse a string as URIPath.
 
std::string PopBack ()
 Remove the part that's in the back of this path and return it.
 
std::string PopFront ()
 Remove the part that's in the front of this path and return it.
 
void PushBack (const std::string &_part)
 Push a new part onto the back of this path.
 
void PushFront (const std::string &_part)
 Push a new part onto the front of this path.
 
void SetAbsolute (bool _absolute=true)
 Set whether the path is to be treated absolute or not.
 
void SetRelative ()
 Set the path to be relative.
 
std::string Str (const std::string &_delim="/") const
 Get the path as a string.
 
bool Valid () const
 Return true if this is a valid path.
 

Static Public Member Functions

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

Detailed Description

A URI path contains a sequence of segments separated by /. The path may be empty in a valid URI. When an authority is present, the path must start with a /.

In the following URI:

scheme://authority.com/seg1/seg2?query

The path is /seg1/seg2

Constructor & Destructor Documentation

◆ URIPath() [1/2]

URIPath ( )

Constructor.

◆ URIPath() [2/2]

URIPath ( const std::string _str)
explicit

Construct a URIPath object from a string.

Parameters
[in]_strA string.

Member Function Documentation

◆ Clear()

void Clear ( )

Remove all parts of the path.

◆ IsAbsolute()

bool IsAbsolute ( ) const

Returns whether the path is absolute or not.

Returns
Whether the path is absolute or not.

◆ operator/()

const URIPath operator/ ( const std::string _part) const

Get the current path with the _part added to the end.

Parameters
[in]_partPath part.
Returns
A new Path that consists of "this / _part"
See also
PushBack

◆ operator/=()

const URIPath & operator/= ( const std::string _part)

Compound assignment operator.

Parameters
[in]_partA new path to append.
Returns
A new Path that consists of "this / _part"

◆ operator==()

bool operator== ( const URIPath _path) const

Return true if the two paths match.

Parameters
[in]_partPath part. return True of the paths match.

◆ Parse()

bool Parse ( const std::string _str)

Parse a string as URIPath.

Parameters
[in]_strA string.
Returns
True if the string could be parsed as a URIPath.

◆ PopBack()

std::string PopBack ( )

Remove the part that's in the back of this path and return it.

Returns
Popped part. Returns empty string if path doesn't have parts to be popped.

◆ PopFront()

std::string PopFront ( )

Remove the part that's in the front of this path and return it.

Returns
Popped part. Returns empty string if path doesn't have parts to be popped.

◆ PushBack()

void PushBack ( const std::string _part)

Push a new part onto the back of this path.

Parameters
[in]_partPath part to push
See also
operator/ Empty _part is ignored. If _part starts with / and the path is empty, the path is set to absolute (though calling SetAbsolute() is the preferred method). All forward slashes inside the string are URI-encoded to %2F. The path is also set to absolute if it is empty and a Windows drive specifier (e.g. 'C:') is pushed to it.

◆ PushFront()

void PushFront ( const std::string _part)

Push a new part onto the front of this path.

Parameters
[in]_partPath part to push Empty _part is ignored. If _part starts with /, the path is set to absolute (though calling SetAbsolute() is the preferred method). All forward slashes inside the string are URI-encoded to %2F. The path is also set to absolute if a Windows drive specifier (e.g. 'C:') is pushed to the front.

◆ SetAbsolute()

void SetAbsolute ( bool  _absolute = true)

Set whether the path is to be treated absolute or not.

Parameters
[in]_absoluteWhether the path is to be treated absolute or not.
Note
If this path starts with a Windows drive specifier (e.g. 'C:'), it cannot be set non-absolute.

◆ SetRelative()

void SetRelative ( )

Set the path to be relative.

Note
If this path starts with a Windows drive specifier (e.g. 'C:'), it cannot be set relative.

◆ Str()

std::string Str ( const std::string _delim = "/") const

Get the path as a string.

Parameters
[in]_delimDelimiter used to separate each part of the path.
Returns
The path as a string, with each path part separated by _delim.

◆ Valid() [1/2]

bool Valid ( ) const

Return true if this is a valid path.

Returns
True if this is a valid URI path.

◆ Valid() [2/2]

static bool Valid ( const std::string _str)
static

Return true if the string is a valid path.

Parameters
[in]_strString to check.
Returns
True if _str is a valid URI path.

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