5#ifndef ADA_URL_PATTERN_INIT_H
6#define ADA_URL_PATTERN_INIT_H
8#include "ada/expected.h"
20#if ADA_INCLUDE_URL_PATTERN
28 {
f(
sv) } -> std::same_as<tl::expected<std::string, errors>>;
46 case process_type::url:
48 case process_type::pattern:
49 return os <<
"pattern";
51 return os <<
"unknown";
57 static tl::expected<url_pattern_init, errors>
process(
59 std::optional<std::string_view>
protocol = std::nullopt,
60 std::optional<std::string_view> username = std::nullopt,
61 std::optional<std::string_view> password = std::nullopt,
62 std::optional<std::string_view>
hostname = std::nullopt,
63 std::optional<std::string_view> port = std::nullopt,
64 std::optional<std::string_view>
pathname = std::nullopt,
65 std::optional<std::string_view>
search = std::nullopt,
66 std::optional<std::string_view> hash = std::nullopt);
97 static tl::expected<std::string, errors>
process_hash(std::string_view value,
102 *
os <<
"protocol: '" <<
init.protocol.value_or(
"undefined") <<
"', ";
103 *
os <<
"username: '" <<
init.username.value_or(
"undefined") <<
"', ";
104 *
os <<
"password: '" <<
init.password.value_or(
"undefined") <<
"', ";
105 *
os <<
"hostname: '" <<
init.hostname.value_or(
"undefined") <<
"', ";
106 *
os <<
"port: '" <<
init.port.value_or(
"undefined") <<
"', ";
107 *
os <<
"pathname: '" <<
init.pathname.value_or(
"undefined") <<
"', ";
108 *
os <<
"search: '" <<
init.search.value_or(
"undefined") <<
"', ";
109 *
os <<
"hash: '" <<
init.hash.value_or(
"undefined") <<
"', ";
110 *
os <<
"base_url: '" <<
init.base_url.value_or(
"undefined") <<
"', ";
116 std::optional<std::string>
protocol{};
118 std::optional<std::string> username{};
120 std::optional<std::string> password{};
122 std::optional<std::string>
hostname{};
124 std::optional<std::string> port{};
126 std::optional<std::string>
pathname{};
128 std::optional<std::string>
search{};
130 std::optional<std::string> hash{};
132 std::optional<std::string>
base_url{};
Error type definitions for URL parsing.
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)