00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef URLSPEC_H
00020 #define URLSPEC_H
00021
00022 #include "pandabase.h"
00023 #include "notify.h"
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 class EXPCL_PANDAEXPRESS URLSpec {
00034 PUBLISHED:
00035 URLSpec();
00036 INLINE URLSpec(const string &url, bool server_name_expected = false);
00037 INLINE URLSpec(const URLSpec ©);
00038 INLINE void operator = (const string &url);
00039 void operator = (const URLSpec ©);
00040
00041 INLINE bool operator == (const URLSpec &other) const;
00042 INLINE bool operator != (const URLSpec &other) const;
00043 INLINE bool operator < (const URLSpec &other) const;
00044 INLINE int compare_to(const URLSpec &other) const;
00045
00046 INLINE bool has_scheme() const;
00047 INLINE bool has_authority() const;
00048 INLINE bool has_username() const;
00049 INLINE bool has_server() const;
00050 INLINE bool has_port() const;
00051 INLINE bool has_path() const;
00052 INLINE bool has_query() const;
00053
00054 string get_scheme() const;
00055 INLINE string get_authority() const;
00056 INLINE string get_username() const;
00057 INLINE string get_server() const;
00058 INLINE string get_port_str() const;
00059 int get_port() const;
00060 string get_server_and_port() const;
00061 string get_path() const;
00062 INLINE string get_query() const;
00063
00064 INLINE const string &get_url() const;
00065
00066 void set_scheme(const string &scheme);
00067 void set_authority(const string &authority);
00068 void set_username(const string &username);
00069 void set_server(const string &server);
00070 void set_port(const string &port);
00071 void set_port(int port);
00072 void set_server_and_port(const string &server_and_port);
00073 void set_path(const string &path);
00074 void set_query(const string &query);
00075
00076 void set_url(const string &url, bool server_name_expected = false);
00077
00078 INLINE operator const string & () const;
00079 INLINE const char *c_str() const;
00080 INLINE bool empty() const;
00081 INLINE size_t length() const;
00082 INLINE char operator [] (int n) const;
00083
00084 bool input(istream &in);
00085 void output(ostream &out) const;
00086
00087 static string quote(const string &source, const string &safe = "/");
00088 static string quote_plus(const string &source, const string &safe = "/");
00089 static string unquote(const string &source);
00090 static string unquote_plus(const string &source);
00091
00092 private:
00093 void parse_authority();
00094
00095 enum Flags {
00096 F_has_scheme = 0x0001,
00097 F_has_authority = 0x0002,
00098 F_has_username = 0x0004,
00099 F_has_server = 0x0008,
00100 F_has_port = 0x0010,
00101 F_has_path = 0x0020,
00102 F_has_query = 0x0040,
00103 };
00104
00105 string _url;
00106 int _port;
00107 int _flags;
00108
00109 size_t _scheme_end;
00110 size_t _username_start;
00111 size_t _username_end;
00112 size_t _server_start;
00113 size_t _server_end;
00114 size_t _port_start;
00115 size_t _port_end;
00116 size_t _path_start;
00117 size_t _path_end;
00118 size_t _query_start;
00119 };
00120
00121 INLINE istream &operator >> (istream &in, URLSpec &url);
00122 INLINE ostream &operator << (ostream &out, const URLSpec &url);
00123
00124 #include "urlSpec.I"
00125
00126 #endif
00127