summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Base/URL.h')
-rw-r--r--Swiften/Base/URL.h26
1 files changed, 18 insertions, 8 deletions
diff --git a/Swiften/Base/URL.h b/Swiften/Base/URL.h
index 7a5aa59..75cf1a6 100644
--- a/Swiften/Base/URL.h
+++ b/Swiften/Base/URL.h
@@ -8,15 +8,20 @@
#include <string>
+#include <boost/lexical_cast.hpp>
+#include <boost/optional.hpp>
+#include <Swiften/Base/API.h>
namespace Swift {
-class URL {
+class SWIFTEN_API URL {
public:
- URL() : scheme(""), user(""), password(""), host(""), port(-1), path(""), isEmpty(true) {
+ URL() : scheme(""), user(""), password(""), host(""), path(""), empty(true) {
}
- 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) {
+ 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), empty(false) {
+ }
+ URL(const std::string& scheme, const std::string& host, const std::string& path) : scheme(scheme), user(), password(), host(host), path(path), empty(false) {
}
@@ -24,6 +29,6 @@ class URL {
* Whether the URL is empty.
*/
- bool empty() const {
- return isEmpty;
+ bool isEmpty() const {
+ return empty;
}
@@ -45,5 +50,5 @@ class URL {
* Port number
*/
- int getPort() const {
+ boost::optional<int> getPort() const {
return port;
}
@@ -56,4 +61,9 @@ class URL {
}
+ std::string toString() const;
+
+ static int getPortOrDefaultPort(const URL& url);
+ static URL fromString(const std::string&);
+ static std::string unescape(const std::string&);
@@ -63,7 +73,7 @@ class URL {
std::string password;
std::string host;
- int port;
+ boost::optional<int> port;
std::string path;
- bool isEmpty;
+ bool empty;
};
}