A container for a URL, e.g. More...
Public Member Functions | |
URLSpec () | |
URLSpec (URLSpec const copy) | |
URLSpec (string url, bool server_name_expected) | |
URLSpec (string url) | |
int | compareTo (URLSpec const other) |
Returns a number less than zero if this URLSpec sorts before the other one, greater than zero if it sorts after, or zero if they are equivalent. | |
string | cStr () |
bool | empty () |
string | getAuthority () |
Returns the authority specified by the URL (this includes username, server, and/or port), or empty string if no authority is specified. | |
string | getPath () |
Returns the path specified by the URL, or "/" if no path is specified. | |
string | getPathAndQuery () |
Returns the path (or "/" if no path is specified), followed by the query if it is specified. | |
int | getPort () |
Returns the port number specified by the URL, or the default port if not specified. | |
string | getPortStr () |
Returns the port specified by the URL as a string, or the empty string if no port is specified. | |
string | getQuery () |
Returns the query specified by the URL, or empty string if no query is specified. | |
string | getScheme () |
Returns the scheme specified by the URL, or empty string if no scheme is specified. | |
string | getServer () |
Returns the server name specified by the URL, if any. | |
string | getServerAndPort () |
Returns a string consisting of the server name, followed by a colon, followed by the port number. | |
string | getUrl () |
Returns the complete URL specification. | |
string | getUsername () |
Returns the username specified by the URL, if any. | |
bool | hasAuthority () |
Returns true if the URL specifies an authority (this includes username, server, and/or port), false otherwise. | |
bool | hasPath () |
Returns true if the URL includes a path specification (that is, the particular filename on the server to retrieve), false otherwise. | |
bool | hasPort () |
Returns true if the URL specifies a port number, false otherwise. | |
bool | hasQuery () |
Returns true if the URL includes a query specification, false otherwise. | |
bool | hasScheme () |
Returns true if the URL specifies a scheme (e.g. | |
bool | hasServer () |
Returns true if the URL specifies a server name, false otherwise. | |
bool | hasUsername () |
Returns true if the URL specifies a username (and/or password), false otherwise. | |
bool | input (istream in) |
bool | isDefaultPort () |
Returns true if the port number encoded in this URL is the default port number for the scheme (or if there is no port number), or false if it is a nonstandard port. | |
bool | isSsl () |
Returns true if the URL's scheme specifies an SSL-secured protocol such as https, or false otherwise. | |
unsigned int | length () |
bool | operator!= (URLSpec const other) |
bool | operator< (URLSpec const other) |
URLSpec | operator= (URLSpec const copy) |
URLSpec | operator= (string url) |
bool | operator== (URLSpec const other) |
char | operator[] (int n) |
output (ostream out) | |
setAuthority (string authority) | |
Replaces the authority part of the URL specification. | |
setPath (string path) | |
Replaces the path part of the URL specification. | |
setPort (string port) | |
Replaces the port part of the URL specification. | |
setPort (int port) | |
Replaces the port part of the URL specification, given a numeric port number. | |
setQuery (string query) | |
Replaces the query part of the URL specification. | |
setScheme (string scheme) | |
Replaces the scheme part of the URL specification. | |
setServer (string server) | |
Replaces the server part of the URL specification. | |
setServerAndPort (string server_and_port) | |
Replaces the server and port parts of the URL specification simultaneously. | |
setUrl (string url, bool server_name_expected) | |
Completely replaces the URL with the indicated string. | |
setUrl (string url) | |
Completely replaces the URL with the indicated string. | |
setUsername (string username) | |
Replaces the username part of the URL specification. | |
Static Public Member Functions | |
static int | getDefaultPortForScheme (string scheme) |
Returns the default port number for the indicated scheme, or 0 if there is no known default. | |
static string | quote (string source, string safe) |
Returns the source string with all "unsafe" characters quoted, making a string suitable for placing in a URL. | |
static string | quote (string source) |
Returns the source string with all "unsafe" characters quoted, making a string suitable for placing in a URL. | |
static string | quotePlus (string source, string safe) |
Behaves like quote() with the additional behavior of replacing spaces with plus signs. | |
static string | quotePlus (string source) |
Behaves like quote() with the additional behavior of replacing spaces with plus signs. | |
static string | unquote (string source) |
Reverses the operation of quote(): converts escaped characters of the form "%xx" to their ascii equivalent. | |
static string | unquotePlus (string source) |
Reverses the operation of quote_plus(): converts escaped characters of the form "%xx" to their ascii equivalent, and also converts plus signs to spaces. |
A container for a URL, e.g.
"http://server:port/path".
The URLSpec object is similar to a Filename in that it contains logic to identify the various parts of a URL and return (or modify) them separately.
URLSpec | ( | ) |
URLSpec | ( | string | url, |
bool | server_name_expected | ||
) |
URLSpec | ( | string | url | ) |
Returns a number less than zero if this URLSpec sorts before the other one, greater than zero if it sorts after, or zero if they are equivalent.
string cStr | ( | ) |
bool empty | ( | ) |
string getAuthority | ( | ) |
Returns the authority specified by the URL (this includes username, server, and/or port), or empty string if no authority is specified.
static int getDefaultPortForScheme | ( | string | scheme | ) | [static] |
Returns the default port number for the indicated scheme, or 0 if there is no known default.
string getPath | ( | ) |
Returns the path specified by the URL, or "/" if no path is specified.
string getPathAndQuery | ( | ) |
Returns the path (or "/" if no path is specified), followed by the query if it is specified.
string getPortStr | ( | ) |
Returns the port specified by the URL as a string, or the empty string if no port is specified.
Compare this with get_port(), which returns a default port number if no port is specified.
string getQuery | ( | ) |
Returns the query specified by the URL, or empty string if no query is specified.
string getScheme | ( | ) |
Returns the scheme specified by the URL, or empty string if no scheme is specified.
string getServer | ( | ) |
Returns the server name specified by the URL, if any.
string getServerAndPort | ( | ) |
Returns a string consisting of the server name, followed by a colon, followed by the port number.
If the port number is not explicitly given in the URL, this string will include the implicit port number.
string getUrl | ( | ) |
Returns the complete URL specification.
string getUsername | ( | ) |
Returns the username specified by the URL, if any.
This might also include a password, e.g. "username:password", although putting a password on the URL is probably a bad idea.
bool hasAuthority | ( | ) |
Returns true if the URL specifies an authority (this includes username, server, and/or port), false otherwise.
bool hasPath | ( | ) |
Returns true if the URL includes a path specification (that is, the particular filename on the server to retrieve), false otherwise.
bool hasPort | ( | ) |
Returns true if the URL specifies a port number, false otherwise.
bool hasQuery | ( | ) |
Returns true if the URL includes a query specification, false otherwise.
bool hasScheme | ( | ) |
Returns true if the URL specifies a scheme (e.g.
"http:"), false otherwise.
bool hasServer | ( | ) |
Returns true if the URL specifies a server name, false otherwise.
bool hasUsername | ( | ) |
Returns true if the URL specifies a username (and/or password), false otherwise.
bool isDefaultPort | ( | ) |
Returns true if the port number encoded in this URL is the default port number for the scheme (or if there is no port number), or false if it is a nonstandard port.
bool isSsl | ( | ) |
Returns true if the URL's scheme specifies an SSL-secured protocol such as https, or false otherwise.
bool operator!= | ( | URLSpec const | other | ) |
bool operator< | ( | URLSpec const | other | ) |
URLSpec operator= | ( | string | url | ) |
bool operator== | ( | URLSpec const | other | ) |
static string quote | ( | string | source, |
string | safe | ||
) | [static] |
Returns the source string with all "unsafe" characters quoted, making a string suitable for placing in a URL.
Letters, digits, and the underscore, comma, period, and hyphen characters, as well as any included in the safe string, are left alone; all others are converted to hex representation.
static string quote | ( | string | source | ) | [static] |
Returns the source string with all "unsafe" characters quoted, making a string suitable for placing in a URL.
Letters, digits, and the underscore, comma, period, and hyphen characters, as well as any included in the safe string, are left alone; all others are converted to hex representation.
static string quotePlus | ( | string | source, |
string | safe | ||
) | [static] |
Behaves like quote() with the additional behavior of replacing spaces with plus signs.
static string quotePlus | ( | string | source | ) | [static] |
Behaves like quote() with the additional behavior of replacing spaces with plus signs.
setAuthority | ( | string | authority | ) |
Replaces the authority part of the URL specification.
This includes the username, server, and port.
setPath | ( | string | path | ) |
Replaces the path part of the URL specification.
setPort | ( | string | port | ) |
Replaces the port part of the URL specification.
setQuery | ( | string | query | ) |
Replaces the query part of the URL specification.
setScheme | ( | string | scheme | ) |
Replaces the scheme part of the URL specification.
setServer | ( | string | server | ) |
Replaces the server part of the URL specification.
setServerAndPort | ( | string | server_and_port | ) |
Replaces the server and port parts of the URL specification simultaneously.
The input string should be of the form "server:port", or just "server" to make the port number implicit.
setUrl | ( | string | url, |
bool | server_name_expected | ||
) |
Completely replaces the URL with the indicated string.
If server_name_expected is true, it is a hint that an undecorated URL is probably a server name, not a local filename.
setUrl | ( | string | url | ) |
Completely replaces the URL with the indicated string.
If server_name_expected is true, it is a hint that an undecorated URL is probably a server name, not a local filename.
setUsername | ( | string | username | ) |
Replaces the username part of the URL specification.
static string unquote | ( | string | source | ) | [static] |
Reverses the operation of quote(): converts escaped characters of the form "%xx" to their ascii equivalent.
static string unquotePlus | ( | string | source | ) | [static] |
Reverses the operation of quote_plus(): converts escaped characters of the form "%xx" to their ascii equivalent, and also converts plus signs to spaces.