11 std::optional<std::string_view>
protocol,
12 std::optional<std::string_view>
username,
13 std::optional<std::string_view>
password,
14 std::optional<std::string_view>
hostname,
15 std::optional<std::string_view>
port,
16 std::optional<std::string_view>
pathname,
17 std::optional<std::string_view>
search,
18 std::optional<std::string_view>
hash) {
47 std::optional<url_aggregator>
base_url{};
54 if (!parsing_result) {
57 base_url = std::move(*parsing_result);
63 std::string_view base_url_protocol =
base_url->get_protocol();
64 if (base_url_protocol.ends_with(
":")) base_url_protocol.remove_suffix(1);
93 auto base_host =
base_url->get_hostname();
142 if (!process_result) {
143 return tl::unexpected(process_result.error());
145 result.protocol = std::move(*process_result);
152 if (!process_result) {
153 return tl::unexpected(process_result.error());
155 result.username = std::move(*process_result);
162 if (!process_result) {
163 return tl::unexpected(process_result.error());
165 result.password = std::move(*process_result);
172 if (!process_result) {
173 return tl::unexpected(process_result.error());
175 result.hostname = std::move(*process_result);
181 auto process_result =
183 if (!process_result) {
184 return tl::unexpected(process_result.error());
186 result.port = std::move(*process_result);
209 auto slash_index = base_url_path.find_last_of(
'/');
212 if (slash_index != std::string::npos) {
215 std::string new_pathname = base_url_path.substr(0, slash_index + 1);
218 new_pathname.append(
result.pathname.value());
220 result.pathname = std::move(new_pathname);
226 auto pathname_processing_result =
228 if (!pathname_processing_result) {
229 return tl::unexpected(pathname_processing_result.error());
231 result.pathname = std::move(*pathname_processing_result);
238 if (!process_result) {
239 return tl::unexpected(process_result.error());
241 result.search = std::move(*process_result);
248 if (!process_result) {
249 return tl::unexpected(process_result.error());
251 result.hash = std::move(*process_result);
258 std::string_view value, std::string_view type) {
259 ada_log(
"process_protocol=", value,
" [", type,
"]");
262 if (value.ends_with(
":")) {
263 value.remove_suffix(1);
266 if (type ==
"pattern") {
267 return std::string(value);
274 std::string_view value, std::string_view type) {
276 if (type ==
"pattern") {
277 return std::string(value);
284 std::string_view value, std::string_view type) {
286 if (type ==
"pattern") {
287 return std::string(value);
294 std::string_view value, std::string_view type) {
295 ada_log(
"process_hostname value=", value,
" type=", type);
297 if (type ==
"pattern") {
298 return std::string(value);
305 std::string_view
port, std::string_view
protocol, std::string_view type) {
307 if (type ==
"pattern") {
308 return std::string(
port);
316 std::string_view value, std::string_view
protocol, std::string_view type) {
318 if (type ==
"pattern") {
319 return std::string(value);
334 std::string_view value, std::string_view type) {
337 if (value.starts_with(
"?")) {
338 value.remove_prefix(1);
342 if (type ==
"pattern") {
343 return std::string(value);
350 std::string_view value, std::string_view type) {
353 if (value.starts_with(
"#")) {
354 value.remove_prefix(1);
358 if (type ==
"pattern") {
359 return std::string(value);
#define ADA_ASSERT_TRUE(COND)
tl::expected< std::string, errors > canonicalize_opaque_pathname(std::string_view input)
tl::expected< std::string, errors > canonicalize_pathname(std::string_view input)
constexpr bool is_absolute_pathname(std::string_view input, std::string_view type) noexcept
tl::expected< std::string, errors > canonicalize_password(std::string_view input)
std::string process_base_url_string(std::string_view input, std::string_view type)
tl::expected< std::string, errors > canonicalize_protocol(std::string_view input)
tl::expected< std::string, errors > canonicalize_hostname(std::string_view input)
tl::expected< std::string, errors > canonicalize_port_with_protocol(std::string_view input, std::string_view protocol)
tl::expected< std::string, errors > canonicalize_hash(std::string_view input)
tl::expected< std::string, errors > canonicalize_search(std::string_view input)
tl::expected< std::string, errors > canonicalize_username(std::string_view input)
template ada::result< url_aggregator > parse< url_aggregator >(std::string_view input, const url_aggregator *base_url)
tl::expected< result_type, ada::errors > result
std::optional< std::string > port
static tl::expected< std::string, errors > process_pathname(std::string_view value, std::string_view protocol, std::string_view type)
static tl::expected< std::string, errors > process_username(std::string_view value, std::string_view type)
static tl::expected< std::string, errors > process_port(std::string_view port, std::string_view protocol, std::string_view type)
static tl::expected< std::string, errors > process_hostname(std::string_view value, std::string_view type)
std::optional< std::string > protocol
static tl::expected< url_pattern_init, errors > process(url_pattern_init init, std::string_view type, std::optional< std::string_view > protocol=std::nullopt, std::optional< std::string_view > username=std::nullopt, std::optional< std::string_view > password=std::nullopt, std::optional< std::string_view > hostname=std::nullopt, std::optional< std::string_view > port=std::nullopt, std::optional< std::string_view > pathname=std::nullopt, std::optional< std::string_view > search=std::nullopt, std::optional< std::string_view > hash=std::nullopt)
std::optional< std::string > password
std::optional< std::string > base_url
std::optional< std::string > hostname
std::optional< std::string > search
static tl::expected< std::string, errors > process_hash(std::string_view value, std::string_view type)
static tl::expected< std::string, errors > process_password(std::string_view value, std::string_view type)
std::optional< std::string > username
std::optional< std::string > pathname
static tl::expected< std::string, errors > process_search(std::string_view value, std::string_view type)
std::optional< std::string > hash
static tl::expected< std::string, errors > process_protocol(std::string_view value, std::string_view type)
Declaration for the URLPattern inline functions.