Gnash  0.8.11dev
Public Member Functions | Static Public Member Functions | Friends | List of all members
gnash::URL Class Reference

Uniform Resource Locator. More...

#include <URL.h>

Public Member Functions

 URL (const std::string &absolute_url)
 Construct an URL from the given absolute url string. More...
 
 URL (const std::string &relative_url, const URL &baseurl)
 
const std::string & protocol () const
 Return the 'protocol' member of this URL, as a string. More...
 
const std::string & hostname () const
 Return the 'hostname' member of this URL, as a string. More...
 
const std::string & port () const
 Return the 'port' member of this URL, as a string. More...
 
const std::string & path () const
 Return the 'path' member of this URL, as a string. More...
 
const std::string & anchor () const
 Return the 'anchor' member of this URL, as a string. More...
 
const std::string & querystring () const
 Return the 'querystring' member of this URL, as a string. More...
 
void set_querystring (const std::string &value)
 Set the 'querystring' member of this URL to a new value. More...
 
std::string str () const
 Return the full absolute URL as a string. More...
 

Static Public Member Functions

static void parse_querystring (const std::string &query_string, std::map< std::string, std::string > &target_map)
 Parse a query string filling the provided map. More...
 
static void encode (std::string &str)
 Encode a string to URL-encoded format converting all dodgy characters to AB hex sequences. More...
 
static std::string encode (const std::string &str)
 Encode a string to URL-encoded format converting all dodgy characters to AB hex sequences. This merely uses the void encode() function on a new string. More...
 
static void decode (std::string &str)
 Decode a string from URL-encoded format converting all hexadecimal sequences to ASCII characters. More...
 

Friends

std::ostream & operator<< (std::ostream &o, const URL &u)
 

Detailed Description

Uniform Resource Locator.

This class is used to manage URLs.

Constructor & Destructor Documentation

§ URL() [1/2]

gnash::URL::URL ( const std::string &  absolute_url)

Construct an URL from the given absolute url string.

A relative URL will be considered a filesystem path relative to the current working directory.

Throws std::runtime_error on error

References gnash::key::i.

§ URL() [2/2]

gnash::URL::URL ( const std::string &  relative_url,
const URL baseurl 
)

Construct an URL from the given relative url string, using the given URL for resolving it. Throws std::runtime_error on error

References gnash::key::e, gnash::key::i, and path().

Member Function Documentation

§ anchor()

const std::string& gnash::URL::anchor ( ) const
inline

Return the 'anchor' member of this URL, as a string.

The anchor is the string after the '#' character

§ decode()

void gnash::URL::decode ( std::string &  str)
static

Decode a string from URL-encoded format converting all hexadecimal sequences to ASCII characters.

A sequence to convert is % followed by two case-independent hexadecimal digits, which is replaced by the equivalent ASCII character. See RFC1738 http://www.rfc-editor.org/rfc/rfc1738.txt, Section 2.2 "URL Character Encoding Issues"

Parameters
strThe input/output string

References gnash::key::i.

Referenced by gnash::Global_as::makeObject(), and parse_querystring().

§ encode() [1/2]

void gnash::URL::encode ( std::string &  str)
static

Encode a string to URL-encoded format converting all dodgy characters to AB hex sequences.

Characters that need escaping are:

  • ASCII control characters: 0-31 and 127
  • Non-ASCII chars: 128-255
  • URL syntax characters: $ & + , / : ; = ? @
  • Unsafe characters: SPACE " < > # % { } | \ ^ ~ [ ] ` Encoding is a % followed by two hexadecimal characters, case insensitive. See RFC1738 http://www.rfc-editor.org/rfc/rfc1738.txt, Section 2.2 "URL Character Encoding Issues"
Parameters
strThe input/output string

References gnash::key::c, and gnash::key::i.

Referenced by encode(), gnash::getURLEncodedVars(), gnash::Global_as::makeObject(), and gnash::registerSystemNative().

§ encode() [2/2]

std::string gnash::URL::encode ( const std::string &  str)
static

Encode a string to URL-encoded format converting all dodgy characters to AB hex sequences. This merely uses the void encode() function on a new string.

@ param str The input string @ return An encoded version of the input string

References encode().

§ hostname()

const std::string& gnash::URL::hostname ( ) const
inline

§ parse_querystring()

void gnash::URL::parse_querystring ( const std::string &  query_string,
std::map< std::string, std::string > &  target_map 
)
static

Parse a query string filling the provided map.

Parameters
query_stringthe url-escaped query string (can include or not the starting question mark)
target_mapA standard map to put parsed values into. Note: existing elements of the map will be replaced.
Todo:
url-unescape names and values
Todo:
supports duplicated keys (var=value1&var=value2)

References decode(), and name.

Referenced by gnash::MovieLoader::clear().

§ path()

const std::string& gnash::URL::path ( ) const
inline

§ port()

const std::string& gnash::URL::port ( ) const
inline

Return the 'port' member of this URL, as a string.

NOTE: return the empty string if the port isn't specified, as this is an optional field.

Referenced by gnash::rtmp::RTMP::connect().

§ protocol()

const std::string& gnash::URL::protocol ( ) const
inline

Return the 'protocol' member of this URL, as a string.

Referenced by gnash::URLAccessManager::allow(), gnash::StreamProvider::getStream(), and gnash::Player::setScale().

§ querystring()

const std::string& gnash::URL::querystring ( ) const
inline

Return the 'querystring' member of this URL, as a string.

The query is the string after the '?' character

Referenced by gnash::MovieLoader::clear().

§ set_querystring()

void gnash::URL::set_querystring ( const std::string &  value)
inline

Set the 'querystring' member of this URL to a new value.

References path.

§ str()

std::string gnash::URL::str ( ) const

Friends And Related Function Documentation

§ operator<<

std::ostream& operator<< ( std::ostream &  o,
const URL u 
)
friend

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