1#ifndef LIBFILEZILLA_URI_HEADER
2#define LIBFILEZILLA_URI_HEADER
6#include <initializer_list>
29class FZ_PUBLIC_SYMBOL uri final
32 uri()
noexcept =
default;
51 std::string
to_string(
bool with_query =
true)
const;
61 explicit operator bool()
const {
return !empty(); }
107 bool operator==(uri
const& arg)
const;
109 bool operator!=(uri
const& arg)
const {
return !(*
this == arg); }
112 bool FZ_PRIVATE_SYMBOL parse_authority(std::string_view authority);
120class FZ_PUBLIC_SYMBOL query_string final
123 explicit query_string() =
default;
124 explicit query_string(std::string_view
const& raw,
bool plus_is_space =
false);
125 explicit query_string(std::pair<std::string, std::string>
const& segment);
126 explicit query_string(std::initializer_list<std::pair<std::string, std::string>>
const& segments);
127 bool set(std::string_view
const& raw,
bool plus_is_space =
false);
129 std::string to_string(
bool encode_slashes)
const;
131 void remove(std::string
const& key);
132 std::string& operator[](std::string
const& key);
134 std::map<std::string, std::string, less_insensitive_ascii>
const& pairs()
const {
return segments_; }
136 bool empty()
const {
return segments_.empty(); }
139 std::map<std::string, std::string, less_insensitive_ascii> segments_;
std::string get_authority(bool with_userinfo) const
Returns [user[:pass]@]host[:port] Keeps valid bracketed IPv6 literals unchanged; percent-encodes othe...
std::string user_
Optional user part of the authority.
Definition uri.hpp:67
std::string query_
The part of a URI after ? but before #.
Definition uri.hpp:88
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:70
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:64
std::string path_
Optional path, must start with a slash if set.
Definition uri.hpp:79
std::string fragment_
The part of a URI after #.
Definition uri.hpp:95
unsigned short port_
Optional Port if non-zero.
Definition uri.hpp:76
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:98
bool parse(std::string_view in, uri_parsing_flags flags={})
Splits uri into components.
std::string host_
Hostname, or IP address literal.
Definition uri.hpp:73
Sets some global macros and further includes string.hpp.
The namespace used by libfilezilla.
Definition apply.hpp:17
uri_parsing_flags
Definition uri.hpp:17
@ assume_authority
If parsing a schemeless URI, assume it has an authority, otherwise it's all seen as path.
Definition uri.hpp:21