Ada 2.9.2
Fast spec-compliant URL parser
Loading...
Searching...
No Matches
url_aggregator.h
Go to the documentation of this file.
1
5#ifndef ADA_URL_AGGREGATOR_H
6#define ADA_URL_AGGREGATOR_H
7
8#include <string>
9#include <string_view>
10
11#include "ada/common_defs.h"
12#include "ada/url_base.h"
13#include "ada/url_components.h"
14
15namespace ada {
16
26 url_aggregator() = default;
27 url_aggregator(const url_aggregator &u) = default;
28 url_aggregator(url_aggregator &&u) noexcept = default;
29 url_aggregator &operator=(url_aggregator &&u) noexcept = default;
31 ~url_aggregator() override = default;
32
33 bool set_href(std::string_view input);
34 bool set_host(std::string_view input);
35 bool set_hostname(std::string_view input);
36 bool set_protocol(std::string_view input);
37 bool set_username(std::string_view input);
38 bool set_password(std::string_view input);
39 bool set_port(std::string_view input);
40 bool set_pathname(std::string_view input);
41 void set_search(std::string_view input);
42 void set_hash(std::string_view input);
43
44 [[nodiscard]] bool has_valid_domain() const noexcept override;
51 [[nodiscard]] std::string get_origin() const noexcept override;
60 [[nodiscard]] constexpr std::string_view get_href() const noexcept
68 [[nodiscard]] std::string_view get_username() const noexcept
76 [[nodiscard]] std::string_view get_password() const noexcept
84 [[nodiscard]] std::string_view get_port() const noexcept ada_lifetime_bound;
91 [[nodiscard]] std::string_view get_hash() const noexcept ada_lifetime_bound;
100 [[nodiscard]] std::string_view get_host() const noexcept ada_lifetime_bound;
108 [[nodiscard]] std::string_view get_hostname() const noexcept
117 [[nodiscard]] constexpr std::string_view get_pathname() const noexcept
125 [[nodiscard]] ada_really_inline uint32_t get_pathname_length() const noexcept;
132 [[nodiscard]] std::string_view get_search() const noexcept ada_lifetime_bound;
140 [[nodiscard]] std::string_view get_protocol() const noexcept
142
147 [[nodiscard]] ada_really_inline constexpr bool has_credentials()
148 const noexcept;
149
171 [[nodiscard]] ada_really_inline const ada::url_components &get_components()
172 const noexcept;
176 [[nodiscard]] std::string to_string() const override;
180 [[nodiscard]] std::string to_diagram() const;
181
187 [[nodiscard]] constexpr bool validate() const noexcept;
188
190 [[nodiscard]] constexpr bool has_empty_hostname() const noexcept;
192 [[nodiscard]] constexpr bool has_hostname() const noexcept;
194 [[nodiscard]] constexpr bool has_non_empty_username() const noexcept;
196 [[nodiscard]] constexpr bool has_non_empty_password() const noexcept;
198 [[nodiscard]] constexpr bool has_port() const noexcept;
200 [[nodiscard]] constexpr bool has_password() const noexcept;
202 [[nodiscard]] constexpr bool has_hash() const noexcept override;
204 [[nodiscard]] constexpr bool has_search() const noexcept override;
205
206 inline void clear_port();
207 inline void clear_hash();
208 inline void clear_search() override;
209
210 private:
212 std::string_view, const ada::url_aggregator *);
216 ada::url_aggregator, true>(std::string_view, const ada::url_aggregator *);
218 ada::parser::parse_url_impl<ada::url_aggregator, false>(
219 std::string_view, const ada::url_aggregator *);
220
221 std::string buffer{};
222 url_components components{};
223
229 [[nodiscard]] ada_really_inline bool is_at_path() const noexcept;
230
231 inline void add_authority_slashes_if_needed() noexcept;
232
237 constexpr void reserve(uint32_t capacity);
238
239 ada_really_inline size_t parse_port(
240 std::string_view view, bool check_trailing_content) noexcept override;
241
242 ada_really_inline size_t parse_port(std::string_view view) noexcept override {
243 return this->parse_port(view, false);
244 }
245
252 [[nodiscard]] bool parse_ipv4(std::string_view input, bool in_place);
253
258 [[nodiscard]] bool parse_ipv6(std::string_view input);
259
264 [[nodiscard]] bool parse_opaque_host(std::string_view input);
265
266 ada_really_inline void parse_path(std::string_view input);
267
272 [[nodiscard]] constexpr bool cannot_have_credentials_or_port() const;
273
274 template <bool override_hostname = false>
275 bool set_host_or_hostname(std::string_view input);
276
277 ada_really_inline bool parse_host(std::string_view input);
278
279 inline void update_base_authority(std::string_view base_buffer,
280 const ada::url_components &base);
281 inline void update_unencoded_base_hash(std::string_view input);
282 inline void update_base_hostname(std::string_view input);
283 inline void update_base_search(std::string_view input);
284 inline void update_base_search(std::string_view input,
285 const uint8_t *query_percent_encode_set);
286 inline void update_base_pathname(std::string_view input);
287 inline void update_base_username(std::string_view input);
288 inline void append_base_username(std::string_view input);
289 inline void update_base_password(std::string_view input);
290 inline void append_base_password(std::string_view input);
291 inline void update_base_port(uint32_t input);
292 inline void append_base_pathname(std::string_view input);
293 [[nodiscard]] inline uint32_t retrieve_base_port() const;
294 constexpr void clear_hostname();
295 constexpr void clear_password();
296 constexpr void clear_pathname() override;
297 [[nodiscard]] constexpr bool has_dash_dot() const noexcept;
298 void delete_dash_dot();
299 inline void consume_prepared_path(std::string_view input);
300 template <bool has_state_override = false>
301 [[nodiscard]] ada_really_inline bool parse_scheme_with_colon(
302 std::string_view input);
303 ada_really_inline uint32_t replace_and_resize(uint32_t start, uint32_t end,
304 std::string_view input);
305 [[nodiscard]] constexpr bool has_authority() const noexcept;
306 constexpr void set_protocol_as_file();
307 inline void set_scheme(std::string_view new_scheme) noexcept;
312 inline void set_scheme_from_view_with_colon(
313 std::string_view new_scheme_with_colon) noexcept;
314 inline void copy_scheme(const url_aggregator &u) noexcept;
315
316 inline void update_host_to_base_host(const std::string_view input) noexcept;
317
318}; // url_aggregator
319
320inline std::ostream &operator<<(std::ostream &out, const ada::url &u);
321} // namespace ada
322
323#endif
Common definitions for cross-platform compiler support.
#define ada_lifetime_bound
#define ada_really_inline
Definition common_defs.h:77
Definition ada_idna.h:13
Lightweight URL struct.
url_aggregator & operator=(const url_aggregator &u)=default
url_aggregator & operator=(url_aggregator &&u) noexcept=default
ada_really_inline const ada::url_components & get_components() const noexcept
constexpr bool has_non_empty_password() const noexcept
void set_hash(std::string_view input)
constexpr bool validate() const noexcept
void clear_search() override
url_aggregator()=default
std::string_view get_hostname() const noexcept ada_lifetime_bound
friend void ada::helpers::strip_trailing_spaces_from_opaque_path(ada::url_aggregator &url) noexcept
friend ada::url_aggregator ada::parser::parse_url(std::string_view, const ada::url_aggregator *)
std::string to_string() const override
std::string_view get_hash() const noexcept ada_lifetime_bound
std::string to_diagram() const
constexpr bool has_hostname() const noexcept
bool set_protocol(std::string_view input)
constexpr bool has_search() const noexcept override
std::string get_origin() const noexcept override
constexpr std::string_view get_href() const noexcept ada_lifetime_bound
constexpr bool has_empty_hostname() const noexcept
constexpr bool has_password() const noexcept
std::string_view get_search() const noexcept ada_lifetime_bound
ada_really_inline uint32_t get_pathname_length() const noexcept
bool has_valid_domain() const noexcept override
bool set_hostname(std::string_view input)
bool set_password(std::string_view input)
~url_aggregator() override=default
constexpr std::string_view get_pathname() const noexcept ada_lifetime_bound
bool set_pathname(std::string_view input)
std::string_view get_protocol() const noexcept ada_lifetime_bound
std::string_view get_password() const noexcept ada_lifetime_bound
bool set_href(std::string_view input)
constexpr bool has_hash() const noexcept override
void set_search(std::string_view input)
std::string_view get_port() const noexcept ada_lifetime_bound
constexpr bool has_port() const noexcept
ada_really_inline constexpr bool has_credentials() const noexcept
url_aggregator(url_aggregator &&u) noexcept=default
friend ada::url_aggregator ada::parser::parse_url_impl(std::string_view, const ada::url_aggregator *)
bool set_host(std::string_view input)
std::string_view get_host() const noexcept ada_lifetime_bound
bool set_port(std::string_view input)
url_aggregator(const url_aggregator &u)=default
constexpr bool has_non_empty_username() const noexcept
std::string_view get_username() const noexcept ada_lifetime_bound
bool set_username(std::string_view input)
Base class of URL implementations.
Definition url_base.h:44
URL Component representations using offsets.
Generic URL struct reliant on std::string instantiation.
Definition url.h:38
Declaration for the basic URL definitions.
Declaration for the URL Components.