libcommonc++  0.7
URL Class Reference

A class representing a URL (Uniform Resource Locator). More...

#include <URL.h++>

Public Member Functions

 URL ()
 Construct a new, empty URL. More...
 
 URL (const String &url)
 Construct a new URL for the given URL string. More...
 
 URL (const URL &other)
 Copy constructor. More...
 
 ~URL ()
 Destructor. More...
 
void setScheme (const String &scheme)
 Set the scheme component of the URL. More...
 
String getScheme () const
 Get the scheme component of the URL. More...
 
void setHost (const String &host)
 Set the hostname component of the URL. More...
 
String getHost () const
 Get the hostname component of the URL. More...
 
void setPort (uint16_t port)
 Set the port number for the URL. More...
 
uint16_t getPort () const
 Get the port number for the URL. More...
 
void setPath (const String &path)
 Set the path component of the URL. More...
 
String getPath () const
 Get the path component of the URL. More...
 
String getCanonicalPath () const
 Get the path component of the URL, in canonicalized form. More...
 
void setQuery (const String &query)
 Set the query component of the URL. More...
 
String getQuery () const
 Get the query component of the URL. More...
 
bool isValid () const
 Test if the URL is valid. More...
 
String toString () const
 Get a String representation of the URL. More...
 
bool operator== (const URL &other) const
 Equality operator. More...
 
bool operator!= (const URL &other) const
 Inequality operator. More...
 
URLoperator= (const String &other)
 Assignment operator. More...
 
URLoperator= (const URL &other)
 Assignment operator. More...
 

Static Public Member Functions

static String encode (const String &str)
 URL-encode a String. More...
 
static String decode (const String &str)
 Decode a URL-encoded String. More...
 

Detailed Description

A class representing a URL (Uniform Resource Locator).

This class will parse simple, common URLs, but is not a fully-conformant URL parser.

Author
Mark Lindner

Constructor & Destructor Documentation

◆ URL() [1/3]

URL ( )

Construct a new, empty URL.

◆ URL() [2/3]

URL ( const String url)

Construct a new URL for the given URL string.

◆ URL() [3/3]

URL ( const URL other)

Copy constructor.

◆ ~URL()

~URL ( )

Destructor.

Member Function Documentation

◆ decode()

String decode ( const String str)
static

Decode a URL-encoded String.

Parameters
strThe string to decode.
Returns
THe decoded form.

◆ encode()

String encode ( const String str)
static

URL-encode a String.

Parameters
strThe string to encode.
Returns
The encoded form.

◆ getCanonicalPath()

String getCanonicalPath ( ) const
inline

Get the path component of the URL, in canonicalized form.

◆ getHost()

String getHost ( ) const
inline

Get the hostname component of the URL.

◆ getPath()

String getPath ( ) const
inline

Get the path component of the URL.

◆ getPort()

uint16_t getPort ( ) const
inline

Get the port number for the URL.

Returns 0 if no port number was specified.

◆ getQuery()

String getQuery ( ) const
inline

Get the query component of the URL.

Returns
The query, in its original, URL-encoded form.

◆ getScheme()

String getScheme ( ) const
inline

Get the scheme component of the URL.

◆ isValid()

bool isValid ( ) const

Test if the URL is valid.

◆ operator!=()

bool operator!= ( const URL other) const
inline

Inequality operator.

◆ operator=() [1/2]

URL & operator= ( const String other)

Assignment operator.

◆ operator=() [2/2]

URL & operator= ( const URL other)

Assignment operator.

◆ operator==()

bool operator== ( const URL other) const

Equality operator.

◆ setHost()

void setHost ( const String host)
inline

Set the hostname component of the URL.

◆ setPath()

void setPath ( const String path)

Set the path component of the URL.

◆ setPort()

void setPort ( uint16_t  port)
inline

Set the port number for the URL.

A value of 0 indicates no port number.

◆ setQuery()

void setQuery ( const String query)
inline

Set the query component of the URL.

Parameters
queryThe query, in URL-encoded form.

◆ setScheme()

void setScheme ( const String scheme)
inline

Set the scheme component of the URL.

◆ toString()

String toString ( ) const

Get a String representation of the URL.


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