Scopira
20080306
|
#include <url.h>
Public Member Functions | |
url (void) | |
url (const std::string &fullurl) | |
url (const std::string &hostname, int port) | |
url (const std::string &proto, const std::string &hostname, int port, const std::string &filename) | |
~url () | |
bool | load (scopira::tool::itflow_i &in) |
void | save (scopira::tool::otflow_i &out) const |
void | clear_url (void) |
bool | set_url (const std::string &fullurl) |
void | set_url (const std::string &hostname, int port) |
void | set_url (const std::string &proto, const std::string &hostname, int port, const std::string &filename) |
const std::string & | get_url (void) const |
std::string | get_proto (void) const |
std::string | get_hostname (void) const |
int | get_port (void) const |
std::string | get_filename (void) const |
Protected Attributes | |
std::string | dm_full |
the full url | |
std::string::size_type | dm_proto_begin |
protocol (never empty) | |
std::string::size_type | dm_proto_end |
std::string::size_type | dm_host_begin |
hostname (may be empty) | |
std::string::size_type | dm_host_end |
int | dm_port |
port (0 for non explicitly provided) | |
std::string::size_type | dm_file_begin |
filename (after the directory path) | |
std::string::size_type | dm_file_end |
A web-like URL (uniform resource locator) class. This class represents one URL and allows access to its various components.
The components are: protocol://hostname:port/filename port will not include the : (how can it, it's an integer) filename will contain the leading /, however. filename definatly may be empty-string
scopira::tool::url::url | ( | void | ) |
Empty url constructor.
scopira::tool::url::url | ( | const std::string & | fullurl | ) |
Constructs a url from the given url string. This version is only intended for string literals – strings where you know the url is of the valid form. If the url may be malformed, use the empty contrustor and use the set_url call.
scopira::tool::url::url | ( | const std::string & | hostname, |
int | port | ||
) |
Constructs a url for the the host and port. The protocol will be "scopira"
scopira::tool::url::url | ( | const std::string & | proto, |
const std::string & | hostname, | ||
int | port, | ||
const std::string & | filename | ||
) |
Constructs a url by components.
scopira::tool::url::~url | ( | ) |
Simple Destructor
void scopira::tool::url::clear_url | ( | void | ) |
Clears the url
std::string scopira::tool::url::get_filename | ( | void | ) | const |
Gets the filename segment
Referenced by get_port().
std::string scopira::tool::url::get_hostname | ( | void | ) | const |
Gets the hostname segment
Referenced by get_url().
|
inline |
Gets the port. If the url doesn't have an explicit port specified, then this will be 0.
References dm_port, and get_filename().
std::string scopira::tool::url::get_proto | ( | void | ) | const |
Gets the protocol segment
Referenced by get_url().
|
inline |
Gets the full url
References dm_full, get_hostname(), and get_proto().
bool scopira::tool::url::load | ( | scopira::tool::itflow_i & | in | ) |
Useful when part of other objects that are serializable.
void scopira::tool::url::save | ( | scopira::tool::otflow_i & | out | ) | const |
Useful when part of other objects that are serializable.
bool scopira::tool::url::set_url | ( | const std::string & | fullurl | ) |
Sets the url from a full url string. Returns true on successully parse.
void scopira::tool::url::set_url | ( | const std::string & | hostname, |
int | port | ||
) |
Sets the url by host and port. The protocol will be "scopira"
void scopira::tool::url::set_url | ( | const std::string & | proto, |
const std::string & | hostname, | ||
int | port, | ||
const std::string & | filename | ||
) |
Sets the url by components