28class EXPCL_PANDA_DOWNLOADER URLSpec {
31 INLINE URLSpec(
const std::string &url,
bool server_name_expected =
false);
32 URLSpec(
const URLSpec &url,
const Filename &path);
33 INLINE
void operator = (
const std::string &url);
35 INLINE
bool operator == (
const URLSpec &other)
const;
36 INLINE
bool operator != (
const URLSpec &other)
const;
37 INLINE
bool operator < (
const URLSpec &other)
const;
39 size_t get_hash()
const;
61 INLINE
bool is_ssl()
const;
63 INLINE
const std::string &
get_url()
const;
69 void set_port(
const std::string &port);
72 void set_path(
const std::string &path);
75 void set_url(
const std::string &url,
bool server_name_expected =
false);
77 INLINE
operator const std::string & ()
const;
78 INLINE
const char *c_str()
const;
79 INLINE
bool empty()
const;
80 INLINE
operator bool()
const;
81 INLINE
size_t length()
const;
82 INLINE
size_t size()
const;
83 INLINE
char operator [] (
size_t n)
const;
85 bool input(std::istream &in);
86 void output(std::ostream &out)
const;
88 static std::string
quote(
const std::string &source,
const std::string &safe =
"/");
89 static std::string
quote_plus(
const std::string &source,
const std::string &safe =
"/");
90 static std::string
unquote(
const std::string &source);
91 static std::string
unquote_plus(
const std::string &source);
104 void parse_authority();
107 F_has_scheme = 0x0001,
108 F_has_authority = 0x0002,
109 F_has_username = 0x0004,
110 F_has_server = 0x0008,
113 F_has_query = 0x0040,
121 size_t _username_start;
122 size_t _username_end;
123 size_t _server_start;
132INLINE std::istream &operator >> (std::istream &in,
URLSpec &url);
133INLINE std::ostream &operator << (std::ostream &out,
const URLSpec &url);
The name of a file, such as a texture file or an Egg file.
A container for a URL, e.g.
bool has_username() const
Returns true if the URL specifies a username (and/or password), false otherwise.
bool empty() const
Returns false if the URLSpec is valid (not empty), or true if it is an empty string.
bool has_path() const
Returns true if the URL includes a path specification (that is, the particular filename on the server...
static int get_default_port_for_scheme(const std::string &scheme)
Returns the default port number for the indicated scheme, or 0 if there is no known default.
set_port
Replaces the port part of the URL specification.
set_scheme
Replaces the scheme part of the URL specification.
set_path
Replaces the path part of the URL specification.
get_username
Returns the username specified by the URL, if any.
set_query
Replaces the query part of the URL specification.
bool has_authority() const
Returns true if the URL specifies an authority (this includes username, server, and/or port),...
static std::string quote(const std::string &source, const std::string &safe="/")
Returns the source string with all "unsafe" characters quoted, making a string suitable for placing i...
bool has_query() const
Returns true if the URL includes a query specification, false otherwise.
const std::string & get_url() const
Returns the complete URL specification.
bool is_default_port() const
Returns true if the port number encoded in this URL is the default port number for the scheme (or if ...
set_server
Replaces the server part of the URL specification.
get_server
Returns the server name specified by the URL, if any.
get_query
Returns the query specified by the URL, or empty string if no query is specified.
get_path
Returns the path specified by the URL, or "/" if no path is specified.
static std::string unquote_plus(const std::string &source)
Reverses the operation of quote_plus(): converts escaped characters of the form "%xx" to their ascii ...
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.
get_server_and_port
Returns a string consisting of the server name, followed by a colon, followed by the port number.
bool has_port() const
Returns true if the URL specifies a port number, false otherwise.
bool has_scheme() const
Returns true if the URL specifies a scheme (e.g.
get_scheme
Returns the scheme specified by the URL, or empty string if no scheme is specified.
static std::string unquote(const std::string &source)
Reverses the operation of quote(): converts escaped characters of the form "%xx" to their ascii equiv...
is_ssl
Returns true if the URL's scheme specifies an SSL-secured protocol such as https, or false otherwise.
void set_url(const std::string &url, bool server_name_expected=false)
Completely replaces the URL with the indicated string.
get_port
Returns the port number specified by the URL, or the default port if not specified.
set_authority
Replaces the authority part of the URL specification.
static std::string quote_plus(const std::string &source, const std::string &safe="/")
Behaves like quote() with the additional behavior of replacing spaces with plus signs.
bool has_server() const
Returns true if the URL specifies a server name, false otherwise.
set_server_and_port
Replaces the server and port parts of the URL specification simultaneously.
std::string get_path_and_query() const
Returns the path (or "/" if no path is specified), followed by the query if it is specified.
set_username
Replaces the username part of the URL specification.
get_authority
Returns the authority specified by the URL (this includes username, server, and/or port),...
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...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.