1 #ifndef LIBFILEZILLA_URI_HEADER
2 #define LIBFILEZILLA_URI_HEADER
6 #include <initializer_list>
21 class FZ_PUBLIC_SYMBOL
uri final
24 uri() noexcept =
default;
25 explicit uri(std::string_view
const& in);
35 bool parse(std::string_view in);
43 std::string
to_string(
bool with_query =
true)
const;
52 explicit operator bool()
const {
return !empty(); }
67 unsigned short port_{};
100 bool operator!=(
uri const& arg)
const {
return !(*
this == arg); }
103 bool FZ_PRIVATE_SYMBOL parse_authority(std::string_view authority);
116 explicit query_string(std::pair<std::string, std::string>
const& segment);
117 explicit query_string(std::initializer_list<std::pair<std::string, std::string>>
const& segments);
118 bool set(std::string_view
const& raw);
120 std::string
to_string(
bool encode_slashes)
const;
122 void remove(std::string
const& key);
123 std::string& operator[](std::string
const& key);
125 std::map<std::string, std::string, less_insensitive_ascii>
const& pairs()
const {
return segments_; }
127 bool empty()
const {
return segments_.empty(); }
130 std::map<std::string, std::string, less_insensitive_ascii> segments_;
Class for parsing a URI's query string.
Definition: uri.hpp:112
The uri class is used to decompose URIs into their individual components.
Definition: uri.hpp:22
std::string get_authority(bool with_userinfo) const
Returns [user[:pass]@]host[:port].
bool parse(std::string_view in)
Splits uri into components.
std::string user_
Optional user part of the authority.
Definition: uri.hpp:58
std::string query_
The part of a URI after ? but before #.
Definition: uri.hpp:79
std::string get_request(bool with_query=true) const
Returns path and query, separated by question mark.
std::string pass_
Optional password part of the authority.
Definition: uri.hpp:61
std::string to_string(bool with_query=true) const
Assembles components into string.
std::string scheme_
Often referred to as the protocol prefix, e.g. ftp://.
Definition: uri.hpp:55
std::string path_
Optional path, must start with a slash if set.
Definition: uri.hpp:70
std::string fragment_
The part of a URI after #.
Definition: uri.hpp:86
void resolve(uri const &base)
Resolve a relative URI reference into an absolute URI given a base URL.
bool is_absolute() const
Checks that the URI is absolute, that is the path starting with a slash.
Definition: uri.hpp:89
std::string host_
Hostname, or IP address literal.
Definition: uri.hpp:64
Sets some global macros and further includes string.hpp.
The namespace used by libfilezilla.
Definition: apply.hpp:17
std::string to_string(std::wstring_view const &in)
Converts from std::wstring into std::string in system encoding.
bool operator==(symmetric_key const &lhs, symmetric_key const &rhs)
Side-channel safe comparison.