dmlite  0.6
include/dmlite/cpp/utils/urls.h
Go to the documentation of this file.
00001 /// @file   include/dmlite/cpp/utils/urls.h
00002 /// @brief  Common methods and functions for URL and path.
00003 /// @author Alejandro Álvarez Ayllón <aalvarez@cern.ch>
00004 #ifndef DMLITE_CPP_UTILS_URLS_H
00005 #define DMLITE_CPP_UTILS_URLS_H
00006 
00007 #include <string>
00008 #include <vector>
00009 #include "extensible.h"
00010 
00011 namespace dmlite {
00012   
00013   struct Url {
00014     std::string scheme;
00015     std::string domain;
00016     unsigned    port;
00017     std::string path;
00018     Extensible  query;
00019     
00020     Url() throw();
00021     explicit Url(const std::string& url) throw ();
00022     
00023     // Operators
00024     bool operator == (const Url&) const;
00025     bool operator != (const Url&) const;
00026     bool operator <  (const Url&) const;
00027     bool operator >  (const Url&) const;
00028     
00029     std::string queryToString(void) const;
00030     void        queryFromString(const std::string& str);
00031 
00032 
00033     std::string toString(void) const;
00034 
00035     /// Split a path into a list of components.
00036     /// @param path The path to split.
00037     /// @return     A list with the extracted components.
00038     static std::vector<std::string> splitPath(const std::string& path) throw ();
00039     
00040     /// Build a path from a list of components
00041     static std::string joinPath(const std::vector<std::string>& components) throw();
00042     
00043     /// Remove multiple slashes.
00044     static std::string normalizePath(const std::string& path) throw ();
00045   };
00046 
00047 };
00048 
00049 #endif // DMLITE_CPP_UTILS_URLS_H