Ada 2.7.8
Fast spec-compliant URL parser
|
Lightweight URL struct. More...
#include <url_aggregator.h>
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 |
Additional Inherited Members | |
Public Attributes inherited from ada::url_base | |
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.
Definition at line 25 of file url_aggregator.h.
|
default |
|
default |
|
defaultnoexcept |
|
overridedefault |
|
inline |
Definition at line 620 of file url_aggregator-inl.h.
References ADA_ASSERT_EQUAL, ADA_ASSERT_TRUE, get_hash(), ada::url_components::hash_start, ada::url_components::omitted, ada::parse(), to_diagram(), ada::url_components::to_string(), and validate().
|
inline |
Definition at line 571 of file url_aggregator-inl.h.
References ADA_ASSERT_TRUE, ada::url_components::hash_start, ada::url_components::host_end, ada::url_components::omitted, ada::parse(), ada::url_components::pathname_start, ada::url_components::port, ada::url_components::search_start, and validate().
Referenced by set_port().
|
inlineoverridevirtual |
Implements ada::url_base.
Definition at line 595 of file url_aggregator-inl.h.
References ADA_ASSERT_EQUAL, ADA_ASSERT_TRUE, get_search(), ada::url_components::hash_start, ada::url_components::omitted, ada::parse(), ada::url_components::search_start, to_diagram(), ada::url_components::to_string(), and validate().
Referenced by set_search().
|
noexcept |
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.
|
noexcept |
Return U+0023 (#), followed by this's URL's fragment. This function does not allocate memory.
Definition at line 678 of file url_aggregator.cpp.
References ada::url_components::hash_start, ada::url_components::omitted, and ada::parse().
Referenced by clear_hash().
|
noexcept |
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 691 of file url_aggregator.cpp.
References ada::url_components::host_end, ada::url_components::host_start, ada::parse(), and ada::url_components::pathname_start.
Referenced by get_origin().
|
noexcept |
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 709 of file url_aggregator.cpp.
References ada::url_components::host_end, ada::url_components::host_start, and ada::parse().
Referenced by has_valid_domain().
|
inlinenoexcept |
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::parse().
|
overridevirtualnoexcept |
The origin getter steps are to return the serialization of this's URL's origin. [HTML]
Implements ada::url_base.
Definition at line 624 of file url_aggregator.cpp.
References ada::scheme::FILE, get_host(), get_pathname(), get_protocol(), ada::scheme::HTTP, ada::scheme::HTTPS, ada::url_base::is_special(), and ada::parse().
|
noexcept |
The password getter steps are to return this's URL's password. This function does not allocate memory.
Definition at line 660 of file url_aggregator.cpp.
References has_non_empty_password(), ada::url_components::host_start, ada::parse(), and ada::url_components::username_end.
|
noexcept |
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 723 of file url_aggregator.cpp.
References ada::url_components::hash_start, ada::url_components::omitted, ada::parse(), ada::url_components::pathname_start, and ada::url_components::search_start.
Referenced by get_origin().
|
noexcept |
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::url_components::hash_start, ada::url_components::omitted, ada::parse(), ada::url_components::pathname_start, and ada::url_components::search_start.
|
noexcept |
Return this's URL's port, serialized. This function does not allocate memory.
Definition at line 669 of file url_aggregator.cpp.
References ada::url_components::host_end, ada::url_components::omitted, ada::parse(), ada::url_components::pathname_start, and ada::url_components::port.
|
noexcept |
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 754 of file url_aggregator.cpp.
References ada::parse(), and ada::url_components::protocol_end.
Referenced by get_origin().
|
noexcept |
Return U+003F (?), followed by this's URL's query. This function does not allocate memory.
Definition at line 737 of file url_aggregator.cpp.
References ada::url_components::hash_start, ada::url_components::omitted, ada::parse(), and ada::url_components::search_start.
Referenced by clear_search().
|
noexcept |
The username getter steps are to return this's URL's username. This function does not allocate memory.
Definition at line 651 of file url_aggregator.cpp.
References has_non_empty_username(), ada::parse(), ada::url_components::protocol_end, and ada::url_components::username_end.
|
noexcept |
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 has_non_empty_password(), has_non_empty_username(), and ada::parse().
|
inlinenoexcept |
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.
|
inlineoverridevirtualnoexcept |
Implements ada::url_base.
Definition at line 709 of file url_aggregator-inl.h.
References ada::url_components::hash_start, ada::url_components::omitted, and ada::parse().
|
inlinenoexcept |
Definition at line 804 of file url_aggregator-inl.h.
Referenced by has_empty_hostname(), and has_port().
|
inlinenoexcept |
Definition at line 779 of file url_aggregator-inl.h.
References ada::url_components::host_start, ada::parse(), and ada::url_components::username_end.
Referenced by get_password(), and has_credentials().
|
inlinenoexcept |
Definition at line 774 of file url_aggregator-inl.h.
References ada::parse(), ada::url_components::protocol_end, and ada::url_components::username_end.
Referenced by get_username(), and has_credentials().
|
inlinenoexcept |
Definition at line 784 of file url_aggregator-inl.h.
References ada::url_components::host_start, ada::parse(), and ada::url_components::username_end.
|
inlinenoexcept |
Definition at line 808 of file url_aggregator-inl.h.
References has_hostname(), ada::url_components::host_end, ada::parse(), and ada::url_components::pathname_start.
|
inlineoverridevirtualnoexcept |
Implements ada::url_base.
Definition at line 714 of file url_aggregator-inl.h.
References ada::url_components::omitted, ada::parse(), and ada::url_components::search_start.
|
overridevirtualnoexcept |
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 852 of file url_aggregator.cpp.
References get_hostname(), ada::url_components::host_end, and ada::url_components::host_start.
|
default |
|
defaultnoexcept |
void ada::url_aggregator::set_hash | ( | std::string_view | input | ) |
Definition at line 392 of file url_aggregator.cpp.
References ADA_ASSERT_TRUE, ada::url_components::hash_start, ada::url_components::omitted, ada::parse(), and validate().
bool ada::url_aggregator::set_host | ( | std::string_view | input | ) |
Definition at line 610 of file url_aggregator.cpp.
References ADA_ASSERT_TRUE, ada::parse(), and validate().
bool ada::url_aggregator::set_hostname | ( | std::string_view | input | ) |
Definition at line 617 of file url_aggregator.cpp.
References ADA_ASSERT_TRUE, ada::parse(), and validate().
bool ada::url_aggregator::set_href | ( | std::string_view | input | ) |
Definition at line 412 of file url_aggregator.cpp.
References ADA_ASSERT_TRUE, ada::parse(), and ada::parse< url_aggregator >().
bool ada::url_aggregator::set_password | ( | std::string_view | input | ) |
Definition at line 257 of file url_aggregator.cpp.
References ADA_ASSERT_TRUE, ada::parse(), ada::unicode::percent_encode_index(), ada::character_sets::USERINFO_PERCENT_ENCODE, and validate().
bool ada::url_aggregator::set_pathname | ( | std::string_view | input | ) |
Definition at line 311 of file url_aggregator.cpp.
References ADA_ASSERT_TRUE, ada::checkers::begins_with(), ada::url_base::has_opaque_path, ada::parse(), ada::url_components::pathname_start, and validate().
bool ada::url_aggregator::set_port | ( | std::string_view | input | ) |
Definition at line 277 of file url_aggregator.cpp.
References ADA_ASSERT_TRUE, clear_port(), ada::url_base::is_valid, ada::parse(), ada::url_components::port, and validate().
bool ada::url_aggregator::set_protocol | ( | std::string_view | input | ) |
Definition at line 210 of file url_aggregator.cpp.
References ADA_ASSERT_TRUE, ada::checkers::is_alpha(), ada::parse(), and validate().
void ada::url_aggregator::set_search | ( | std::string_view | input | ) |
Definition at line 370 of file url_aggregator.cpp.
References ADA_ASSERT_TRUE, clear_search(), ada::url_base::is_special(), ada::parse(), ada::character_sets::QUERY_PERCENT_ENCODE, ada::character_sets::SPECIAL_QUERY_PERCENT_ENCODE, and validate().
bool ada::url_aggregator::set_username | ( | std::string_view | input | ) |
Definition at line 237 of file url_aggregator.cpp.
References ADA_ASSERT_TRUE, ada::parse(), ada::unicode::percent_encode_index(), ada::character_sets::USERINFO_PERCENT_ENCODE, and validate().
std::string ada::url_aggregator::to_diagram | ( | ) | const |
Returns a string diagram of this URL.
Definition at line 1217 of file url_aggregator.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::parse(), 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().
|
overridevirtual |
Returns a string representation of this URL.
Implements ada::url_base.
Definition at line 759 of file url_aggregator.cpp.
References ada::url_components::omitted, and ada::parse().
|
noexcept |
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
Definition at line 1374 of file url_aggregator.cpp.
References 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::parse(), 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(), clear_search(), set_hash(), set_host(), set_hostname(), set_password(), set_pathname(), set_port(), set_protocol(), set_search(), and set_username().
|
friend |
|
friend |