Ignition Common

API Reference

4.5.0

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

Static Public Member Functions

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

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

URIPath ( )

Constructor.

◆ URIPath() [2/3]

URIPath ( const URIPath _path)

Copy constructor.

Parameters
[in]_pathAnother URIPath.

◆ URIPath() [3/3]

URIPath ( const std::string _str)
explicit

Construct a URIPath object from a string.

Parameters
[in]_strA string.

◆ ~URIPath()

virtual ~URIPath ( )
virtual

Destructor.

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

URIPath& operator= ( const URIPath _path)

Assignment operator.

Parameters
[in]_pathAnother URIPath.
Returns
Itself.

◆ 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]

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.

◆ Valid() [2/2]

bool Valid ( ) const

Return true if this is a valid path.

Returns
True if this is a valid URI path.

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