SAGA C++ API 1.6
|
00001 // Copyright (c) 2005-2011 Hartmut Kaiser 00002 // Copyright (c) 2007 Ole Weidner (oweidner@cct.lsu.edu) 00003 // 00004 // Distributed under the Boost Software License, Version 1.0. (See accompanying 00005 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 00006 00007 #include <string> 00008 #include <iosfwd> 00009 00010 #include <saga/saga/util.hpp> 00011 #include <saga/saga/base.hpp> 00012 #include <saga/saga/call.hpp> 00013 00014 #include <saga/saga/object.hpp> 00015 #include <saga/saga/session.hpp> 00016 00017 #if !defined(SAGA_SAGA_URL_HPP) 00018 #define SAGA_SAGA_URL_HPP 00019 00020 // suppress warnings about dependent classes not being exported from the dll 00021 #if defined(BOOST_MSVC) 00022 #pragma warning(push) 00023 #pragma warning(disable: 4251 4231 4275 4660) 00024 #endif 00025 00027 namespace saga 00028 { 00030 00034 SAGA_EXPORT std::ostream& operator<< (std::ostream& os, url const& u); 00035 00040 SAGA_EXPORT std::istream& operator>> (std::istream& is, url& u); 00041 00046 SAGA_EXPORT bool operator== (saga::url const& lhs, saga::url const& rhs); 00047 00052 SAGA_EXPORT bool operator!= (saga::url const& lhs, saga::url const& rhs); 00053 00058 SAGA_EXPORT bool operator< (saga::url const& lhs, saga::url const& rhs); 00059 00067 class SAGA_EXPORT url 00068 : public saga::object 00069 { 00070 private: 00071 friend class saga::impl::url; 00072 friend struct saga::impl::runtime; 00073 00074 SAGA_CALL_CONST_PRIV_1(translate, std::string) 00075 SAGA_CALL_CONST_PRIV_2(translate, saga::session, std::string) 00076 00077 std::string get_url_escaped(bool hide_password = false) const; 00078 00079 friend SAGA_EXPORT std::ostream& operator<< (std::ostream& os, url const& u); 00080 friend SAGA_EXPORT std::istream& operator>> (std::istream& is, url& u); 00081 friend SAGA_EXPORT bool operator== (saga::url const& lhs, saga::url const& rhs); 00082 friend SAGA_EXPORT bool operator!= (saga::url const& lhs, saga::url const& rhs); 00083 friend SAGA_EXPORT bool operator< (saga::url const& lhs, saga::url const& rhs); 00084 00085 protected: 00087 00088 TR1::shared_ptr <impl::url> get_impl_sp() const; 00089 impl::url* get_impl() const; 00090 00091 url (impl::url *impl); 00092 // url (adaptors::nocheck); 00093 // url (saga::object rhs, adaptors::nocheck); 00094 url (std::string const & urlstr, adaptors::nocheck); 00096 00097 public: 00098 url(); 00099 explicit url (saga::object rhs); 00100 url(saga::url const& rhs); 00101 url(std::string const& urlstr); 00102 url(char const * urlstr); 00103 ~url(void); 00104 00105 url& operator=(char const * urlstr); 00106 url& operator=(std::string const & urlstr); 00107 url& operator=(saga::url const& rhs); 00108 url& operator=(saga::object const& rhs); 00109 00114 saga::object clone() const; 00115 00121 std::string get_string(void) const; 00122 00127 void set_string(std::string const & url); 00128 00134 std::string get_scheme (void) const; 00135 00140 void set_scheme (std::string const & scheme); 00141 00147 std::string get_host (void) const; 00148 00153 void set_host (std::string const & host); 00154 00160 int get_port (void) const; 00161 00166 void set_port (int port); 00167 00173 std::string get_fragment (void) const; 00174 00179 void set_fragment (std::string const & fragment); 00180 00186 std::string get_path (void) const; 00187 00192 void set_path (std::string const & path); 00193 00199 std::string get_userinfo (void) const; 00200 00205 void set_userinfo (std::string const & userinfo); 00206 00211 saga::url translate(std::string scheme) const 00212 { 00213 saga::task t = translatepriv(scheme, saga::task_base::Sync()); 00214 return t.get_result<saga::url>(); 00215 } 00216 SAGA_CALL_CONST_PUB_1_DEF_0(translate, std::string) 00217 00218 00222 saga::url translate(saga::session s, std::string scheme) const 00223 { 00224 saga::task t = translatepriv(s, scheme, saga::task_base::Sync()); 00225 return t.get_result<saga::url>(); 00226 } 00227 SAGA_CALL_CONST_PUB_2_DEF_0(translate, saga::session, std::string) 00228 00229 00230 // The API functions below are not part of the SAGA specification 00231 // we provide these as convenience helpers 00233 00234 00239 std::string get_url (void) const; 00240 00245 void set_url(std::string const & url); 00246 00251 std::string get_authority (void) const; 00252 00257 void set_authority (std::string const & auth); 00258 00263 std::string get_query (void) const; 00264 00269 void set_query (std::string const & query); 00270 00275 void set_scheme_specific_part (std::string const & scheme_specific_part); 00276 00281 std::string get_username (void) const; 00282 00287 void set_username (std::string const & username); 00288 00293 std::string get_password (void) const; 00294 00299 void set_password (std::string const & passwd); 00300 00304 static std::string unescape(std::string const&in); 00305 00308 static std::string escape(std::string const&in); 00309 00310 }; 00311 } // namespace saga 00312 00313 // re-enable warnings about dependent classes not being exported from the dll 00314 #if defined(BOOST_MSVC) 00315 #pragma warning(pop) 00316 #endif 00317 00318 #endif // SAGA_SAGA_URL_HPP 00319