s11n::io::url_parser Class Reference

url_parser is a basic implementation for parsing a URL string into its atomic components. More...

#include <url.hpp>

List of all members.

Public Types

typedef std::map
< std::string,
std::string > 
args_map_type

Public Member Functions

 url_parser (std::string const &)
 Parses the given URL.
 url_parser ()
 Creates an empty (!good()) parser.
url_parseroperator= (std::string const &)
 Functions the same as the string-argument ctor.
 ~url_parser ()
bool good () const
 Returns true if the last parse() got a "valid" URL.
bool parse (std::string const &)
 Parses URLs of the following forms:.
std::string url () const
 Returns the URL most recently passed to parse().
std::string scheme () const
 Returns the scheme part of url().
std::string user () const
 Returns the user name part of url(), which may be empty.
std::string password () const
 Returns the user password part of url(), which may be empty.
std::string host () const
 Returns the host part of url().
std::string path () const
 Returns the resource path part of url(), which may be empty.
std::string args_str () const
 If the URL path has a '?' in it, anything after the '?' is assumed to be a list of arguments, e.g.
args_map_type const & args_map () const
unsigned short port () const
 Returns the port number part of url(), or 0 if no port was specified.

Classes

struct  impl
 impl holds the private data for a url_parser.


Detailed Description

url_parser is a basic implementation for parsing a URL string into its atomic components.

It is not a full-featured parser, for example it does not parse key=value arguments at the end of a URL.

This type uses reference-counted internal data and copy-on-write, so copying it is cheap.

Definition at line 22 of file url.hpp.


Member Typedef Documentation

typedef std::map<std::string,std::string> s11n::io::url_parser::args_map_type

Definition at line 99 of file url.hpp.


Constructor & Destructor Documentation

s11n::io::url_parser::url_parser ( std::string const &   ) 

Parses the given URL.

good() reveals the status of the parse.

s11n::io::url_parser::url_parser (  ) 

Creates an empty (!good()) parser.

s11n::io::url_parser::~url_parser (  ) 


Member Function Documentation

url_parser& s11n::io::url_parser::operator= ( std::string const &   ) 

Functions the same as the string-argument ctor.

bool s11n::io::url_parser::good (  )  const

Returns true if the last parse() got a "valid" URL.

bool s11n::io::url_parser::parse ( std::string const &   ) 

Parses URLs of the following forms:.

scheme://[user[:password]@]host[:[port[:]]][/path/to/resource]

Note that host may have an optional ':' after it without a port number, and that a port number may be followed by an optional ':' character. This is to accommodate ssh URLs and the like:

ssh://user@host:/path

ssh://user@host:33:/path

This function returns the same as good().

If this function returns false then the contents of this objects are in an undefined state. They should not be used before a call to parse() succeeds.

std::string s11n::io::url_parser::url (  )  const

Returns the URL most recently passed to parse().

std::string s11n::io::url_parser::scheme (  )  const

Returns the scheme part of url().

std::string s11n::io::url_parser::user (  )  const

Returns the user name part of url(), which may be empty.

std::string s11n::io::url_parser::password (  )  const

Returns the user password part of url(), which may be empty.

std::string s11n::io::url_parser::host (  )  const

Returns the host part of url().

std::string s11n::io::url_parser::path (  )  const

Returns the resource path part of url(), which may be empty.

Contrary to RFC1738, a leading slash in a URL *is* considered to be part of the path.

In some protocols (e.g. http) an empty path can be considered the same as '/', but on others (e.g. file) such interpretation is not appropriate.

std::string s11n::io::url_parser::args_str (  )  const

If the URL path has a '?' in it, anything after the '?' is assumed to be a list of arguments, e.g.

as those passed to HTTP GET requests. This string does not contain the leading '?'.

args_map_type const& s11n::io::url_parser::args_map (  )  const

unsigned short s11n::io::url_parser::port (  )  const

Returns the port number part of url(), or 0 if no port was specified.


The documentation for this class was generated from the following file:
Generated on Wed Jun 4 21:44:21 2008 for libs11n by  doxygen 1.5.3