sword::URL Class Reference

URL provides URL parsing The URL class provides an interface to work on the data of an URL like "http://www.crosswire.org/index.jsp?page=test&user=nobody". More...

#include <url.h>

Collaboration diagram for sword::URL:

Collaboration graph
[legend]
List of all members.

Public Types

typedef std::map< SWBuf, SWBufParameterMap

Public Member Functions

 URL (const char *url)
 Constructor.
const char * getProtocol () const
 Get the protocol.
const char * getHostName () const
 Get the hostname.
const char * getPath () const
 Get the path.
const ParameterMapgetParameters () const
 All available paramters.
const char * getParameterValue (const char *name) const
 Returns the value of an URL parameter.

Static Public Member Functions

static const SWBuf encode (const char *urlText)
 Encodes and URL Encodes a string into a valid URL, e.g.
static const SWBuf decode (const char *encodedText)

Private Member Functions

void parse ()
 Parse Parse the URL into protocol, hostname, path, page and paramters.

Private Attributes

SWBuf url
SWBuf protocol
SWBuf hostname
SWBuf path
ParameterMap parameterMap

Detailed Description

URL provides URL parsing The URL class provides an interface to work on the data of an URL like "http://www.crosswire.org/index.jsp?page=test&amp;user=nobody".

Definition at line 33 of file url.h.


Constructor & Destructor Documentation

sword::URL::URL ( const char *  url  ) 

Constructor.

Parameters:
url The url string which should be parsed into protocol, hostname, path and paramters


Member Function Documentation

const char* sword::URL::getProtocol (  )  const

Get the protocol.

Returns:
The protocol, e.g. "http" for an url like "http://www.crosswire.org/index.jsp?page=help"

const char* sword::URL::getHostName (  )  const

Get the hostname.

Returns:
The hostname, e.g. "www.crosswire.org" for an url like "http://www.crosswire.org/index.jsp?page=help"

const char* sword::URL::getPath (  )  const

Get the path.

Returns:
The path, e.g. "/index.jsp" for an url like "http://www.crosswire.org/index.jsp?page=help"

const ParameterMap& sword::URL::getParameters (  )  const

All available paramters.

Returns:
The map which contains the parameters and their values

const char* sword::URL::getParameterValue ( const char *  name  )  const

Returns the value of an URL parameter.

For the URL "http://www.crosswire.org/index.jsp?page=test&amp;user=nobody" the value of the parameter "page" would be "test". If the parameter is not set an empty string is returned.

Parameters:
name The name of the paramter.
Returns:
The value of the given paramter of an empty string if the name could not be found in the list of available paramters

static const SWBuf sword::URL::encode ( const char *  urlText  )  [static]

Encodes and URL Encodes a string into a valid URL, e.g.

changes http://www.crosswire.org/test.jsp?force=1&help=1 into http://www.crosswire.org/test.jsp?force=1&amp;help=1 This function works on the data of the buf parameter.

WARNING: It doesn't check if the URL is encoded already, so http://www.crosswire.org/test.jsp?force=1&amp;help=1 becomes http://www.crosswire.org/test.jsp?force=1&amp;amp;help=1


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