Ada 2.9.2
Fast spec-compliant URL parser
|
Lightweight URL struct. More...
#include <url_aggregator.h>
Public Member Functions | |
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) |
bool | has_valid_domain () const noexcept override |
std::string | get_origin () const noexcept override |
std::string_view | get_href () const noexcept ada_lifetime_bound |
std::string_view | get_username () const noexcept ada_lifetime_bound |
std::string_view | get_password () const noexcept ada_lifetime_bound |
std::string_view | get_port () const noexcept ada_lifetime_bound |
std::string_view | get_hash () const noexcept ada_lifetime_bound |
std::string_view | get_host () const noexcept ada_lifetime_bound |
std::string_view | get_hostname () const noexcept ada_lifetime_bound |
std::string_view | get_pathname () const noexcept ada_lifetime_bound |
ada_really_inline uint32_t | get_pathname_length () const noexcept |
std::string_view | get_search () const noexcept ada_lifetime_bound |
std::string_view | get_protocol () const noexcept ada_lifetime_bound |
ada_really_inline bool | has_credentials () const noexcept |
ada_really_inline const ada::url_components & | get_components () const noexcept |
std::string | to_string () const override |
std::string | to_diagram () const |
bool | validate () const noexcept |
bool | has_empty_hostname () const noexcept |
bool | has_hostname () const noexcept |
bool | has_non_empty_username () const noexcept |
bool | has_non_empty_password () const noexcept |
bool | has_port () const noexcept |
bool | has_password () const noexcept |
bool | has_hash () const noexcept override |
bool | has_search () const noexcept override |
void | clear_port () |
void | clear_hash () |
void | clear_search () override |
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) |
bool | has_valid_domain () const noexcept override |
std::string | get_origin () const noexcept override |
std::string_view | get_href () const noexcept ada_lifetime_bound |
std::string_view | get_username () const noexcept ada_lifetime_bound |
std::string_view | get_password () const noexcept ada_lifetime_bound |
std::string_view | get_port () const noexcept ada_lifetime_bound |
std::string_view | get_hash () const noexcept ada_lifetime_bound |
std::string_view | get_host () const noexcept ada_lifetime_bound |
std::string_view | get_hostname () const noexcept ada_lifetime_bound |
std::string_view | get_pathname () const noexcept ada_lifetime_bound |
ada_really_inline uint32_t | get_pathname_length () const noexcept |
std::string_view | get_search () const noexcept ada_lifetime_bound |
std::string_view | get_protocol () const noexcept ada_lifetime_bound |
ada_really_inline bool | has_credentials () const noexcept |
ada_really_inline const ada::url_components & | get_components () const noexcept |
std::string | to_string () const override |
std::string | to_diagram () const |
bool | validate () const noexcept |
bool | has_empty_hostname () const noexcept |
bool | has_hostname () const noexcept |
bool | has_non_empty_username () const noexcept |
bool | has_non_empty_password () const noexcept |
bool | has_port () const noexcept |
bool | has_password () const noexcept |
bool | has_hash () const noexcept override |
bool | has_search () const noexcept override |
void | clear_port () |
void | clear_hash () |
void | clear_search () override |
![]() | |
virtual | ~url_base ()=default |
ada_really_inline bool | is_special () const noexcept |
virtual | ~url_base ()=default |
ada_really_inline bool | is_special () const noexcept |
Friends | |
ada::url_aggregator | ada::parser::parse_url (std::string_view, const ada::url_aggregator *) |
void | ada::helpers::strip_trailing_spaces_from_opaque_path (ada::url_aggregator &url) noexcept |
ada::url_aggregator | ada::parser::parse_url_impl (std::string_view, const ada::url_aggregator *) |
ada::url_aggregator | ada::parser::parse_url_impl (std::string_view, const ada::url_aggregator *) |
ada::url_aggregator | ada::parser::parse_url (std::string_view, const ada::url_aggregator *) |
void | ada::helpers::strip_trailing_spaces_from_opaque_path (ada::url_aggregator &url) noexcept |
ada::url_aggregator | ada::parser::parse_url_impl (std::string_view, const ada::url_aggregator *) |
ada::url_aggregator | ada::parser::parse_url_impl (std::string_view, const ada::url_aggregator *) |
Additional Inherited Members | |
![]() | |
bool | is_valid {true} |
bool | has_opaque_path {false} |
url_host_type | host_type = url_host_type::DEFAULT |
Lightweight URL struct.
The url_aggregator class aims to minimize temporary memory allocation while representing a parsed URL. Internally, it contains a single normalized URL (the href), and it makes available the components, mostly using std::string_view.
|
default |
|
default |
|
defaultnoexcept |
|
overridedefault |
|
default |
|
default |
|
defaultnoexcept |
|
overridedefault |
|
inline |
Definition at line 620 of file url_aggregator-inl.h.
References ADA_ASSERT_EQUAL, ADA_ASSERT_TRUE, ada_log, get_hash(), ada::url_components::hash_start, ada::url_components::omitted, to_diagram(), ada::url_components::to_string(), and validate().
|
inline |
|
inline |
Definition at line 571 of file url_aggregator-inl.h.
References ADA_ASSERT_TRUE, ada_log, ada::url_components::hash_start, ada::url_components::host_end, ada::url_components::omitted, ada::url_components::pathname_start, ada::url_components::port, ada::url_components::search_start, and validate().
|
inline |
|
inlineoverridevirtual |
Implements ada::url_base.
Definition at line 595 of file url_aggregator-inl.h.
References ADA_ASSERT_EQUAL, ADA_ASSERT_TRUE, ada_log, get_search(), ada::url_components::hash_start, ada::url_components::omitted, ada::url_components::search_start, to_diagram(), ada::url_components::to_string(), and validate().
|
inlineoverridevirtual |
Implements ada::url_base.
|
nodiscardnoexcept |
Useful for implementing efficient serialization for the URL.
https://user:pass@example.com:1234/foo/bar?baz#quux | | | | ^^^^| | | | | | | | | | ----- hash_start | | | | | |
------— search_start | | | | | ----------------- pathname_start | | | |
------------------— port | | | ----------------------- host_end | |
-------------------------------— host_start | --------------------------------------- username_end
------------------------------------------— protocol_end
Inspired after servo/url
Definition at line 731 of file url_aggregator-inl.h.
|
nodiscardnoexcept |
Useful for implementing efficient serialization for the URL.
https://user:pass@example.com:1234/foo/bar?baz#quux | | | | ^^^^| | | | | | | | | | ----- hash_start | | | | | |
------— search_start | | | | | ----------------- pathname_start | | | |
------------------— port | | | ----------------------- host_end | |
-------------------------------— host_start | --------------------------------------- username_end
------------------------------------------— protocol_end
Inspired after servo/url
|
nodiscardnoexcept |
Return U+0023 (#), followed by this's URL's fragment. This function does not allocate memory.
Definition at line 13863 of file ada.cpp.
References ada_log.
Referenced by clear_hash(), and to_string().
|
nodiscardnoexcept |
Return U+0023 (#), followed by this's URL's fragment. This function does not allocate memory.
|
nodiscardnoexcept |
Return url's host, serialized, followed by U+003A (:) and url's port, serialized. This function does not allocate memory. When there is no host, this function returns the empty view.
Definition at line 13877 of file ada.cpp.
References ada_log.
Referenced by to_string().
|
nodiscardnoexcept |
Return url's host, serialized, followed by U+003A (:) and url's port, serialized. This function does not allocate memory. When there is no host, this function returns the empty view.
|
nodiscardnoexcept |
Return this's URL's host, serialized. This function does not allocate memory. When there is no host, this function returns the empty view.
Definition at line 13896 of file ada.cpp.
References ada_log.
Referenced by has_valid_domain().
|
nodiscardnoexcept |
Return this's URL's host, serialized. This function does not allocate memory. When there is no host, this function returns the empty view.
|
inlinenodiscardnoexcept |
Return the normalized string. This function does not allocate memory. It is highly efficient.
Definition at line 847 of file url_aggregator-inl.h.
References ada_log.
|
inlinenodiscardnoexcept |
Return the normalized string. This function does not allocate memory. It is highly efficient.
|
nodiscardoverridevirtualnoexcept |
The origin getter steps are to return the serialization of this's URL's origin. [HTML]
Implements ada::url_base.
Definition at line 13806 of file ada.cpp.
References ada_log, and ada::parse().
|
nodiscardoverridevirtualnoexcept |
The origin getter steps are to return the serialization of this's URL's origin. [HTML]
Implements ada::url_base.
|
nodiscardnoexcept |
The password getter steps are to return this's URL's password. This function does not allocate memory.
Definition at line 13843 of file ada.cpp.
References ada_log.
Referenced by to_string().
|
nodiscardnoexcept |
The password getter steps are to return this's URL's password. This function does not allocate memory.
|
nodiscardnoexcept |
The pathname getter steps are to return the result of URL path serializing this's URL. This function does not allocate memory.
Definition at line 13911 of file ada.cpp.
References ada_log.
Referenced by to_string().
|
nodiscardnoexcept |
The pathname getter steps are to return the result of URL path serializing this's URL. This function does not allocate memory.
|
nodiscardnoexcept |
Compute the pathname length in bytes without instantiating a view or a string.
Definition at line 156 of file url_aggregator-inl.h.
References ada_log, ada::url_components::hash_start, ada::url_components::omitted, ada::url_components::pathname_start, and ada::url_components::search_start.
|
nodiscardnoexcept |
Compute the pathname length in bytes without instantiating a view or a string.
|
nodiscardnoexcept |
|
nodiscardnoexcept |
Return this's URL's port, serialized. This function does not allocate memory.
|
nodiscardnoexcept |
The protocol getter steps are to return this's URL's scheme, followed by U+003A (:). This function does not allocate memory.
Definition at line 13944 of file ada.cpp.
References ada_log.
Referenced by to_string().
|
nodiscardnoexcept |
The protocol getter steps are to return this's URL's scheme, followed by U+003A (:). This function does not allocate memory.
|
nodiscardnoexcept |
Return U+003F (?), followed by this's URL's query. This function does not allocate memory.
Definition at line 13926 of file ada.cpp.
References ada_log.
Referenced by clear_search(), and to_string().
|
nodiscardnoexcept |
Return U+003F (?), followed by this's URL's query. This function does not allocate memory.
|
nodiscardnoexcept |
The username getter steps are to return this's URL's username. This function does not allocate memory.
Definition at line 13833 of file ada.cpp.
References ada_log.
Referenced by to_string().
|
nodiscardnoexcept |
The username getter steps are to return this's URL's username. This function does not allocate memory.
|
nodiscardnoexcept |
A URL includes credentials if its username or password is not the empty string.
Definition at line 719 of file url_aggregator-inl.h.
References ada_log, has_non_empty_password(), and has_non_empty_username().
Referenced by to_string().
|
nodiscardnoexcept |
A URL includes credentials if its username or password is not the empty string.
|
inlinenodiscardnoexcept |
Definition at line 791 of file url_aggregator-inl.h.
References has_hostname(), ada::url_components::host_end, ada::url_components::host_start, and ada::url_components::username_end.
|
inlinenodiscardnoexcept |
|
inlinenodiscardoverridevirtualnoexcept |
Implements ada::url_base.
Definition at line 709 of file url_aggregator-inl.h.
References ada_log, ada::url_components::hash_start, and ada::url_components::omitted.
|
inlinenodiscardoverridevirtualnoexcept |
Implements ada::url_base.
|
inlinenodiscardnoexcept |
Definition at line 804 of file url_aggregator-inl.h.
Referenced by has_empty_hostname(), and has_port().
|
inlinenodiscardnoexcept |
|
inlinenodiscardnoexcept |
Definition at line 779 of file url_aggregator-inl.h.
References ada_log, ada::url_components::host_start, and ada::url_components::username_end.
Referenced by has_credentials().
|
inlinenodiscardnoexcept |
|
inlinenodiscardnoexcept |
Definition at line 774 of file url_aggregator-inl.h.
References ada_log, ada::url_components::protocol_end, and ada::url_components::username_end.
Referenced by has_credentials().
|
inlinenodiscardnoexcept |
|
inlinenodiscardnoexcept |
Definition at line 784 of file url_aggregator-inl.h.
References ada_log, ada::url_components::host_start, and ada::url_components::username_end.
|
inlinenodiscardnoexcept |
|
inlinenodiscardnoexcept |
Definition at line 808 of file url_aggregator-inl.h.
References ada_log, has_hostname(), ada::url_components::host_end, and ada::url_components::pathname_start.
|
inlinenodiscardnoexcept |
|
inlinenodiscardoverridevirtualnoexcept |
Implements ada::url_base.
Definition at line 714 of file url_aggregator-inl.h.
References ada_log, ada::url_components::omitted, and ada::url_components::search_start.
|
inlinenodiscardoverridevirtualnoexcept |
Implements ada::url_base.
|
nodiscardoverridevirtualnoexcept |
Returns true if this URL has a valid domain as per RFC 1034 and corresponding specifications. Among other things, it requires that the domain string has fewer than 255 octets.
Implements ada::url_base.
Definition at line 14043 of file ada.cpp.
References get_hostname(), ada::url_components::host_end, and ada::url_components::host_start.
|
nodiscardoverridevirtualnoexcept |
Returns true if this URL has a valid domain as per RFC 1034 and corresponding specifications. Among other things, it requires that the domain string has fewer than 255 octets.
Implements ada::url_base.
|
default |
|
default |
|
defaultnoexcept |
|
defaultnoexcept |
void ada::url_aggregator::set_hash | ( | std::string_view | input | ) |
Definition at line 13574 of file ada.cpp.
References ADA_ASSERT_TRUE, and ada_log.
void ada::url_aggregator::set_hash | ( | std::string_view | input | ) |
bool ada::url_aggregator::set_host | ( | std::string_view | input | ) |
Definition at line 13792 of file ada.cpp.
References ADA_ASSERT_TRUE, and ada_log.
bool ada::url_aggregator::set_host | ( | std::string_view | input | ) |
bool ada::url_aggregator::set_hostname | ( | std::string_view | input | ) |
Definition at line 13799 of file ada.cpp.
References ADA_ASSERT_TRUE, and ada_log.
bool ada::url_aggregator::set_hostname | ( | std::string_view | input | ) |
bool ada::url_aggregator::set_href | ( | std::string_view | input | ) |
Definition at line 13594 of file ada.cpp.
References ADA_ASSERT_TRUE, ada_log, tl::expected< T, E >::has_value(), and ada::parse< url_aggregator >().
bool ada::url_aggregator::set_href | ( | std::string_view | input | ) |
bool ada::url_aggregator::set_password | ( | std::string_view | input | ) |
Definition at line 13439 of file ada.cpp.
References ADA_ASSERT_TRUE, ada_log, and ada::unicode::percent_encode_index().
bool ada::url_aggregator::set_password | ( | std::string_view | input | ) |
bool ada::url_aggregator::set_pathname | ( | std::string_view | input | ) |
Definition at line 13493 of file ada.cpp.
References ADA_ASSERT_TRUE, and ada_log.
bool ada::url_aggregator::set_pathname | ( | std::string_view | input | ) |
bool ada::url_aggregator::set_port | ( | std::string_view | input | ) |
Definition at line 13459 of file ada.cpp.
References ADA_ASSERT_TRUE, and ada_log.
bool ada::url_aggregator::set_port | ( | std::string_view | input | ) |
bool ada::url_aggregator::set_protocol | ( | std::string_view | input | ) |
Definition at line 13392 of file ada.cpp.
References ADA_ASSERT_TRUE, and ada_log.
bool ada::url_aggregator::set_protocol | ( | std::string_view | input | ) |
void ada::url_aggregator::set_search | ( | std::string_view | input | ) |
Definition at line 13552 of file ada.cpp.
References ADA_ASSERT_TRUE, ada_log, ada::character_sets::QUERY_PERCENT_ENCODE, and ada::character_sets::SPECIAL_QUERY_PERCENT_ENCODE.
void ada::url_aggregator::set_search | ( | std::string_view | input | ) |
bool ada::url_aggregator::set_username | ( | std::string_view | input | ) |
Definition at line 13419 of file ada.cpp.
References ADA_ASSERT_TRUE, ada_log, and ada::unicode::percent_encode_index().
bool ada::url_aggregator::set_username | ( | std::string_view | input | ) |
|
nodiscard |
Returns a string diagram of this URL.
Definition at line 14408 of file ada.cpp.
References ada::url_components::hash_start, ada::url_components::host_end, ada::url_components::host_start, ada::url_base::is_valid, ada::url_components::omitted, ada::url_components::pathname_start, ada::url_components::protocol_end, ada::url_components::search_start, and ada::url_components::username_end.
Referenced by clear_hash(), clear_search(), and validate().
|
nodiscard |
Returns a string diagram of this URL.
|
nodiscardoverridevirtual |
Returns a string representation of this URL.
Implements ada::url_base.
Definition at line 13950 of file ada.cpp.
References ada_log, get_hash(), get_host(), get_password(), get_pathname(), get_protocol(), get_search(), get_username(), has_credentials(), ada::url_base::has_opaque_path, ada::url_components::hash_start, ada::url_components::host_end, ada::url_components::host_start, ada::url_base::is_valid, ada::url_components::omitted, ada::url_components::pathname_start, ada::url_components::port, ada::url_components::protocol_end, ada::url_components::search_start, and ada::url_components::username_end.
Referenced by ada::operator<<().
|
nodiscardoverridevirtual |
Returns a string representation of this URL.
Implements ada::url_base.
|
nodiscardnoexcept |
Verifies that the parsed URL could be valid. Useful for debugging purposes.
https://user:pass@example.com:1234/foo/bar?baz#quux | | | | ^^^^| | | | | | | | | | ----- hash_start | | | | | |
------— search_start | | | | | ----------------- pathname_start | | | |
------------------— port | | | ----------------------- host_end | |
-------------------------------— host_start | --------------------------------------- username_end
------------------------------------------— protocol_end
https://user:pass@example.com:1234/foo/bar?baz#quux | | | | ^^^^| | | | | | | | | | ----- hash_start | | | | | |
------— search_start | | | | | ----------------- pathname_start | | | |
------------------— port | | | ----------------------- host_end | |
-------------------------------— host_start | --------------------------------------- username_end
------------------------------------------— protocol_end
Definition at line 14565 of file ada.cpp.
References ada_log, ada::url_components::check_offset_consistency(), ada::url_base::has_opaque_path, ada::url_components::hash_start, ada::url_components::host_end, ada::url_components::host_start, ada::url_base::is_valid, ada::url_components::omitted, ada::url_components::pathname_start, ada::url_components::protocol_end, ada::url_components::search_start, to_diagram(), and ada::url_components::username_end.
Referenced by clear_hash(), clear_port(), and clear_search().
|
nodiscardnoexcept |
Verifies that the parsed URL could be valid. Useful for debugging purposes.
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |