Gnash  0.8.10
Public Member Functions | Static Public Member Functions | Friends
gnash::URL Class Reference

Uniform Resource Locator. More...

#include <URL.h>

List of all members.

Public Member Functions

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

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.
static void encode (std::string &str)
 Encode a string to URL-encoded format converting all dodgy characters to AB hex sequences.
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.
static void decode (std::string &str)
 Decode a string from URL-encoded format converting all hexadecimal sequences to ASCII characters.

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

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

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


Member Function Documentation

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

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 parse_querystring().

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::i, and gnash::key::c.

Referenced by gnash::getURLEncodedVars(), and encode().

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().

const std::string& gnash::URL::hostname ( ) const [inline]
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().

Referenced by nsPluginInstance::threadMain().

const std::string& gnash::URL::path ( ) const [inline]
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().

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

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

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

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 nsPluginInstance::threadMain().

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

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

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

Return the full absolute URL as a string.

TODO: make output operator and operator+ for strings

Referenced by gnash::MovieFactory::makeMovie(), gnash::Player::run(), gnash::rtmp::RTMP::connect(), main(), gnash::StreamProvider::getStream(), and gnash::operator<<().


Friends And Related Function Documentation

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

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