00001 #ifndef BASE_URL_H 00002 #define BASE_URL_H 00003 00004 #include <string> 00005 00006 namespace base { 00007 00011 class Url { 00012 protected: 00013 std::string fUrl; 00014 bool fValid; 00015 std::string fProtocol; 00016 std::string fHostName; 00017 int fPort; 00018 std::string fFileName; 00019 std::string fOptions; 00020 00021 bool GetOption(const std::string& optname, std::string* value = 0) const; 00022 00023 public: 00024 Url(); 00025 Url(const char* url); 00026 Url(const std::string& url); 00027 virtual ~Url(); 00028 00029 void Reset(); 00030 bool SetUrl(const std::string& url, bool showerr = true); 00031 00032 std::string GetUrl() const { return fUrl; } 00033 bool IsValid() const { return fValid; } 00034 00035 std::string GetProtocol() const { return fProtocol; } 00036 std::string GetHostName() const { return fHostName; } 00037 int GetPort() const { return fPort; } 00038 std::string GetPortStr() const; 00039 std::string GetFileName() const { return fFileName; } 00040 std::string GetFullName() const; 00041 00042 std::string GetOptions() const { return fOptions; } 00043 bool HasOption(const std::string& optname) const { return GetOption(optname); } 00044 std::string GetOptionValue(const std::string& optname) const; 00045 }; 00046 00047 } 00048 00049 #endif