libfilezilla
uri.hpp
Go to the documentation of this file.
1 #ifndef LIBFILEZILLA_URI_HEADER
2 #define LIBFILEZILLA_URI_HEADER
3 
4 #include "libfilezilla.hpp"
5 
6 #include <initializer_list>
7 #include <map>
8 #include <string>
9 
14 namespace fz {
15 
21 class FZ_PUBLIC_SYMBOL uri final
22 {
23 public:
24  uri() = default;
25  explicit uri(std::string const& in);
26 
27  void clear();
28 
35  bool parse(std::string in);
36 
43  std::string to_string() const;
44 
46  std::string get_request() const;
47 
49  std::string get_authority(bool with_userinfo) const;
50 
51  bool empty() const;
52 
54  std::string scheme_;
55  std::string user_;
56  std::string pass_;
57  std::string host_;
58  unsigned short port_{};
59  std::string path_;
60 
68  std::string query_;
69 
75  std::string fragment_;
76 
78  bool is_absolute() const { return path_[0] == '/'; }
79 
85  void resolve(uri const& base);
86 private:
87  bool parse_authority(std::string && authority);
88 };
89 
95 class FZ_PUBLIC_SYMBOL query_string final
96 {
97 public:
98  explicit query_string() = default;
99  explicit query_string(std::string const& raw);
100  explicit query_string(std::pair<std::string, std::string> const& segment);
101  explicit query_string(std::initializer_list<std::pair<std::string, std::string>> const& segments);
102  bool set(std::string const& raw);
103 
104  std::string to_string(bool encode_slashes) const;
105 
106  void remove(std::string const& key);
107  std::string& operator[](std::string const& key);
108 
109 private:
110 
111  std::map<std::string, std::string, fz::less_insensitive_ascii> segments_;
112 };
113 
114 }
115 
116 #endif
The uri class is used to decompose URIs into their individual components.
Definition: uri.hpp:21
std::string query_
The part of a URI after ? but before #.
Definition: uri.hpp:68
std::string scheme_
Often refered to as the protocol prefix, e.g. ftp://.
Definition: uri.hpp:54
Class for parsing a URI&#39;s query string.
Definition: uri.hpp:95
std::string to_string(std::wstring const &in)
Converts from std::wstring into std::string in system encoding.
std::string fragment_
The part of a URI after #.
Definition: uri.hpp:75
The namespace used by libfilezilla.
Definition: apply.hpp:16
Sets some global macros and further includes string.hpp.
bool is_absolute() const
Checks that the URI is absolute, that is the path starting with a slash.
Definition: uri.hpp:78