diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-01-12 23:49:43 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-01-12 23:49:43 (GMT) |
commit | a116aeb2cf5a84fa03f9814c3884561149029267 (patch) | |
tree | bdd7dfc15ec1e38edcc9a7532ffad03fe4f6f823 /src/uscxml/URL.h | |
parent | 6d0622c0bb8f0e52589c82252f2cc1eb847ad9bf (diff) | |
download | uscxml-a116aeb2cf5a84fa03f9814c3884561149029267.zip uscxml-a116aeb2cf5a84fa03f9814c3884561149029267.tar.gz uscxml-a116aeb2cf5a84fa03f9814c3884561149029267.tar.bz2 |
Refactored to PIMPL pattern
Diffstat (limited to 'src/uscxml/URL.h')
-rw-r--r-- | src/uscxml/URL.h | 47 |
1 files changed, 41 insertions, 6 deletions
diff --git a/src/uscxml/URL.h b/src/uscxml/URL.h index 3a87fb1..07921f3 100644 --- a/src/uscxml/URL.h +++ b/src/uscxml/URL.h @@ -8,13 +8,17 @@ // use arabica URL parser #include <io/uri.hpp> -namespace uscxml { +#include <boost/shared_ptr.hpp> +#include <boost/enable_shared_from_this.hpp> -class URL { +namespace uscxml { + +class URLImpl : public boost::enable_shared_from_this<URLImpl> { public: - URL() {} - URL(const std::string uri) : _uri(uri) {} - virtual ~URL(); + URLImpl() {} + URLImpl(const std::string uri) : _uri(uri) {} + virtual ~URLImpl(); + const bool toAbsoluteCwd(); const bool toAbsolute(const std::string& baseUrl); const std::string asLocalFile(const std::string& suffix, bool reload = false); @@ -28,9 +32,40 @@ public: private: Arabica::io::URI _uri; std::string _localFile; - friend std::ostream & operator<<(std::ostream &stream, const URL& p); }; +class URL { +public: + URL() : _impl() {} + URL(const std::string uri) : _impl(new URLImpl(uri)) {} + URL(boost::shared_ptr<URLImpl> const impl) : _impl(impl) { } + URL(const URL& other) : _impl(other._impl) { } + virtual ~URL() {}; + + operator bool() const { return _impl;} + bool operator< (const URL& other) const { return _impl < other._impl; } + bool operator==(const URL& other) const { return _impl == other._impl; } + bool operator!=(const URL& other) const { return _impl != other._impl; } + URL& operator= (const URL& other) { _impl = other._impl; return *this; } + + const bool toAbsoluteCwd() { return _impl->toAbsoluteCwd(); } + const bool toAbsolute(const std::string& baseUrl) { return _impl->toAbsolute(baseUrl); } + const bool toAbsolute(const URL& baseUrl) { return _impl->toAbsolute(baseUrl.asString()); } + const std::string asLocalFile(const std::string& suffix, bool reload = false) { return _impl->asLocalFile(suffix, reload); } + + const bool isAbsolute() const { return _impl->isAbsolute(); } + const std::string scheme() const { return _impl->scheme(); } + const std::string host() const { return _impl->host(); } + const std::string port() const { return _impl->port(); } + const std::string path() const { return _impl->path(); } + const std::string asString() const { return _impl->asString(); } + + friend std::ostream & operator<<(std::ostream &stream, const URL& p); + +protected: + boost::shared_ptr<URLImpl> _impl; +}; + enum fcurl_type_e { CFTYPE_NONE=0, CFTYPE_FILE=1, |