dmlite  0.4
urls.h
Go to the documentation of this file.
1 /// @file include/dmlite/cpp/utils/urls.h
2 /// @brief Common methods and functions for URL and path.
3 /// @author Alejandro Álvarez Ayllón <aalvarez@cern.ch>
4 #ifndef DMLITE_CPP_UTILS_URLS_H
5 #define DMLITE_CPP_UTILS_URLS_H
6 
7 #include <string>
8 #include <vector>
9 
10 namespace dmlite {
11 
12  struct Url {
13  std::string scheme;
14  std::string domain;
15  unsigned port;
16  std::string path;
17  std::string query;
18 
19  explicit Url(const std::string& url) throw ();
20 
21  // Operators
22  bool operator == (const Url&) const;
23  bool operator != (const Url&) const;
24  bool operator < (const Url&) const;
25  bool operator > (const Url&) const;
26 
27  /// Split a path into a list of components.
28  /// @param path The path to split.
29  /// @return A list with the extracted components.
30  static std::vector<std::string> splitPath(const std::string& path) throw ();
31 
32  /// Build a path from a list of components
33  static std::string joinPath(const std::vector<std::string>& components) throw();
34 
35  /// Remove multiple slashes.
36  static std::string normalizePath(const std::string& path) throw ();
37  };
38 
39 };
40 
41 #endif // DMLITE_CPP_UTILS_URLS_H