SAGA Adaptor CPI v.1.0
url.hpp
Go to the documentation of this file.
00001 //  Copyright (c) 2005-2009 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 {
00037   class SAGA_EXPORT url 
00038     : public saga::object
00039   {
00040     private:
00041       friend class saga::impl::url;
00042       friend struct saga::impl::runtime;
00043 
00044       SAGA_CALL_CONST_PRIV_1(translate, std::string)
00045       SAGA_CALL_CONST_PRIV_2(translate, saga::session, std::string)
00046 
00047    protected:
00049 
00050      TR1::shared_ptr <impl::url> get_impl_sp() const;
00051      impl::url* get_impl() const;
00052 
00053      url (impl::url *impl);
00054 //      url (adaptors::nocheck);
00055 //      url (saga::object rhs, adaptors::nocheck);
00056      url (std::string const & urlstr, adaptors::nocheck);
00058 
00059    public:
00060      url();
00061      explicit url (saga::object rhs);
00062      url(saga::url const& rhs);
00063      url(std::string const& urlstr);
00064      url(char const * urlstr);
00065     ~url(void);
00066 
00067     url& operator=(char const * urlstr);
00068     url& operator=(std::string const & urlstr);
00069     url& operator=(saga::url const& rhs);
00070     url& operator=(saga::object const& rhs);
00071     
00076     saga::object clone() const;
00077     
00083      std::string get_string(void) const;
00084      
00089      void set_string(std::string const & url);
00090      
00096      std::string get_scheme (void) const;
00097      
00102      void set_scheme (std::string const & scheme);
00103      
00109      std::string get_host (void) const;
00110      
00115      void set_host (std::string const & host);
00116      
00122      int get_port (void) const;
00123 
00128      void set_port (int port);
00129 
00135      std::string get_fragment  (void) const;
00136      
00141      void set_fragment (std::string const & fragment);
00142      
00148      std::string get_path (void) const;
00149      
00154      void set_path (std::string const & path);
00155      
00161      std::string get_userinfo (void) const;
00162      
00167      void set_userinfo (std::string const & userinfo);
00168 
00173     saga::url translate(std::string scheme) const
00174     {
00175         saga::task t = translatepriv(scheme, saga::task_base::Sync());
00176         return t.get_result<saga::url>();
00177     }
00178     SAGA_CALL_CONST_PUB_1_DEF_0(translate, std::string)
00179 
00180     
00184     saga::url translate(saga::session s, std::string scheme) const
00185     {
00186         saga::task t = translatepriv(s, scheme, saga::task_base::Sync());
00187         return t.get_result<saga::url>();
00188     }
00189     SAGA_CALL_CONST_PUB_2_DEF_0(translate, saga::session, std::string)
00190 
00191     
00192     // The API functions below are not part of the SAGA specification
00193     // we provide these as convenience helpers
00195     
00196     
00201      std::string get_url       (void) const;
00202      
00207      void set_url(std::string const & url);
00208      
00213      std::string get_authority (void) const;
00214      
00219      std::string get_query (void) const;
00220      
00225      void set_query (std::string const & query);
00226 
00231      void set_scheme_specific_part (std::string const & scheme_specific_part);
00232      
00237      std::string get_username  (void) const;
00238      
00243      void set_username (std::string const & username);
00244      
00249      std::string get_password  (void) const;
00250      
00255      void set_password (std::string const & passwd);
00256 
00260     static std::string unescape(std::string const&in);
00261   
00264     static std::string escape(std::string const&in);
00265   
00266   };
00267 
00269 
00273   SAGA_EXPORT std::ostream& operator<< (std::ostream& os, url const& u);
00274 
00279   SAGA_EXPORT std::istream& operator>> (std::istream& is, url& u);
00280 
00285   SAGA_EXPORT bool operator== (saga::url const& lhs, saga::url const& rhs);
00286 
00291   SAGA_EXPORT bool operator!= (saga::url const& lhs, saga::url const& rhs);
00292 
00297   SAGA_EXPORT bool operator< (saga::url const& lhs, saga::url const& rhs);
00298 
00300 } // namespace saga
00301 
00302 // re-enable warnings about dependent classes not being exported from the dll
00303 #if defined(BOOST_MSVC)
00304 #pragma warning(pop)
00305 #endif
00306 
00307 #endif // SAGA_SAGA_URL_HPP
00308 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines