All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
te::common::uri::path Class Reference

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...
 
pathoperator+= (const std::string &rhs)
 Append unencoded segment and reset is_directory. More...
 
pathoperator+= (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...
 

Detailed Description

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 )
See also
http://tools.ietf.org/html/rfc3986#section-3.3

Definition at line 51 of file path.h.

Member Typedef Documentation

typedef segments_type::const_iterator te::common::uri::path::const_iterator

segments const iterator type

Definition at line 54 of file path.h.

typedef std::list<std::string> te::common::uri::path::segments_type

segments type

Definition at line 53 of file path.h.

Constructor & Destructor Documentation

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.

Exceptions
std::invalid_argumentif invalid encoding

Definition at line 33 of file path.cpp.

References parse.

Member Function Documentation

bool te::common::uri::path::absolute ( ) const
inline

Test if absolute, meaning path begins with "/".

Definition at line 64 of file path.h.

Referenced by te::common::URL::setIsAbsolutePath().

void te::common::uri::path::absolute ( bool  v)
inline

Set whether absolute or not.

Definition at line 66 of file path.h.

const std::string & te::common::uri::path::back ( ) const

Get back segment.

Exceptions
std::out_of_rangeif empty

Definition at line 67 of file path.cpp.

References segments_.

const_iterator te::common::uri::path::begin ( ) const
inline

Get iterator at beginning.

Definition at line 111 of file path.h.

Referenced by te::common::URL::beginPath(), match_prefix(), and string().

void te::common::uri::path::clear ( )

Clear segments and reset absolute and is_directory.

Definition at line 40 of file path.cpp.

References absolute_, is_directory_, and segments_.

Referenced by te::common::URL::clearPath().

bool te::common::uri::path::empty ( ) const
inline

Test if empty and not absolute.

Definition at line 62 of file path.h.

Referenced by te::common::uri::uri::is_null(), and pop_back().

std::string te::common::uri::path::encoding ( ) const
const_iterator te::common::uri::path::end ( ) const
inline

Get iterator at end.

Definition at line 112 of file path.h.

Referenced by te::common::URL::endPath(), match_prefix(), and string().

const std::string & te::common::uri::path::front ( ) const

Get front segment.

Exceptions
std::out_of_rangeif empty

Definition at line 62 of file path.cpp.

References segments_.

bool te::common::uri::path::is_directory ( ) const
inline

Test if a directory, meaning the path ends in a "/".

Definition at line 68 of file path.h.

Referenced by te::common::URL::setIsDirectoryPath().

void te::common::uri::path::is_directory ( bool  v)
inline

Set whether a directory or not.

Definition at line 70 of file path.h.

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.

Definition at line 45 of file path.cpp.

References absolute_, begin(), end(), and is_directory_.

bool te::common::uri::path::operator!= ( const path rhs) const
inline

Not equal operator.

Definition at line 91 of file path.h.

path te::common::uri::path::operator+ ( const std::string &  rhs) const
inline

Append unencoded segment and reset is_directory.

Definition at line 98 of file path.h.

path te::common::uri::path::operator+ ( const path rhs) const
inline

Append path and set is_directory according to rhs.

Definition at line 104 of file path.h.

path & te::common::uri::path::operator+= ( const std::string &  rhs)

Append unencoded segment and reset is_directory.

Definition at line 125 of file path.cpp.

References is_directory_, and segments_.

path & te::common::uri::path::operator+= ( const path rhs)

Append path and set is_directory according to rhs.

Definition at line 130 of file path.cpp.

References absolute_, is_directory_, and segments_.

bool te::common::uri::path::operator< ( const path rhs) const

Less operator.

Examines the following in order:

  1. relative are less than absolute
  2. lexicographical comparison of segments
  3. non-directories are less than directories

Definition at line 111 of file path.cpp.

References absolute_, is_directory_, and segments_.

bool te::common::uri::path::operator== ( const path rhs) const

Get number of segments.

Equal operator.

Definition at line 108 of file path.cpp.

References absolute_, is_directory_, and segments_.

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.

Definition at line 80 of file path.cpp.

References absolute_, empty(), is_directory_, and segments_.

void te::common::uri::path::pop_front ( )

Pop front segment and reset absolute.

Definition at line 72 of file path.cpp.

References absolute_, is_directory_, and segments_.

size_t te::common::uri::path::size ( ) const
inline

Definition at line 89 of file path.h.

std::string te::common::uri::path::string ( ) const

Return path string. Added by Lauro.

Definition at line 151 of file path.cpp.

References begin(), end(), is_directory_, and SEPARATOR_CHAR.

Friends And Related Function Documentation

bool TECOMMONEXPORT parse ( std::string::const_iterator &  first,
std::string::const_iterator  last,
path v,
std::string *  errs 
)
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:

  • Errors in decoding segments do not cause an immediate false return and and error message is reported in the error string errs. The segment is used without decoding (i.e. assumes an unencoded '').

Definition at line 169 of file path.cpp.

Referenced by path().

Member Data Documentation

bool te::common::uri::path::absolute_
private
bool te::common::uri::path::is_directory_
private
segments_type te::common::uri::path::segments_
private
const char te::common::uri::path::SEPARATOR_CHAR = '/'
static

separator ('/')

Definition at line 113 of file path.h.

Referenced by encoding(), te::common::uri::parse(), and string().


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