Loading...
Searching...
No Matches
url_aggregator.h
Go to the documentation of this file.
#ifndef ADA_URL_AGGREGATOR_H
#define ADA_URL_AGGREGATOR_H
#include <ostream>
#include <string>
#include <string_view>
#include <variant>
#include "ada/common_defs.h"
#include "ada/url_base.h"
#include "ada/url_components.h"
namespace ada {
namespace parser {}
struct url_aggregator : url_base {
url_aggregator() = default;
url_aggregator(const url_aggregator &u) = default;
url_aggregator(url_aggregator &&u) noexcept = default;
url_aggregator &operator=(url_aggregator &&u) noexcept = default;
url_aggregator &operator=(const url_aggregator &u) = default;
~url_aggregator() override = default;
bool set_href(std::string_view input);
bool set_host(std::string_view input);
bool set_hostname(std::string_view input);
bool set_protocol(std::string_view input);
bool set_username(std::string_view input);
bool set_password(std::string_view input);
bool set_port(std::string_view input);
bool set_pathname(std::string_view input);
void set_search(std::string_view input);
void set_hash(std::string_view input);
[[nodiscard]] bool has_valid_domain() const noexcept override;
[[nodiscard]] std::string get_origin() const override;
[[nodiscard]] constexpr std::string_view get_href() const noexcept
ada_lifetime_bound;
[[nodiscard]] std::string_view get_username() const ada_lifetime_bound;
[[nodiscard]] std::string_view get_password() const ada_lifetime_bound;
[[nodiscard]] std::string_view get_port() const ada_lifetime_bound;
[[nodiscard]] std::string_view get_hash() const ada_lifetime_bound;
[[nodiscard]] std::string_view get_host() const ada_lifetime_bound;
[[nodiscard]] std::string_view get_hostname() const ada_lifetime_bound;
[[nodiscard]] constexpr std::string_view get_pathname() const
ada_lifetime_bound;
[[nodiscard]] ada_really_inline uint32_t get_pathname_length() const noexcept;
[[nodiscard]] std::string_view get_search() const ada_lifetime_bound;
[[nodiscard]] std::string_view get_protocol() const ada_lifetime_bound;
[[nodiscard]] ada_really_inline constexpr bool has_credentials()
const noexcept;
[[nodiscard]] ada_really_inline const url_components &get_components()
const noexcept;
[[nodiscard]] std::string to_string() const override;
[[nodiscard]] std::string to_diagram() const;
[[nodiscard]] constexpr bool validate() const noexcept;
[[nodiscard]] constexpr bool has_empty_hostname() const noexcept;
[[nodiscard]] constexpr bool has_hostname() const noexcept;
[[nodiscard]] constexpr bool has_non_empty_username() const noexcept;
[[nodiscard]] constexpr bool has_non_empty_password() const noexcept;
[[nodiscard]] constexpr bool has_port() const noexcept;
[[nodiscard]] constexpr bool has_password() const noexcept;
[[nodiscard]] constexpr bool has_hash() const noexcept override;
[[nodiscard]] constexpr bool has_search() const noexcept override;
inline void clear_port();
inline void clear_hash();
inline void clear_search() override;
private:
// helper methods
friend void helpers::strip_trailing_spaces_from_opaque_path<url_aggregator>(
url_aggregator &url);
// parse_url methods
friend url_aggregator parser::parse_url<url_aggregator>(
std::string_view, const url_aggregator *);
friend url_aggregator parser::parse_url_impl<url_aggregator, true>(
std::string_view, const url_aggregator *);
friend url_aggregator parser::parse_url_impl<url_aggregator, false>(
std::string_view, const url_aggregator *);
#if ADA_INCLUDE_URL_PATTERN
// url_pattern methods
template <url_pattern_regex::regex_concept regex_provider>
friend tl::expected<url_pattern<regex_provider>, errors>
parse_url_pattern_impl(
std::variant<std::string_view, url_pattern_init> &&input,
const std::string_view *base_url, const url_pattern_options *options);
#endif // ADA_INCLUDE_URL_PATTERN
std::string buffer{};
url_components components{};
[[nodiscard]] ada_really_inline bool is_at_path() const noexcept;
inline void add_authority_slashes_if_needed();
constexpr void reserve(uint32_t capacity);
ada_really_inline size_t parse_port(std::string_view view,
bool check_trailing_content) override;
ada_really_inline size_t parse_port(std::string_view view) override {
return this->parse_port(view, false);
}
[[nodiscard]] bool parse_ipv4(std::string_view input, bool in_place);
[[nodiscard]] bool parse_ipv6(std::string_view input);
[[nodiscard]] bool parse_opaque_host(std::string_view input);
ada_really_inline void parse_path(std::string_view input);
[[nodiscard]] constexpr bool cannot_have_credentials_or_port() const;
template <bool override_hostname = false>
bool set_host_or_hostname(std::string_view input);
ada_really_inline bool parse_host(std::string_view input);
inline void update_base_authority(std::string_view base_buffer,
const url_components &base);
inline void update_unencoded_base_hash(std::string_view input);
inline void update_base_hostname(std::string_view input);
inline void update_base_search(std::string_view input);
inline void update_base_search(std::string_view input,
const uint8_t *query_percent_encode_set);
inline void update_base_pathname(std::string_view input);
inline void update_base_username(std::string_view input);
inline void append_base_username(std::string_view input);
inline void update_base_password(std::string_view input);
inline void append_base_password(std::string_view input);
inline void update_base_port(uint32_t input);
inline void append_base_pathname(std::string_view input);
[[nodiscard]] inline uint32_t retrieve_base_port() const;
constexpr void clear_hostname();
constexpr void clear_password();
constexpr void clear_pathname() override;
[[nodiscard]] constexpr bool has_dash_dot() const noexcept;
void delete_dash_dot();
inline void consume_prepared_path(std::string_view input);
template <bool has_state_override = false>
[[nodiscard]] ada_really_inline bool parse_scheme_with_colon(
std::string_view input);
ada_really_inline uint32_t replace_and_resize(uint32_t start, uint32_t end,
std::string_view input);
[[nodiscard]] constexpr bool has_authority() const noexcept;
constexpr void set_protocol_as_file();
inline void set_scheme(std::string_view new_scheme);
inline void set_scheme_from_view_with_colon(
std::string_view new_scheme_with_colon);
inline void copy_scheme(const url_aggregator &u);
inline void update_host_to_base_host(const std::string_view input);
}; // url_aggregator
inline std::ostream &operator<<(std::ostream &out, const url &u);
} // namespace ada
#endif
common_defs.h
Cross-platform compiler macros and common definitions.
ada_lifetime_bound
#define ada_lifetime_bound
Definition common_defs.h:272
ada_really_inline
#define ada_really_inline
Definition common_defs.h:85
ada::helpers
Includes the definitions for helper functions.
ada::parser
Internal URL parsing implementation.
Definition parser-inl.h:16
ada
Definition ada_idna.h:13
ada::errors
errors
Error codes for URL parsing operations.
Definition errors.h:17
ada::url_aggregator::operator=
url_aggregator & operator=(const url_aggregator &u)=default
ada::url_aggregator::operator=
url_aggregator & operator=(url_aggregator &&u) noexcept=default
ada::url_aggregator::get_components
ada_really_inline const url_components & get_components() const noexcept
Definition url_aggregator-inl.h:732
ada::url_aggregator::has_non_empty_password
constexpr bool has_non_empty_password() const noexcept
Definition url_aggregator-inl.h:781
ada::url_aggregator::set_hash
void set_hash(std::string_view input)
Definition url_aggregator.cpp:406
ada::url_aggregator::validate
constexpr bool validate() const noexcept
Definition url_aggregator-inl.h:924
ada::url_aggregator::clear_search
void clear_search() override
Definition url_aggregator-inl.h:596
ada::url_aggregator::get_search
std::string_view get_search() const ada_lifetime_bound
Definition url_aggregator.cpp:792
ada::url_aggregator::url_aggregator
url_aggregator()=default
ada::url_aggregator::parse_url
friend url_aggregator parser::parse_url(std::string_view, const url_aggregator *)
ada::url_aggregator::get_hash
std::string_view get_hash() const ada_lifetime_bound
Definition url_aggregator.cpp:744
ada::url_aggregator::strip_trailing_spaces_from_opaque_path
friend void helpers::strip_trailing_spaces_from_opaque_path(url_aggregator &url)
ada::url_aggregator::to_string
std::string to_string() const override
Definition url_aggregator.cpp:816
ada::url_aggregator::get_password
std::string_view get_password() const ada_lifetime_bound
Definition url_aggregator.cpp:724
ada::url_aggregator::get_host
std::string_view get_host() const ada_lifetime_bound
Definition url_aggregator.cpp:758
ada::url_aggregator::get_username
std::string_view get_username() const ada_lifetime_bound
Definition url_aggregator.cpp:714
ada::url_aggregator::clear_port
void clear_port()
Definition url_aggregator-inl.h:572
ada::url_aggregator::parse_url_impl
friend url_aggregator parser::parse_url_impl(std::string_view, const url_aggregator *)
ada::url_aggregator::get_port
std::string_view get_port() const ada_lifetime_bound
Definition url_aggregator.cpp:734
ada::url_aggregator::to_diagram
std::string to_diagram() const
Definition url_aggregator.cpp:1273
ada::url_aggregator::has_hostname
constexpr bool has_hostname() const noexcept
Definition url_aggregator-inl.h:806
ada::url_aggregator::set_protocol
bool set_protocol(std::string_view input)
Definition url_aggregator.cpp:210
ada::url_aggregator::has_search
constexpr bool has_search() const noexcept override
Definition url_aggregator-inl.h:715
ada::url_aggregator::get_origin
std::string get_origin() const override
Definition url_aggregator.cpp:687
ada::url_aggregator::get_href
constexpr std::string_view get_href() const noexcept ada_lifetime_bound
Definition url_aggregator-inl.h:849
ada::url_aggregator::has_empty_hostname
constexpr bool has_empty_hostname() const noexcept
Definition url_aggregator-inl.h:793
ada::url_aggregator::has_password
constexpr bool has_password() const noexcept
Definition url_aggregator-inl.h:786
ada::url_aggregator::get_pathname_length
ada_really_inline uint32_t get_pathname_length() const noexcept
Definition url_aggregator-inl.h:154
ada::url_aggregator::has_valid_domain
bool has_valid_domain() const noexcept override
Definition url_aggregator.cpp:909
ada::url_aggregator::set_hostname
bool set_hostname(std::string_view input)
Definition url_aggregator.cpp:680
ada::url_aggregator::set_password
bool set_password(std::string_view input)
Definition url_aggregator.cpp:257
ada::url_aggregator::~url_aggregator
~url_aggregator() override=default
ada::url_aggregator::set_pathname
bool set_pathname(std::string_view input)
Definition url_aggregator.cpp:320
ada::url_aggregator::set_href
bool set_href(std::string_view input)
Definition url_aggregator.cpp:426
ada::url_aggregator::has_hash
constexpr bool has_hash() const noexcept override
Definition url_aggregator-inl.h:710
ada::url_aggregator::get_pathname
constexpr std::string_view get_pathname() const ada_lifetime_bound
Definition url_aggregator-inl.h:1094
ada::url_aggregator::set_search
void set_search(std::string_view input)
Definition url_aggregator.cpp:384
ada::url_aggregator::get_hostname
std::string_view get_hostname() const ada_lifetime_bound
Definition url_aggregator.cpp:777
ada::url_aggregator::get_protocol
std::string_view get_protocol() const ada_lifetime_bound
Definition url_aggregator.cpp:810
ada::url_aggregator::has_port
constexpr bool has_port() const noexcept
Definition url_aggregator-inl.h:810
ada::url_aggregator::has_credentials
ada_really_inline constexpr bool has_credentials() const noexcept
Definition url_aggregator-inl.h:720
ada::url_aggregator::clear_hash
void clear_hash()
Definition url_aggregator-inl.h:621
ada::url_aggregator::url_aggregator
url_aggregator(url_aggregator &&u) noexcept=default
ada::url_aggregator::set_host
bool set_host(std::string_view input)
Definition url_aggregator.cpp:673
ada::url_aggregator::set_port
bool set_port(std::string_view input)
Definition url_aggregator.cpp:277
ada::url_aggregator::url_aggregator
url_aggregator(const url_aggregator &u)=default
ada::url_aggregator::has_non_empty_username
constexpr bool has_non_empty_username() const noexcept
Definition url_aggregator-inl.h:776
ada::url_aggregator::set_username
bool set_username(std::string_view input)
Definition url_aggregator.cpp:237
ada::url_base
Abstract base class for URL representations.
Definition url_base.h:49
ada::url_components
Stores byte offsets for URL components within a buffer.
Definition url_components.h:39
ada::url
Represents a parsed URL with individual string components.
Definition url.h:62
url_base.h
Base class and common definitions for URL types.
url_components.h
Declaration for the URL Components.