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 
62  std::string query_;
63 
65  std::string fragment_;
66 
68  bool is_absolute() const { return path_[0] == '/'; }
69 
75  void resolve(uri const& base);
76 private:
77  bool parse_authority(std::string && authority);
78 };
79 
85 class FZ_PUBLIC_SYMBOL query_string final
86 {
87 public:
88  explicit query_string() = default;
89  explicit query_string(std::string const& raw);
90  explicit query_string(std::pair<std::string, std::string> const& segment);
91  explicit query_string(std::initializer_list<std::pair<std::string, std::string>> const& segments);
92  bool set(std::string const& raw);
93 
94  std::string to_string(bool encode_slashes) const;
95 
96  void remove(std::string const& key);
97  std::string& operator[](std::string const& key);
98 
99 private:
100 
101  std::map<std::string, std::string, fz::less_insensitive_ascii> segments_;
102 };
103 
104 }
105 
106 #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:62
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:85
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:65
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 absolut, that is the path starting with a slash.
Definition: uri.hpp:68