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();
61 if (host.has_value()) {
63 out.host_start =
out.protocol_end + 2;
70 if (!password.empty()) {
76 out.username_end =
out.host_start;
86 out.host_start =
out.protocol_end;
87 out.host_end =
out.host_start;
99 if (port.has_value()) {
108 if (query.has_value()) {
116 if (hash.has_value()) {
123inline void url::update_base_hostname(std::string_view
input) { host =
input; }
125inline void url::update_unencoded_base_hash(std::string_view
input) {
127 hash = unicode::percent_encode(
input,
131inline void url::update_base_search(std::string_view
input,
136inline void url::update_base_search(std::optional<std::string> &&
input) {
137 query = std::move(
input);
140inline void url::update_base_pathname(
const std::string_view
input) {
144inline void url::update_base_username(
const std::string_view
input) {
148inline void url::update_base_password(
const std::string_view
input) {
152inline void url::update_base_port(std::optional<uint16_t>
input) {
156constexpr void url::clear_pathname() { path.clear(); }
158constexpr void url::clear_search() { query = std::nullopt; }
161 return hash.has_value();
165 return query.has_value();
170inline void url::set_scheme(std::string &&
new_scheme)
noexcept {
178constexpr void url::copy_scheme(
ada::url &&
u) {
179 non_special_scheme =
u.non_special_scheme;
183constexpr void url::copy_scheme(
const ada::url &
u) {
184 non_special_scheme =
u.non_special_scheme;
191 if (host.has_value()) {
195 if (!password.empty()) {
201 if (port.has_value()) {
211 if (query.has_value()) {
212 output +=
"?" + query.value();
214 if (hash.has_value()) {
215 output +=
"#" + hash.value();
223 if (!
view.empty() &&
view[0] ==
'-') {
224 ada_log(
"parse_port: view[0] == '0' && view.size() > 1");
230 if (
r.ec == std::errc::result_out_of_range) {
231 ada_log(
"parse_port: r.ec == std::errc::result_out_of_range");
243 ada_log(
"parse_port: is_valid = ", is_valid);
#define ada_really_inline
constexpr uint8_t FRAGMENT_PERCENT_ENCODE[32]
constexpr ada::scheme::type get_scheme_type(std::string_view scheme) noexcept
type
Enumeration of URL scheme types.
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)
Stores byte offsets for URL components within a buffer.
Represents a parsed URL with individual string components.
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
ada_really_inline size_t get_pathname_length() const noexcept
std::string get_search() const
std::string get_port() const
std::string get_protocol() const
bool has_hostname() const noexcept
constexpr std::string_view get_pathname() const noexcept
ada_really_inline std::string get_href() const
const std::string & get_password() const noexcept
constexpr bool has_search() const noexcept override
constexpr bool has_hash() const noexcept override
Declaration for the ada::url class.
Declaration for the URL Components.