Ada 3.4.4
Fast spec-compliant URL parser
Loading...
Searching...
No Matches
url_aggregator.h
Go to the documentation of this file.
1
11#ifndef ADA_URL_AGGREGATOR_H
12#define ADA_URL_AGGREGATOR_H
13
14#include <ostream>
15#include <string>
16#include <string_view>
17#include <variant>
18
19#include "ada/common_defs.h"
20#include "ada/url_base.h"
21#include "ada/url_components.h"
22
23namespace ada {
24
25namespace parser {}
26
47 url_aggregator() = default;
48 url_aggregator(const url_aggregator &u) = default;
49 url_aggregator(url_aggregator &&u) noexcept = default;
50 url_aggregator &operator=(url_aggregator &&u) noexcept = default;
52 ~url_aggregator() override = default;
53
73 bool set_href(std::string_view input);
74 bool set_host(std::string_view input);
75 bool set_hostname(std::string_view input);
76 bool set_protocol(std::string_view input);
77 bool set_username(std::string_view input);
78 bool set_password(std::string_view input);
79 bool set_port(std::string_view input);
80 bool set_pathname(std::string_view input);
81 void set_search(std::string_view input);
82 void set_hash(std::string_view input);
83
89
96
106
115
124
133
142
151
160
170
177
186
195
202
224
229 [[nodiscard]] std::string to_string() const override;
230
236 [[nodiscard]] std::string to_diagram() const;
237
243
249
255
261
267
273
279
285
291
295 inline void clear_port();
296
300 inline void clear_hash();
301
306
307 private:
308 // helper methods
311 // parse_url methods
314
319
320#if ADA_INCLUDE_URL_PATTERN
321 // url_pattern methods
322 template <url_pattern_regex::regex_concept regex_provider>
323 friend tl::expected<url_pattern<regex_provider>, errors>
325 std::variant<std::string_view, url_pattern_init> &&input,
326 const std::string_view *base_url, const url_pattern_options *options);
327#endif // ADA_INCLUDE_URL_PATTERN
328
329 std::string buffer{};
330 url_components components{};
331
337 [[nodiscard]] ada_really_inline bool is_at_path() const noexcept;
338
339 inline void add_authority_slashes_if_needed();
340
345 constexpr void reserve(uint32_t capacity);
346
347 ada_really_inline size_t parse_port(std::string_view view,
349
350 ada_really_inline size_t parse_port(std::string_view view) override {
351 return this->parse_port(view, false);
352 }
353
360 [[nodiscard]] bool parse_ipv4(std::string_view input, bool in_place);
361
366 [[nodiscard]] bool parse_ipv6(std::string_view input);
367
372 [[nodiscard]] bool parse_opaque_host(std::string_view input);
373
374 ada_really_inline void parse_path(std::string_view input);
375
380 [[nodiscard]] constexpr bool cannot_have_credentials_or_port() const;
381
382 template <bool override_hostname = false>
383 bool set_host_or_hostname(std::string_view input);
384
385 ada_really_inline bool parse_host(std::string_view input);
386
387 inline void update_base_authority(std::string_view base_buffer,
388 const url_components &base);
389 inline void update_unencoded_base_hash(std::string_view input);
390 inline void update_base_hostname(std::string_view input);
391 inline void update_base_search(std::string_view input);
392 inline void update_base_search(std::string_view input,
394 inline void update_base_pathname(std::string_view input);
395 inline void update_base_username(std::string_view input);
396 inline void append_base_username(std::string_view input);
397 inline void update_base_password(std::string_view input);
398 inline void append_base_password(std::string_view input);
399 inline void update_base_port(uint32_t input);
400 inline void append_base_pathname(std::string_view input);
401 [[nodiscard]] inline uint32_t retrieve_base_port() const;
402 constexpr void clear_hostname();
403 constexpr void clear_password();
404 constexpr void clear_pathname() override;
405 [[nodiscard]] constexpr bool has_dash_dot() const noexcept;
406 void delete_dash_dot();
407 inline void consume_prepared_path(std::string_view input);
409 [[nodiscard]] ada_really_inline bool parse_scheme_with_colon(
411 ada_really_inline uint32_t replace_and_resize(uint32_t start, uint32_t end,
413 [[nodiscard]] constexpr bool has_authority() const noexcept;
414 constexpr void set_protocol_as_file();
415 inline void set_scheme(std::string_view new_scheme);
420 inline void set_scheme_from_view_with_colon(
422 inline void copy_scheme(const url_aggregator &u);
423
424 inline void update_host_to_base_host(const std::string_view input);
425
426}; // url_aggregator
427
429} // namespace ada
430
431#endif
Cross-platform compiler macros and common definitions.
#define ada_lifetime_bound
#define ada_really_inline
Definition common_defs.h:85
Definition ada_idna.h:13
errors
Error codes for URL parsing operations.
Definition errors.h:17
ada_warn_unused ada::result< result_type > parse(std::string_view input, const result_type *base_url=nullptr)
Memory-efficient URL representation using a single buffer.
url_aggregator & operator=(const url_aggregator &u)=default
url_aggregator & operator=(url_aggregator &&u) noexcept=default
ada_really_inline const 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
std::string_view get_search() const ada_lifetime_bound
url_aggregator()=default
friend url_aggregator parser::parse_url(std::string_view, const url_aggregator *)
std::string_view get_hash() const ada_lifetime_bound
friend void helpers::strip_trailing_spaces_from_opaque_path(url_aggregator &url)
std::string to_string() const override
std::string_view get_password() const ada_lifetime_bound
std::string_view get_host() const ada_lifetime_bound
std::string_view get_username() const ada_lifetime_bound
friend url_aggregator parser::parse_url_impl(std::string_view, const url_aggregator *)
std::string_view get_port() const 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 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
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
bool set_pathname(std::string_view input)
bool set_href(std::string_view input)
constexpr bool has_hash() const noexcept override
constexpr std::string_view get_pathname() const ada_lifetime_bound
void set_search(std::string_view input)
std::string_view get_hostname() const ada_lifetime_bound
std::string_view get_protocol() const 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
bool set_host(std::string_view input)
bool set_port(std::string_view input)
url_aggregator(const url_aggregator &u)=default
constexpr bool has_non_empty_username() const noexcept
bool set_username(std::string_view input)
Abstract base class for URL representations.
Definition url_base.h:49
Stores byte offsets for URL components within a buffer.
Represents a parsed URL with individual string components.
Definition url.h:62
Base class and common definitions for URL types.
Declaration for the URL Components.