summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Base/URL.h')
-rw-r--r--Swiften/Base/URL.h31
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;