1 #ifndef LIBFILEZILLA_URI_HEADER
2 #define LIBFILEZILLA_URI_HEADER
6 #include <initializer_list>
29 class FZ_PUBLIC_SYMBOL
uri final
32 uri() noexcept =
default;
51 std::string
to_string(
bool with_query =
true)
const;
54 std::string get_request(
bool with_query =
true)
const;
57 std::string get_authority(
bool with_userinfo)
const;
60 explicit operator bool()
const {
return !empty(); }
75 unsigned short port_{};
104 void resolve(
uri const& base);
108 bool operator!=(
uri const& arg)
const {
return !(*
this == arg); }
111 bool FZ_PRIVATE_SYMBOL parse_authority(std::string_view authority);
123 explicit query_string(std::string_view
const& raw,
bool plus_is_space =
false);
124 explicit query_string(std::pair<std::string, std::string>
const& segment);
125 explicit query_string(std::initializer_list<std::pair<std::string, std::string>>
const& segments);
126 bool set(std::string_view
const& raw,
bool plus_is_space =
false);
128 std::string
to_string(
bool encode_slashes)
const;
130 void remove(std::string
const& key);
131 std::string& operator[](std::string
const& key);
133 std::map<std::string, std::string, less_insensitive_ascii>
const& pairs()
const {
return segments_; }
135 bool empty()
const {
return segments_.empty(); }
138 std::map<std::string, std::string, less_insensitive_ascii> segments_;
The uri class is used to decompose URIs into their individual components.
Definition: uri.hpp:29
bool operator==(symmetric_key const &lhs, symmetric_key const &rhs)
Side-channel safe comparison.
std::string query_
The part of a URI after ? but before #.
Definition: uri.hpp:87
std::string user_
Optional user part of the authority.
Definition: uri.hpp:66
std::string pass_
Optional password part of the authority.
Definition: uri.hpp:69
std::string scheme_
Often referred to as the protocol prefix, e.g. ftp://.
Definition: uri.hpp:63
Class for parsing a URI's query string.
Definition: uri.hpp:119
std::string fragment_
The part of a URI after #.
Definition: uri.hpp:94
The namespace used by libfilezilla.
Definition: apply.hpp:17
std::string host_
Hostname, or IP address literal.
Definition: uri.hpp:72
Sets some global macros and further includes string.hpp.
If parsing a schemeless URI, assume it has an authority, otherwise it's all seen as path...
uri_parsing_flags
Definition: uri.hpp:16
std::string path_
Optional path, must start with a slash if set.
Definition: uri.hpp:78
bool is_absolute() const
Checks that the URI is absolute, that is the path starting with a slash.
Definition: uri.hpp:97
std::string to_string(std::wstring_view const &in)
Converts from std::wstring into std::string in system encoding.