dmlite  0.6
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 #include "extensible.h"
10 
11 namespace dmlite {
12 
13  struct Url {
14  std::string scheme;
15  std::string domain;
16  unsigned port;
17  std::string path;
19 
20  Url() throw();
21  explicit Url(const std::string& url) throw ();
22  Url(const Url & _u);
23 
24  // Operators
25  bool operator == (const Url&) const;
26  bool operator != (const Url&) const;
27  bool operator < (const Url&) const;
28  bool operator > (const Url&) const;
29 
30  Url & operator = (const Url & _u);
31 
32  std::string queryToString(void) const;
33  void queryFromString(const std::string& str);
34 
35 
36  std::string toString(void) const;
37 
38  /// Split a path into a list of components.
39  /// @param path The path to split.
40  /// @return A list with the extracted components.
41  static std::vector<std::string> splitPath(const std::string& path) throw ();
42 
43  /// Build a path from a list of components
44  static std::string joinPath(const std::vector<std::string>& components) throw();
45 
46  /// Remove multiple slashes.
47  static std::string normalizePath(const std::string& path, const bool add_trailing_slash = true) throw ();
48 
49  };
50 };
51 
52 #endif // DMLITE_CPP_UTILS_URLS_H
static std::string normalizePath(const std::string &path, const bool add_trailing_slash=true)
Remove multiple slashes.
std::string domain
Definition: urls.h:15
unsigned port
Definition: urls.h:16
static std::string joinPath(const std::vector< std::string > &components)
Build a path from a list of components.
static std::vector< std::string > splitPath(const std::string &path)
std::string path
Definition: urls.h:17
void queryFromString(const std::string &str)
Definition: urls.h:13
Extensible query
Definition: urls.h:18
Helpful typedef for KeyValue containers.
Definition: extensible.h:20
std::string scheme
Definition: urls.h:14
std::string queryToString(void) const
Extensible types (hold metadata).
std::string toString(void) const