URL.h++
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __ccxx_URL_hxx
00024 #define __ccxx_URL_hxx
00025
00026 #include <memory>
00027
00028 #include <commonc++/Common.h++>
00029 #include <commonc++/String.h++>
00030 #include <commonc++/ParseException.h++>
00031 #include <commonc++/RegExp.h++>
00032
00033 namespace ccxx {
00034
00041 class COMMONCPP_API URL
00042 {
00043 public:
00044
00046 URL();
00047
00049 URL(const String& url);
00050
00052 URL(const URL& other);
00053
00055 ~URL() throw();
00056
00058 inline void setScheme(const String& scheme)
00059 { _scheme = scheme; _url = String::null; }
00060
00062 inline String getScheme() const
00063 { return(_scheme); }
00064
00066 inline void setHost(const String& host)
00067 { _host = host; _url = String::null; }
00068
00070 inline String getHost() const
00071 { return(_host); }
00072
00075 inline void setPort(uint16_t port) throw()
00076 { _port = port; _url = String::null; }
00077
00081 inline uint16_t getPort() const throw()
00082 { return(_port); }
00083
00085 void setPath(const String& path);
00086
00088 inline String getPath() const
00089 { return(_path); }
00090
00092 inline String getCanonicalPath() const
00093 { return(_canonicalPath); }
00094
00099 inline void setQuery(const String& query)
00100 { _query = query; _url = String::null; }
00101
00106 inline String getQuery() const
00107 { return(_query); }
00108
00110 bool isValid() const throw();
00111
00113 String toString() const;
00114
00116 bool operator==(const URL& other) const throw();
00117
00119 inline bool operator!=(const URL& other) const throw()
00120 { return(! operator==(other)); }
00121
00123 URL& operator=(const String& other);
00124
00126 URL& operator=(const URL& other);
00127
00133 static String encode(const String& str);
00134
00140 static String decode(const String& str);
00141
00142 private:
00143
00144 void _init();
00145 void _parseURL(const String& url);
00146 String _canonicalizePath(const String &path);
00147
00148 String _scheme;
00149 String _host;
00150 uint16_t _port;
00151 String _path;
00152 String _canonicalPath;
00153 String _query;
00154 mutable String _url;
00155 RegExp _re;
00156 };
00157
00158 };
00159
00160 #endif // __ccxx_URL_hxx
00161
00162