uripp::path Class Reference

List of all members.

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


Public Types

typedef std::list< std::string > segments_type
 segments type
typedef segments_type::const_iterator const_iterator
 segments const iterator type

Public Member Functions

 path ()
 path (const std::string &v)
bool empty () const
 Test if empty and not absolute.
bool absolute () const
 Test if absolute, meaning path begins with "/".
void absolute (bool v)
 Set whether absolute or not.
bool is_directory () const
 Test if a directory, meaning the path ends in a "/".
void is_directory (bool v)
 Set whether a directory or not.
const std::string & front () const
const std::string & back () const
bool match_prefix (const path &rhs) const
void pop_front ()
bool pop_back (const path &back)
void clear ()
 Clear segments and reset absolute and is_directory.
size_t size () const
bool operator== (const path &rhs) const
 Get number of segments. Equal operator.
bool operator!= (const path &rhs) const
bool operator< (const path &rhs) const
path operator+ (const std::string &rhs) const
 Append unencoded segment and reset is_directory.
pathoperator+= (const std::string &rhs)
path operator+ (const path &rhs) const
 Append path and set is_directory according to rhs.
pathoperator+= (const path &rhs)
 Append path and set is_directory according to rhs.
std::string encoding () const
 Calculate encoded string.
const_iterator begin () const
 Get iterator at beginning.
const_iterator end () const
 Get iterator at end.

Static Public Attributes

static const char SEPARATOR_CHAR
 separator ('/')

Friends

bool URIPP_API parse (std::string::const_iterator &first, std::string::const_iterator last, path &v, std::string *errs)


Constructor & Destructor Documentation

uripp::path::path (  ) 

Construct.

uripp::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_argument if invalid encoding


Member Function Documentation

const std::string& uripp::path::back (  )  const

Get back segment.

Exceptions:
std::out_of_range if empty

const std::string& uripp::path::front (  )  const

Get front segment.

Exceptions:
std::out_of_range if empty

bool uripp::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.

bool uripp::path::operator!= ( const path rhs  )  const [inline]

Not equal operator.

path& uripp::path::operator+= ( const std::string &  rhs  ) 

Append unencoded segment and reset is_directory.

bool uripp::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

bool uripp::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 uripp::path::pop_front (  ) 

Pop front segment and reset absolute.


Friends And Related Function Documentation

bool URIPP_API 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:


Generated on Wed May 13 09:06:22 2009 for uripp by  doxygen 1.4.7