URI path component. More...
#include <path.h>
Public Types | |
typedef segments_type::const_iterator | const_iterator |
segments const iterator type More... | |
typedef std::list< std::string > | segments_type |
segments type More... | |
Public Member Functions | |
bool | absolute () const |
Test if absolute, meaning path begins with "/". More... | |
void | absolute (bool v) |
Set whether absolute or not. More... | |
const std::string & | back () const |
Get back segment. More... | |
const_iterator | begin () const |
Get iterator at beginning. More... | |
void | clear () |
Clear segments and reset absolute and is_directory. More... | |
bool | empty () const |
Test if empty and not absolute. More... | |
std::string | encoding () const |
Calculate encoded string. More... | |
const_iterator | end () const |
Get iterator at end. More... | |
const std::string & | front () const |
Get front segment. More... | |
bool | is_directory () const |
Test if a directory, meaning the path ends in a "/". More... | |
void | is_directory (bool v) |
Set whether a directory or not. More... | |
bool | match_prefix (const path &rhs) const |
Test if the given other URI path is a prefix of this. More... | |
bool | operator!= (const path &rhs) const |
Not equal operator. More... | |
path | operator+ (const std::string &rhs) const |
Append unencoded segment and reset is_directory. More... | |
path | operator+ (const path &rhs) const |
Append path and set is_directory according to rhs. More... | |
path & | operator+= (const std::string &rhs) |
Append unencoded segment and reset is_directory. More... | |
path & | operator+= (const path &rhs) |
Append path and set is_directory according to rhs. More... | |
bool | operator< (const path &rhs) const |
Less operator. More... | |
bool | operator== (const path &rhs) const |
Get number of segments. More... | |
path () | |
Construct. More... | |
path (const std::string &v) | |
Construct from encoded string. More... | |
bool | pop_back (const path &back) |
Remove the back of the path if it matches the argument (including whether directory or not) and return whether removed/matched. More... | |
void | pop_front () |
Pop front segment and reset absolute. More... | |
size_t | size () const |
std::string | string () const |
Return path string. Added by Lauro. More... | |
Static Public Attributes | |
static const char | SEPARATOR_CHAR |
separator ('/') More... | |
Private Attributes | |
bool | absolute_ |
bool | is_directory_ |
segments_type | segments_ |
Friends | |
bool TECOMMONEXPORT | parse (std::string::const_iterator &first, std::string::const_iterator last, path &v, std::string *errs) |
Parse URI path, returning whether found or not and advancing first and setting path if found. More... | |
URI path component.
Note that there are potential ambiguities when using ":" and "//" in paths in URIs (see RFC).
Syntax: Segments are pct-decoded after parsing.
ALPHA = x41-5A | x61-7A ; A-Z | a-z DIGIT = x30-39 ; 0-9 sub-delims = "!" | "$" | "&" | "'" | "(" | ")" | "*" | "+" | "," | ";" | "=" unreserved = ALPHA | DIGIT | "-" | "." | "_" | "~" pchar = unreserved | pct-encoded | sub-delims | ":" | "@" segment = *pchar path = *( "/" segment )
typedef segments_type::const_iterator te::common::uri::path::const_iterator |
typedef std::list<std::string> te::common::uri::path::segments_type |
te::common::uri::path::path | ( | ) |
Construct.
te::common::uri::path::path | ( | const std::string & | v | ) |
Construct from encoded string.
For example "/foo/bar" or "/foo/ba%20r". Empty segments are removed, i.e. "a//b" becomes "a/b". See parse()
for less strict construction.
std::invalid_argument | if invalid encoding |
|
inline |
|
inline |
const std::string& te::common::uri::path::back | ( | ) | const |
Get back segment.
std::out_of_range | if empty |
|
inline |
void te::common::uri::path::clear | ( | ) |
Clear segments and reset absolute and is_directory.
|
inline |
std::string te::common::uri::path::encoding | ( | ) | const |
Calculate encoded string.
Referenced by te::common::uri::operator<<().
|
inline |
const std::string& te::common::uri::path::front | ( | ) | const |
Get front segment.
std::out_of_range | if empty |
|
inline |
|
inline |
bool te::common::uri::path::match_prefix | ( | const path & | rhs | ) | const |
Test if the given other URI path is a prefix of this.
Must match whether absolute as well.
|
inline |
|
inline |
path& te::common::uri::path::operator+= | ( | const std::string & | rhs | ) |
Append unencoded segment and reset is_directory.
Append path and set is_directory according to rhs.
bool te::common::uri::path::operator< | ( | const path & | rhs | ) | const |
Less operator.
Examines the following in order:
bool te::common::uri::path::operator== | ( | const path & | rhs | ) | const |
Get number of segments.
Equal operator.
bool te::common::uri::path::pop_back | ( | const path & | back | ) |
Remove the back of the path if it matches the argument (including whether directory or not) and return whether removed/matched.
Note that if this starts as a directory it stays a directory. If back is absolute and it does not match all of this or this is not absolute then there is no match.
void te::common::uri::path::pop_front | ( | ) |
Pop front segment and reset absolute.
std::string te::common::uri::path::string | ( | ) | const |
Return path string. Added by Lauro.
|
friend |
Parse URI path, returning whether found or not and advancing first and setting path if found.
Does not skip leading space.
If errs
is specified the following take place:
errs
. The segment is used without decoding (i.e. assumes an unencoded '').
|
private |
|
static |