#include <urlSpec.h>
Public Member Functions | |
URLSpec () | |
URLSpec (const string &url, bool server_name_expected=false) | |
URLSpec (const URLSpec ©) | |
void | operator= (const string &url) |
void | operator= (const URLSpec ©) |
bool | operator== (const URLSpec &other) const |
bool | operator!= (const URLSpec &other) const |
bool | operator< (const URLSpec &other) const |
int | compare_to (const URLSpec &other) const |
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. | |
bool | has_scheme () const |
Returns true if the URL specifies a scheme (e.g. | |
bool | has_authority () const |
Returns true if the URL specifies an authority (this includes username, server, and/or port), false otherwise. | |
bool | has_username () const |
Returns true if the URL specifies a username (and/or password), false otherwise. | |
bool | has_server () const |
Returns true if the URL specifies a server name, false otherwise. | |
bool | has_port () const |
Returns true if the URL specifies a port number, false otherwise. | |
bool | has_path () const |
Returns true if the URL includes a path specification (that is, the particular filename on the server to retrieve), false otherwise. | |
bool | has_query () const |
Returns true if the URL includes a query specification, false otherwise. | |
string | get_scheme () const |
Returns the scheme specified by the URL, or empty string if no scheme is specified. | |
string | get_authority () const |
Returns the authority specified by the URL (this includes username, server, and/or port), or empty string if no authority is specified. | |
string | get_username () const |
Returns the username specified by the URL, if any. | |
string | get_server () const |
Returns the server name specified by the URL, if any. | |
string | get_port_str () const |
Returns the port specified by the URL as a string, or the empty string if no port is specified. | |
int | get_port () const |
Returns the port number specified by the URL, or the default port if not specified. | |
string | get_server_and_port () const |
Returns a string consisting of the server name, followed by a colon, followed by the port number. | |
string | get_path () const |
Returns the path specified by the URL, or "/" if no path is specified. | |
string | get_query () const |
Returns the query specified by the URL, or empty string if no query is specified. | |
const string & | get_url () const |
Returns the complete URL specification. | |
void | set_scheme (const string &scheme) |
Replaces the scheme part of the URL specification. | |
void | set_authority (const string &authority) |
Replaces the authority part of the URL specification. | |
void | set_username (const string &username) |
Replaces the username part of the URL specification. | |
void | set_server (const string &server) |
Replaces the server part of the URL specification. | |
void | set_port (const string &port) |
Replaces the port part of the URL specification. | |
void | set_port (int port) |
Replaces the port part of the URL specification, given a numeric port number. | |
void | set_server_and_port (const string &server_and_port) |
Replaces the server and port parts of the URL specification simultaneously. | |
void | set_path (const string &path) |
Replaces the path part of the URL specification. | |
void | set_query (const string &query) |
Replaces the query part of the URL specification. | |
void | set_url (const string &url, bool server_name_expected=false) |
Completely replaces the URL with the indicated string. | |
operator const string & () const | |
const char * | c_str () const |
bool | empty () const |
size_t | length () const |
char | operator[] (int n) const |
bool | input (istream &in) |
void | output (ostream &out) const |
Static Public Member Functions | |
string | quote (const string &source, const string &safe="/") |
Returns the source string with all "unsafe" characters quoted, making a string suitable for placing in a URL. | |
string | quote_plus (const string &source, const string &safe="/") |
Behaves like quote() with the additional behavior of replacing spaces with plus signs. | |
string | unquote (const string &source) |
Reverses the operation of quote(): converts escaped characters of the form "%xx" to their ascii equivalent. | |
string | unquote_plus (const 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. | |
Private Types | |
enum | Flags { F_has_scheme = 0x0001, F_has_authority = 0x0002, F_has_username = 0x0004, F_has_server = 0x0008, F_has_port = 0x0010, F_has_path = 0x0020, F_has_query = 0x0040 } |
Private Member Functions | |
void | parse_authority () |
Assumes _url[_username_start .. | |
Private Attributes | |
string | _url |
int | _port |
int | _flags |
size_t | _scheme_end |
size_t | _username_start |
size_t | _username_end |
size_t | _server_start |
size_t | _server_end |
size_t | _port_start |
size_t | _port_end |
size_t | _path_start |
size_t | _path_end |
size_t | _query_start |
"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.
Definition at line 43 of file urlSpec.h.
|
|
|
Definition at line 35 of file urlSpec.cxx. |
|
Definition at line 31 of file urlSpec.I. References INLINE. |
|
|
|
|
|
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.
Definition at line 108 of file urlSpec.I. References _flags, F_has_authority, and INLINE. |
|
|
|
Returns the authority specified by the URL (this includes username, server, and/or port), or empty string if no authority is specified.
|
|
Returns the path specified by the URL, or "/" if no path is specified.
Definition at line 151 of file urlSpec.cxx. |
|
Returns the port number specified by the URL, or the default port if not specified.
Definition at line 103 of file urlSpec.cxx. References _port_end, _server_start, _url, get_server(), has_port(), and ostringstream::str(). |
|
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. |
|
Returns the query specified by the URL, or empty string if no query is specified.
Definition at line 300 of file urlSpec.I. References url. |
|
Returns the scheme specified by the URL, or empty string if no scheme is specified.
Definition at line 85 of file urlSpec.cxx. References _port, and has_port(). |
|
Returns the server name specified by the URL, if any.
Definition at line 266 of file urlSpec.I. References _url. Referenced by get_port(). |
|
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. Definition at line 131 of file urlSpec.cxx. |
|
Returns the complete URL specification.
|
|
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. Definition at line 253 of file urlSpec.I. Referenced by set_port(). |
|
Returns true if the URL specifies an authority (this includes username, server, and/or port), false otherwise.
Definition at line 140 of file urlSpec.I. References _flags, F_has_port, and INLINE. Referenced by set_port(). |
|
Returns true if the URL includes a path specification (that is, the particular filename on the server to retrieve), false otherwise.
Definition at line 202 of file urlSpec.I. References _server_end, _server_start, and _url. |
|
Returns true if the URL specifies a port number, false otherwise.
Definition at line 185 of file urlSpec.I. References _url, _username_end, _username_start, and INLINE. Referenced by get_port(), and get_scheme(). |
|
Returns true if the URL includes a query specification, false otherwise.
|
|
Returns true if the URL specifies a scheme (e.g. "http:"), false otherwise. Definition at line 123 of file urlSpec.I. References _flags, and F_has_username. |
|
Returns true if the URL specifies a server name, false otherwise.
Definition at line 170 of file urlSpec.I. References _port_end, _url, _username_start, and INLINE. |
|
Returns true if the URL specifies a username (and/or password), false otherwise.
Definition at line 155 of file urlSpec.I. References _flags, F_has_path, and INLINE. Referenced by set_port(). |
|
Definition at line 633 of file urlSpec.cxx. |
|
|
|
|
|
|
|
Definition at line 91 of file urlSpec.I. References _flags, F_has_scheme, and INLINE. |
|
Definition at line 58 of file urlSpec.cxx. References _path_end, _path_start, _port_end, _port_start, _query_start, _server_end, and _server_start. |
|
|
|
|
|
|
|
Definition at line 652 of file urlSpec.cxx. |
|
Assumes _url[_username_start .. _port_end - 1] is the authority component if the URL, consisting of [username@]server[:port]. Parses out the three pieces and updates the various _start and _end parameters accordingly. Definition at line 867 of file urlSpec.cxx. Referenced by set_url(). |
|
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. Definition at line 677 of file urlSpec.cxx. References size_t. |
|
Behaves like quote() with the additional behavior of replacing spaces with plus signs.
Definition at line 722 of file urlSpec.cxx. References size_t. |
|
Replaces the authority part of the URL specification. This includes the username, server, and port. Definition at line 242 of file urlSpec.cxx. Referenced by set_port(). |
|
Replaces the path part of the URL specification.
Definition at line 426 of file urlSpec.cxx. References _flags, and F_has_query. |
|
Replaces the port part of the URL specification, given a numeric port number.
Definition at line 383 of file urlSpec.cxx. |
|
Replaces the port part of the URL specification.
Definition at line 353 of file urlSpec.cxx. References get_username(), has_authority(), has_username(), and set_authority(). |
|
Replaces the query part of the URL specification.
Definition at line 475 of file urlSpec.cxx. References _flags, _scheme_end, _url, F_has_scheme, and size_t. |
|
Replaces the scheme part of the URL specification.
Definition at line 167 of file urlSpec.cxx. |
|
Replaces the server part of the URL specification.
Definition at line 326 of file urlSpec.cxx. |
|
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. Definition at line 404 of file urlSpec.cxx. References _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. Definition at line 512 of file urlSpec.cxx. References _flags, _port_end, _url, _username_start, F_has_authority, and parse_authority(). Referenced by URLSpec(). |
|
Replaces the username part of the URL specification.
Definition at line 299 of file urlSpec.cxx. |
|
Reverses the operation of quote(): converts escaped characters of the form "%xx" to their ascii equivalent.
Definition at line 773 of file urlSpec.cxx. |
|
Reverses the operation of quote_plus(): converts escaped characters of the form "%xx" to their ascii equivalent, and also converts plus signs to spaces.
Definition at line 816 of file urlSpec.cxx. References _path_end, _path_start, _port_start, _query_start, and _server_end. |
|
Definition at line 117 of file urlSpec.h. Referenced by compare_to(), has_authority(), has_scheme(), has_username(), operator<(), set_path(), set_query(), and set_url(). |
|
Definition at line 127 of file urlSpec.h. Referenced by operator=(), and unquote_plus(). |
|
Definition at line 126 of file urlSpec.h. Referenced by operator=(), and unquote_plus(). |
|
Definition at line 116 of file urlSpec.h. Referenced by get_scheme(). |
|
Definition at line 125 of file urlSpec.h. Referenced by get_port(), has_server(), operator=(), and set_url(). |
|
Definition at line 124 of file urlSpec.h. Referenced by operator=(), and unquote_plus(). |
|
Definition at line 128 of file urlSpec.h. Referenced by operator=(), and unquote_plus(). |
|
Definition at line 119 of file urlSpec.h. Referenced by set_query(). |
|
Definition at line 123 of file urlSpec.h. Referenced by has_path(), operator=(), and unquote_plus(). |
|
Definition at line 122 of file urlSpec.h. Referenced by get_port(), has_path(), and operator=(). |
|
Definition at line 115 of file urlSpec.h. Referenced by get_authority(), get_port(), get_port_str(), get_server(), get_username(), has_path(), has_port(), has_server(), operator!=(), operator=(), set_query(), set_server_and_port(), and set_url(). |
|
Definition at line 121 of file urlSpec.h. Referenced by has_port(). |
|
Definition at line 120 of file urlSpec.h. Referenced by has_port(), has_server(), and set_url(). |