Go to the documentation of this file.
18 URLSpec(
const std::string &url,
bool server_name_expected) {
19 set_url(url, server_name_expected);
26 operator = (
const std::string &url) {
34 operator == (
const URLSpec &other)
const {
42 operator != (
const URLSpec &other)
const {
50 operator < (
const URLSpec &other)
const {
60 return (_flags & F_has_scheme) != 0;
69 return (_flags & F_has_authority) != 0;
78 return (_flags & F_has_username) != 0;
86 return (_flags & F_has_server) != 0;
94 return (_flags & F_has_port) != 0;
103 return (_flags & F_has_path) != 0;
111 return (_flags & F_has_query) != 0;
120 return _url.substr(_username_start, _port_end - _username_start);
130 return _url.substr(_username_start, _username_end - _username_start);
139 return _url.substr(_server_start, _server_end - _server_start);
149 return _url.substr(_port_start, _port_end - _port_start);
158 return _url.substr(_query_start);
170 if (_url.substr(0, _scheme_end) ==
"socks") {
173 return (_url[_scheme_end - 1] ==
's');
192 operator
const std::string & ()
const {
199 INLINE
const char *URLSpec::
218 operator bool()
const {
219 return !_url.empty();
225 INLINE
size_t URLSpec::
227 return _url.length();
233 INLINE
size_t URLSpec::
241 INLINE
char URLSpec::
242 operator [] (
size_t n)
const {
243 nassertr(n < _url.length(),
'\0');
247 INLINE std::istream &
248 operator >> (std::istream &in,
URLSpec &url) {
249 if (!url.input(in)) {
250 in.clear(std::ios::failbit | in.rdstate());
255 INLINE std::ostream &
256 operator << (std::ostream &out,
const URLSpec &url) {
A container for a URL, e.g.
is_ssl
Returns true if the URL's scheme specifies an SSL-secured protocol such as https, or false otherwise.
bool has_server() const
Returns true if the URL specifies a server name, false otherwise.
const std::string & get_url() const
Returns the complete URL specification.
void set_url(const std::string &url, bool server_name_expected=false)
Completely replaces the URL with the indicated string.
get_authority
Returns the authority specified by the URL (this includes username, server, and/or port),...
bool has_port() const
Returns true if the URL specifies a port number, false otherwise.
get_username
Returns the username specified by the URL, if any.
bool has_authority() const
Returns true if the URL specifies an authority (this includes username, server, and/or port),...
bool has_username() const
Returns true if the URL specifies a username (and/or password), false otherwise.
get_server
Returns the server name specified by the URL, if any.
bool empty() const
Returns false if the URLSpec is valid (not empty), or true if it is an empty string.
bool has_query() const
Returns true if the URL includes a query specification, 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...
get_query
Returns the query specified by the URL, or empty string if no query is specified.
bool has_path() const
Returns true if the URL includes a path specification (that is, the particular filename on the server...
bool has_scheme() const
Returns true if the URL specifies a scheme (e.g.
std::string get_port_str() const
Returns the port specified by the URL as a string, or the empty string if no port is specified.