22 URLSpec(
const string &url,
bool server_name_expected) {
23 set_url(url, server_name_expected);
42 operator = (
const string &url) {
52 operator == (
const URLSpec &other)
const {
53 return _url == other._url;
62 operator != (
const URLSpec &other)
const {
63 return !operator == (other);
72 operator < (
const URLSpec &other)
const {
73 return _url < other._url;
85 return strcmp(_url.c_str(), other._url.c_str());
96 return (_flags & F_has_scheme) != 0;
108 return (_flags & F_has_authority) != 0;
119 return (_flags & F_has_username) != 0;
130 return (_flags & F_has_server) != 0;
141 return (_flags & F_has_port) != 0;
153 return (_flags & F_has_path) != 0;
164 return (_flags & F_has_query) != 0;
176 return _url.substr(_username_start, _port_end - _username_start);
189 return _url.substr(_username_start, _username_end - _username_start);
199 return _url.substr(_server_start, _server_end - _server_start);
212 return _url.substr(_port_start, _port_end - _port_start);
223 return _url.substr(_query_start);
238 if (_url.substr(0, _scheme_end) ==
"socks") {
241 return (_url[_scheme_end - 1] ==
's');
264 operator
const string & ()
const {
273 INLINE
const char *URLSpec::
283 INLINE
bool URLSpec::
293 INLINE
size_t URLSpec::
295 return _url.length();
303 INLINE
char URLSpec::
304 operator [] (
int n)
const {
305 nassertr(n >= 0 && n < (
int)_url.length(),
'\0');
310 operator >> (istream &in,
URLSpec &url) {
311 if (!url.input(in)) {
312 in.clear(ios::failbit | in.rdstate());
318 operator << (ostream &out,
const URLSpec &url) {
bool has_query() const
Returns true if the URL includes a query specification, false otherwise.
bool has_username() const
Returns true if the URL specifies a username (and/or password), false otherwise.
A container for a URL, e.g.
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)...
string get_query() const
Returns the query specified by the URL, or empty string if no query is specified. ...
bool is_ssl() const
Returns true if the URL's scheme specifies an SSL-secured protocol such as https, or false otherwise...
string get_port_str() const
Returns the port specified by the URL as a string, or the empty string if no port is specified...
bool has_server() const
Returns true if the URL specifies a server name, false otherwise.
const string & get_url() const
Returns the complete URL specification.
string get_server() const
Returns the server name specified by the URL, if any.
string get_username() const
Returns the username specified by the URL, if any.
string get_authority() const
Returns the authority specified by the URL (this includes username, server, and/or port)...
bool has_path() const
Returns true if the URL includes a path specification (that is, the particular filename on the server...
void set_url(const string &url, bool server_name_expected=false)
Completely replaces the URL with the indicated string.
bool has_port() const
Returns true if the URL specifies a port number, false otherwise.
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 s...