diff options
author | Kevin Smith <git@kismith.co.uk> | 2012-03-15 19:17:09 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2012-09-08 11:16:21 (GMT) |
commit | 0174723efbc1f612433d45c6916a2ad4596b96ba (patch) | |
tree | b063d775f480bec74ab1631a3e48a2c55bd0fed4 /Swiften/Base | |
parent | da72fe77cc7dd183ae18e23903de67de886b3acb (diff) | |
download | swift-contrib-0174723efbc1f612433d45c6916a2ad4596b96ba.zip swift-contrib-0174723efbc1f612433d45c6916a2ad4596b96ba.tar.bz2 |
Connection settings support
Diffstat (limited to 'Swiften/Base')
-rw-r--r-- | Swiften/Base/URL.h | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/Swiften/Base/URL.h b/Swiften/Base/URL.h index 7a5aa59..94dc4cb 100644 --- a/Swiften/Base/URL.h +++ b/Swiften/Base/URL.h @@ -7,6 +7,7 @@ #pragma once #include <string> +#include <boost/lexical_cast.hpp> namespace Swift { @@ -16,6 +17,14 @@ class URL { URL() : scheme(""), user(""), password(""), host(""), port(-1), path(""), isEmpty(true) { } + URL(const std::string& urlString) { + host = urlString; + port = 80; + scheme = "http"; + isEmpty = false; + //FIXME + } + URL(const std::string& scheme, const std::string& host, int port, const std::string& path) : scheme(scheme), user(), password(), host(host), port(port), path(path), isEmpty(false) { } @@ -55,7 +64,27 @@ class URL { return path; } - + const std::string toString() const { + if (isEmpty) { + return ""; + } + std::string result = scheme + "://"; + if (!user.empty()) { + result += user; + if (!password.empty()) { + result += ":" + password; + } + result += "@"; + } + result += host; + if (port > 0) { + result += ":"; + result += boost::lexical_cast<std::string>(port); + } + result += "/"; + result += path; + return result; + } private: std::string scheme; |