The Sword Project: sword::URL Class Reference |
#include <url.h>
Collaboration diagram for sword::URL:
Public Types | |
typedef std::map< SWBuf, SWBuf > | ParameterMap |
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 ParameterMap & | getParameters () 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 |
Definition at line 33 of file url.h.
sword::URL::URL | ( | const char * | url | ) |
Constructor.
url | The url string which should be parsed into protocol, hostname, path and paramters |
const char* sword::URL::getProtocol | ( | ) | const |
Get the protocol.
const char* sword::URL::getHostName | ( | ) | const |
Get the hostname.
const char* sword::URL::getPath | ( | ) | const |
Get the path.
const ParameterMap& sword::URL::getParameters | ( | ) | const |
All available paramters.
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&user=nobody" the value of the parameter "page" would be "test". If the parameter is not set an empty string is returned.
name | The name of the paramter. |
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&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&help=1 becomes http://www.crosswire.org/test.jsp?force=1&amp;help=1
The SWORD Project; P. O. Box 2528; Tempe, AZ 85280-2528 USA |