Ada 2.7.8
Fast spec-compliant URL parser
|
Generic URL struct reliant on std::string instantiation. More...
#include <url.h>
Friends | |
ada::url | ada::parser::parse_url (std::string_view, const ada::url *) |
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 &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 |
Generic URL struct reliant on std::string instantiation.
To disambiguate from a valid URL string it can also be referred to as a URL record. A URL is a struct that represents a universal identifier. Unlike the url_aggregator, the ada::url represents the different components of a parsed URL as independent std::string instances. This makes the structure heavier and more reliant on memory allocations. When getting components from the parsed URL, a new std::string is typically constructed.
|
default |
|
defaultnoexcept |
|
overridedefault |
|
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 46 of file url-inl.h.
References ada::checkers::begins_with(), get_protocol(), get_search(), has_credentials(), ada::url_base::has_opaque_path, ada::parse(), and ada::url_components::protocol_end.
|
noexcept |
Return U+0023 (#), followed by this's URL's fragment.
Definition at line 89 of file url-getters.cpp.
|
noexcept |
Return url's host, serialized, followed by U+003A (:) and url's port, serialized. When there is no host, this function returns the empty string.
Definition at line 48 of file url-getters.cpp.
References get_port().
Referenced by get_origin().
|
noexcept |
Return this's URL's host, serialized. When there is no host, this function returns the empty string.
Definition at line 62 of file url-getters.cpp.
Referenced by ada::parser::parse_url().
|
noexcept |
Definition at line 183 of file url-inl.h.
References ada::checkers::begins_with(), get_password(), get_port(), get_protocol(), has_credentials(), ada::url_base::has_opaque_path, and ada::parse().
Referenced by ada::parser::parse_url().
|
overridevirtualnoexcept |
The origin getter steps are to return the serialization of this's URL's origin. [HTML]
Implements ada::url_base.
Definition at line 14 of file url-getters.cpp.
References ada::scheme::FILE, get_host(), 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.
Definition at line 81 of file url-getters.cpp.
Referenced by get_href().
|
noexcept |
The pathname getter steps are to return the result of URL path serializing this's URL.
Definition at line 66 of file url-getters.cpp.
Referenced by ada::parser::parse_url().
|
noexcept |
Compute the pathname length in bytes without instantiating a view or a string.
|
noexcept |
Return this's URL's port, serialized.
Definition at line 85 of file url-getters.cpp.
Referenced by get_host(), and get_href().
|
noexcept |
The protocol getter steps are to return this's URL's scheme, followed by U+003A (:).
Definition at line 40 of file url-getters.cpp.
References ada::url_base::is_special(), and ada::scheme::details::is_special_list.
Referenced by get_components(), get_href(), get_origin(), ada::parser::parse_url(), and to_string().
|
noexcept |
Return U+003F (?), followed by this's URL's query.
Definition at line 70 of file url-getters.cpp.
Referenced by get_components().
|
noexcept |
The username getter steps are to return this's URL's username.
Definition at line 77 of file url-getters.cpp.
|
noexcept |
A URL includes credentials if its username or password is not the empty string.
Definition at line 19 of file url-inl.h.
Referenced by get_components(), get_href(), and to_string().
|
inlinenoexcept |
|
inlineoverridevirtualnoexcept |
Implements ada::url_base.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlineoverridevirtualnoexcept |
Implements ada::url_base.
Definition at line 159 of file url-inl.h.
Referenced by to_string().
|
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.
void ada::url::set_hash | ( | std::string_view | input | ) |
This function always succeeds.
Definition at line 151 of file url-setters.cpp.
References ada::character_sets::FRAGMENT_PERCENT_ENCODE, and ada::parse().
bool ada::url::set_host | ( | std::string_view | input | ) |
Definition at line 95 of file url-setters.cpp.
References ada::parse().
Referenced by ada::parser::parse_url().
bool ada::url::set_hostname | ( | std::string_view | input | ) |
Definition at line 99 of file url-setters.cpp.
References ada::parse().
Referenced by ada::parser::parse_url().
bool ada::url::set_href | ( | std::string_view | input | ) |
Definition at line 218 of file url-setters.cpp.
References ada::url_base::has_opaque_path, and ada::parse().
bool ada::url::set_password | ( | std::string_view | input | ) |
Definition at line 112 of file url-setters.cpp.
References ada::parse(), and ada::character_sets::USERINFO_PERCENT_ENCODE.
bool ada::url::set_pathname | ( | std::string_view | input | ) |
Definition at line 185 of file url-setters.cpp.
References ada::url_base::has_opaque_path, and ada::parse().
bool ada::url::set_port | ( | std::string_view | input | ) |
Definition at line 121 of file url-setters.cpp.
References ada::url_base::is_valid, and ada::parse().
bool ada::url::set_protocol | ( | std::string_view | input | ) |
Definition at line 194 of file url-setters.cpp.
References ada::checkers::is_alpha(), and ada::parse().
void ada::url::set_search | ( | std::string_view | input | ) |
This function always succeeds.
Definition at line 166 of file url-setters.cpp.
References ada::url_base::is_special(), ada::parse(), ada::character_sets::QUERY_PERCENT_ENCODE, and ada::character_sets::SPECIAL_QUERY_PERCENT_ENCODE.
bool ada::url::set_username | ( | std::string_view | input | ) |
Definition at line 103 of file url-setters.cpp.
References ada::parse(), and ada::character_sets::USERINFO_PERCENT_ENCODE.
|
overridevirtual |
Returns a JSON string representation of this URL.
Implements ada::url_base.
Definition at line 536 of file url.cpp.
References get_protocol(), has_credentials(), ada::url_base::has_opaque_path, has_search(), ada::url_base::is_valid, and ada::parse().
|
friend |
|
friend |