Ada 4.1.1
Fast spec-compliant URL parser
Loading...
Searching...
No Matches
parser.h
Go to the documentation of this file.
1
11#ifndef ADA_PARSER_H
12#define ADA_PARSER_H
13
14#include <cstddef>
15#include <cstdint>
16#include <string_view>
17#include <variant>
18
19#include "ada/expected.h"
20#include "ada/scheme.h"
21
24
26namespace ada {
27struct url_aggregator;
28struct url;
29#if ADA_INCLUDE_URL_PATTERN
30template <url_pattern_regex::regex_concept regex_provider>
31class url_pattern;
32struct url_pattern_options;
33#endif // ADA_INCLUDE_URL_PATTERN
34enum class errors : uint8_t;
35} // namespace ada
36
44namespace ada::parser {
58template <typename result_type = url_aggregator>
59result_type parse_url(std::string_view user_input,
60 const result_type* base_url = nullptr);
61
63 std::string_view user_input, const url_aggregator* base_url);
64extern template url parse_url<url>(std::string_view user_input,
65 const url* base_url);
66
67template <typename result_type = url_aggregator, bool store_values = true>
68result_type parse_url_impl(std::string_view user_input,
69 const result_type* base_url = nullptr);
70
72 std::string_view user_input, const url_aggregator* base_url);
74 std::string_view user_input, const url_aggregator* base_url);
75extern template url parse_url_impl<url, true>(std::string_view user_input,
76 const url* base_url);
77
79template <class result_type>
80bool try_parse_simple_absolute(std::string_view input, result_type& out);
81
83template <class result_type>
84bool finish_simple_absolute_with_port(std::string_view input, result_type& out,
85 ada::scheme::type scheme_type,
86 uint32_t protocol_end, size_t host_start,
87 size_t host_end, size_t host_len,
88 bool has_upper);
89
91template <class result_type>
92bool try_parse_simple_relative(std::string_view input, const result_type& base,
93 result_type& out);
94
95#if ADA_INCLUDE_URL_PATTERN
96template <url_pattern_regex::regex_concept regex_provider>
97tl::expected<url_pattern<regex_provider>, errors> parse_url_pattern_impl(
98 std::variant<std::string_view, url_pattern_init>&& input,
99 const std::string_view* base_url, const url_pattern_options* options);
100#endif // ADA_INCLUDE_URL_PATTERN
101
102} // namespace ada::parser
103
104#endif // ADA_PARSER_H
Internal URL parsing implementation.
Definition parser-inl.h:18
template url parse_url< url >(std::string_view user_input, const url *base_url)
result_type parse_url(std::string_view user_input, const result_type *base_url=nullptr)
Definition parser.cpp:2889
template url parse_url_impl< url, true >(std::string_view user_input, const url *base_url)
template url_aggregator parse_url_impl< url_aggregator, false >(std::string_view user_input, const url_aggregator *base_url)
template url_aggregator parse_url< url_aggregator >(std::string_view user_input, const url_aggregator *base_url)
template url_aggregator parse_url_impl< url_aggregator, true >(std::string_view user_input, const url_aggregator *base_url)
result_type parse_url_impl(std::string_view user_input, const result_type *base_url=nullptr)
Definition parser.cpp:1841
type
Enumeration of URL scheme types.
Definition scheme.h:43
errors
Error codes for URL parsing operations.
Definition errors.h:17
URL scheme type definitions and utilities.
Memory-efficient URL representation using a single buffer.
Represents a parsed URL with individual string components.
Definition url.h:64
Declaration for the url_pattern_init implementation.