14#if ADA_REGULAR_VISUAL_STUDIO
20 return !username.empty() || !password.empty();
23 return port.has_value();
25[[
nodiscard]]
inline bool url::cannot_have_credentials_or_port()
const {
26 return !host.has_value() || host.value().empty() ||
30 if (!host.has_value()) {
33 return host.value().empty();
36 return host.has_value();
39 return out <<
u.to_string();
56 if (host.has_value()) {
58 out.host_start =
out.protocol_end + 2;
65 if (!password.empty()) {
71 out.username_end =
out.host_start;
81 out.host_start =
out.protocol_end;
82 out.host_end =
out.host_start;
94 if (port.has_value()) {
103 if (query.has_value()) {
111 if (hash.has_value()) {
118inline void url::update_base_hostname(std::string_view
input) { host =
input; }
120inline void url::update_unencoded_base_hash(std::string_view
input) {
122 hash = unicode::percent_encode(
input,
126inline void url::update_base_search(std::string_view
input,
131inline void url::update_base_search(std::optional<std::string>
input) {
135inline void url::update_base_pathname(
const std::string_view
input) {
139inline void url::update_base_username(
const std::string_view
input) {
143inline void url::update_base_password(
const std::string_view
input) {
147inline void url::update_base_port(std::optional<uint16_t>
input) {
151inline void url::clear_pathname() { path.clear(); }
153inline void url::clear_search() { query = std::nullopt; }
156 return hash.has_value();
160 return query.has_value();
165inline void url::set_scheme(std::string &&
new_scheme)
noexcept {
173inline void url::copy_scheme(
ada::url &&
u)
noexcept {
174 non_special_scheme =
u.non_special_scheme;
178inline void url::copy_scheme(
const ada::url &
u) {
179 non_special_scheme =
u.non_special_scheme;
186 if (host.has_value()) {
190 if (!password.empty()) {
196 if (port.has_value()) {
206 if (query.has_value()) {
207 output +=
"?" + query.value();
209 if (hash.has_value()) {
210 output +=
"#" + hash.value();
220 if (
r.ec == std::errc::result_out_of_range) {
221 ada_log(
"parse_port: std::errc::result_out_of_range");
233 ada_log(
"parse_port: is_valid = ", is_valid);
Declarations for URL specific checkers used within Ada.
#define ada_really_inline
constexpr uint8_t FRAGMENT_PERCENT_ENCODE[32]
ada_really_inline bool begins_with(std::string_view view, std::string_view prefix)
constexpr ada::scheme::type get_scheme_type(std::string_view scheme) noexcept
std::ostream & operator<<(std::ostream &out, const ada::url &u)
ada_warn_unused ada::result< result_type > parse(std::string_view input, const result_type *base_url=nullptr)
URL Component representations using offsets.
Generic URL struct reliant on std::string instantiation.
std::string get_search() const noexcept
ada_really_inline ada::url_components get_components() const noexcept
bool has_empty_hostname() const noexcept
bool has_port() const noexcept
ada_really_inline bool has_credentials() const noexcept
bool has_hash() const noexcept override
ada_really_inline size_t get_pathname_length() const noexcept
ada_really_inline std::string get_href() const noexcept
bool has_hostname() const noexcept
const std::string & get_password() const noexcept
std::string get_port() const noexcept
std::string get_protocol() const noexcept
bool has_search() const noexcept override
Declaration for the URL Components.