2007-07-19 19:01:57 +02:00
|
|
|
#ifndef ARABICA_IO_URI_HPP
|
|
|
|
#define ARABICA_IO_URI_HPP
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace Arabica
|
|
|
|
{
|
|
|
|
namespace io
|
|
|
|
{
|
|
|
|
class URI
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
URI() { }
|
|
|
|
|
|
|
|
URI(const std::string& URI);
|
|
|
|
|
|
|
|
URI(const URI& base, const std::string& relativeURI);
|
|
|
|
|
|
|
|
URI(const URI& rhs) :
|
|
|
|
scheme_(rhs.scheme_),
|
|
|
|
host_(rhs.host_),
|
|
|
|
path_(rhs.path_),
|
2008-08-26 01:05:37 +02:00
|
|
|
port_(rhs.port_),
|
2012-11-12 22:46:08 +01:00
|
|
|
is_absolute_(rhs.is_absolute_)
|
2007-07-19 19:01:57 +02:00
|
|
|
{
|
|
|
|
} // URI
|
|
|
|
|
|
|
|
URI& operator=(const URI& rhs)
|
|
|
|
{
|
|
|
|
URI t(rhs);
|
|
|
|
swap(t);
|
|
|
|
return *this;
|
|
|
|
} // operator=
|
|
|
|
|
|
|
|
bool operator==(const URI& rhs) const
|
|
|
|
{
|
|
|
|
return scheme_ == rhs.scheme_ &&
|
|
|
|
host_ == rhs.host_ &&
|
|
|
|
path_ == rhs.path_ &&
|
2008-08-26 01:05:37 +02:00
|
|
|
port_ == rhs.port_ &&
|
|
|
|
is_absolute_ == rhs.is_absolute_;
|
2007-07-19 19:01:57 +02:00
|
|
|
} // operator==
|
|
|
|
|
|
|
|
bool operator!=(const URI& rhs) const
|
|
|
|
{
|
|
|
|
return !(operator==(rhs));
|
|
|
|
} // operator!=
|
|
|
|
|
|
|
|
~URI() { }
|
|
|
|
|
|
|
|
void swap(URI& rhs)
|
|
|
|
{
|
|
|
|
std::swap(scheme_, rhs.scheme_);
|
|
|
|
std::swap(host_, rhs.host_);
|
|
|
|
std::swap(path_, rhs.path_);
|
|
|
|
std::swap(port_, rhs.port_);
|
2012-11-12 22:46:08 +01:00
|
|
|
std::swap(is_absolute_, rhs.is_absolute_);
|
2007-07-19 19:01:57 +02:00
|
|
|
} // swap
|
|
|
|
|
|
|
|
const std::string& scheme() const { return scheme_; }
|
|
|
|
const std::string& host() const { return host_; }
|
|
|
|
const std::string& port() const;
|
|
|
|
const std::string& path() const { return path_; }
|
2008-08-26 01:05:37 +02:00
|
|
|
const bool& is_absolute() const { return is_absolute_; }
|
2007-07-19 19:01:57 +02:00
|
|
|
|
|
|
|
std::string as_string() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void parse(const std::string& URI);
|
2008-08-26 01:05:37 +02:00
|
|
|
void parse_uri(const std::string& URI);
|
2009-02-21 00:00:01 +01:00
|
|
|
std::string::const_iterator parseAuthority(const std::string::const_iterator& u, const std::string::const_iterator& ue);
|
2007-07-19 19:01:57 +02:00
|
|
|
void absolutise(URI& relURI);
|
|
|
|
void combinePath(const std::string& path);
|
|
|
|
|
|
|
|
std::string scheme_;
|
|
|
|
std::string host_;
|
|
|
|
std::string path_;
|
|
|
|
std::string port_;
|
2008-08-26 01:05:37 +02:00
|
|
|
bool is_absolute_;
|
2007-07-19 19:01:57 +02:00
|
|
|
}; // class URI
|
|
|
|
} // namespace io
|
|
|
|
} // namespace Arabica
|
|
|
|
|
|
|
|
#endif
|