• Main Page
  • Classes
  • Files
  • File List

Swiften/Base/URL.h

00001 /*
00002  * Copyright (c) 2011 Kevin Smith
00003  * Licensed under the GNU General Public License v3.
00004  * See Documentation/Licenses/GPLv3.txt for more information.
00005  */
00006 
00007 #pragma once
00008 
00009 #include <string>
00010 #include <boost/lexical_cast.hpp>
00011 #include <boost/optional.hpp>
00012 #include <Swiften/Base/API.h>
00013 
00014 namespace Swift {
00015 
00016 class SWIFTEN_API URL {
00017   public:
00018 
00019     URL() : scheme(""), user(""), password(""), host(""), path(""), empty(true) {
00020     }
00021 
00022     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) {
00023     } 
00024 
00025     URL(const std::string& scheme, const std::string& host, const std::string& path) : scheme(scheme), user(), password(), host(host), path(path), empty(false) {
00026     } 
00027 
00031     bool isEmpty() const {
00032       return empty;
00033     }
00034 
00038     const std::string& getScheme() const {
00039       return scheme;
00040     }
00041 
00045     const std::string& getHost() const {
00046       return host;
00047     }
00048 
00052     boost::optional<int> getPort() const {
00053       return port;
00054     }
00055 
00059     const std::string& getPath() const {
00060       return path;
00061     }
00062 
00063     std::string toString() const;
00064 
00065     static int getPortOrDefaultPort(const URL& url);
00066     static URL fromString(const std::string&);
00067     static std::string unescape(const std::string&);
00068 
00069 
00070   private:
00071     std::string scheme;
00072     std::string user;
00073     std::string password;
00074     std::string host;
00075     boost::optional<int> port;
00076     std::string path;
00077     bool empty;
00078   };
00079 }

Generated on Fri Oct 12 2012 21:00:19 for Swiften by  doxygen 1.7.1