Ada 2.9.2
Fast spec-compliant URL parser
|
Generic URL struct reliant on std::string instantiation. More...
#include <url.h>
Public Member Functions | |
url ()=default | |
url (const url &u)=default | |
url (url &&u) noexcept=default | |
url & | operator= (url &&u) noexcept=default |
url & | operator= (const url &u)=default |
~url () override=default | |
bool | has_empty_hostname () const noexcept |
bool | has_port () const noexcept |
bool | has_hostname () const noexcept |
bool | has_valid_domain () const noexcept override |
std::string | to_string () const override |
ada_really_inline std::string | get_href () const noexcept |
std::string | get_origin () const noexcept override |
std::string | get_protocol () const noexcept |
std::string | get_host () const noexcept |
std::string | get_hostname () const noexcept |
std::string_view | get_pathname () const noexcept |
ada_really_inline size_t | get_pathname_length () const noexcept |
std::string | get_search () const noexcept |
const std::string & | get_username () const noexcept |
bool | set_username (std::string_view input) |
bool | set_password (std::string_view input) |
bool | set_port (std::string_view input) |
void | set_hash (std::string_view input) |
void | set_search (std::string_view input) |
bool | set_pathname (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_href (std::string_view input) |
const std::string & | get_password () const noexcept |
std::string | get_port () const noexcept |
std::string | get_hash () const noexcept |
ada_really_inline bool | has_credentials () const noexcept |
ada_really_inline ada::url_components | get_components () const noexcept |
bool | has_hash () const noexcept override |
bool | has_search () const noexcept override |
url ()=default | |
url (const url &u)=default | |
url (url &&u) noexcept=default | |
url & | operator= (url &&u) noexcept=default |
url & | operator= (const url &u)=default |
~url () override=default | |
bool | has_empty_hostname () const noexcept |
bool | has_port () const noexcept |
bool | has_hostname () const noexcept |
bool | has_valid_domain () const noexcept override |
std::string | to_string () const override |
ada_really_inline std::string | get_href () const noexcept |
std::string | get_origin () const noexcept override |
std::string | get_protocol () const noexcept |
std::string | get_host () const noexcept |
std::string | get_hostname () const noexcept |
std::string_view | get_pathname () const noexcept |
ada_really_inline size_t | get_pathname_length () const noexcept |
std::string | get_search () const noexcept |
const std::string & | get_username () const noexcept |
bool | set_username (std::string_view input) |
bool | set_password (std::string_view input) |
bool | set_port (std::string_view input) |
void | set_hash (std::string_view input) |
void | set_search (std::string_view input) |
bool | set_pathname (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_href (std::string_view input) |
const std::string & | get_password () const noexcept |
std::string | get_port () const noexcept |
std::string | get_hash () const noexcept |
ada_really_inline bool | has_credentials () const noexcept |
ada_really_inline ada::url_components | get_components () const noexcept |
bool | has_hash () const noexcept override |
bool | has_search () const noexcept override |
Public Member Functions inherited from ada::url_base | |
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 | 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 |
ada::url | ada::parser::parse_url_impl (std::string_view, const ada::url *) |
ada::url_aggregator | ada::parser::parse_url_impl (std::string_view, const ada::url_aggregator *) |
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 |
ada::url | ada::parser::parse_url_impl (std::string_view, const ada::url *) |
ada::url_aggregator | ada::parser::parse_url_impl (std::string_view, const ada::url_aggregator *) |
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 |
|
overridedefault |
|
default |
|
overridedefault |
|
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 46 of file url-inl.h.
References ada_really_inline, ada::checkers::begins_with(), get_protocol(), get_search(), 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_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 get_components().
|
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
References ada_really_inline, and get_components().
|
nodiscardnoexcept |
Return U+0023 (#), followed by this's URL's fragment.
Definition at line 11891 of file ada.cpp.
References get_hash().
Referenced by get_hash().
|
nodiscardnoexcept |
Return U+0023 (#), followed by this's URL's fragment.
References get_hash().
|
nodiscardnoexcept |
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 11850 of file ada.cpp.
References get_host(), and get_port().
Referenced by get_host(), and get_origin().
|
nodiscardnoexcept |
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.
References get_host().
|
nodiscardnoexcept |
Return this's URL's host, serialized. When there is no host, this function returns the empty string.
Definition at line 11864 of file ada.cpp.
References get_hostname().
Referenced by get_hostname(), and ada::parser::parse_url_impl().
|
nodiscardnoexcept |
Return this's URL's host, serialized. When there is no host, this function returns the empty string.
References get_hostname().
|
nodiscardnoexcept |
Definition at line 183 of file url-inl.h.
References ada_really_inline, ada::checkers::begins_with(), get_password(), get_port(), get_protocol(), has_credentials(), and ada::url_base::has_opaque_path.
Referenced by get_href(), and ada::parser::parse_url_impl().
|
nodiscardnoexcept |
|
nodiscardoverridevirtualnoexcept |
The origin getter steps are to return the serialization of this's URL's origin. [HTML]
Implements ada::url_base.
Definition at line 11816 of file ada.cpp.
References ada::scheme::FILE, get_host(), get_origin(), get_protocol(), ada::scheme::HTTP, ada::scheme::HTTPS, ada::url_base::is_special(), and ada::parse().
Referenced by get_origin().
|
nodiscardoverridevirtualnoexcept |
The origin getter steps are to return the serialization of this's URL's origin. [HTML]
Implements ada::url_base.
References get_origin().
|
nodiscardnoexcept |
The password getter steps are to return this's URL's password.
Definition at line 11883 of file ada.cpp.
References get_password().
Referenced by get_href(), and get_password().
|
nodiscardnoexcept |
The password getter steps are to return this's URL's password.
References get_password().
|
nodiscardnoexcept |
The pathname getter steps are to return the result of URL path serializing this's URL.
Definition at line 11868 of file ada.cpp.
References get_pathname().
Referenced by get_pathname(), and ada::parser::parse_url_impl().
|
nodiscardnoexcept |
The pathname getter steps are to return the result of URL path serializing this's URL.
References get_pathname().
|
nodiscardnoexcept |
Compute the pathname length in bytes without instantiating a view or a string.
Definition at line 42 of file url-inl.h.
Referenced by get_pathname_length().
|
nodiscardnoexcept |
Compute the pathname length in bytes without instantiating a view or a string.
References ada_really_inline, and get_pathname_length().
|
nodiscardnoexcept |
Return this's URL's port, serialized.
Definition at line 11887 of file ada.cpp.
References get_port().
Referenced by get_host(), get_href(), and get_port().
|
nodiscardnoexcept |
Return this's URL's port, serialized.
References get_port().
|
nodiscardnoexcept |
The protocol getter steps are to return this's URL's scheme, followed by U+003A (:).
Definition at line 11842 of file ada.cpp.
References get_protocol(), ada::url_base::is_special(), and ada::scheme::details::is_special_list.
Referenced by get_components(), get_href(), get_origin(), get_protocol(), ada::parser::parse_url_impl(), and to_string().
|
nodiscardnoexcept |
The protocol getter steps are to return this's URL's scheme, followed by U+003A (:).
References get_protocol().
|
nodiscardnoexcept |
Return U+003F (?), followed by this's URL's query.
Definition at line 11872 of file ada.cpp.
References get_search().
Referenced by get_components(), and get_search().
|
nodiscardnoexcept |
Return U+003F (?), followed by this's URL's query.
References get_search().
|
nodiscardnoexcept |
The username getter steps are to return this's URL's username.
Definition at line 11879 of file ada.cpp.
References get_username().
Referenced by get_username().
|
nodiscardnoexcept |
The username getter steps are to return this's URL's username.
References get_username().
|
nodiscardnoexcept |
A URL includes credentials if its username or password is not the empty string.
Definition at line 19 of file url-inl.h.
References ada_really_inline.
Referenced by get_components(), get_href(), has_credentials(), and to_string().
|
nodiscardnoexcept |
A URL includes credentials if its username or password is not the empty string.
References ada_really_inline, and has_credentials().
|
inlinenodiscardnoexcept |
|
inlinenodiscardnoexcept |
|
inlinenodiscardoverridevirtualnoexcept |
Implements ada::url_base.
Definition at line 155 of file url-inl.h.
Referenced by has_hash().
|
inlinenodiscardoverridevirtualnoexcept |
|
inlinenodiscardnoexcept |
Definition at line 35 of file url-inl.h.
Referenced by has_hostname().
|
inlinenodiscardnoexcept |
References has_hostname().
|
inlinenodiscardnoexcept |
Definition at line 22 of file url-inl.h.
References ada_really_inline.
Referenced by has_port().
|
inlinenodiscardnoexcept |
References has_port().
|
inlinenodiscardoverridevirtualnoexcept |
Implements ada::url_base.
Definition at line 159 of file url-inl.h.
Referenced by has_search(), and to_string().
|
inlinenodiscardoverridevirtualnoexcept |
|
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 11798 of file ada.cpp.
References has_valid_domain().
Referenced by has_valid_domain().
|
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.
References has_valid_domain().
void ada::url::set_hash | ( | std::string_view | input | ) |
This function always succeeds.
Definition at line 12049 of file ada.cpp.
References ada::character_sets::FRAGMENT_PERCENT_ENCODE, and set_hash().
Referenced by set_hash().
void ada::url::set_hash | ( | std::string_view | input | ) |
This function always succeeds.
References set_hash().
bool ada::url::set_host | ( | std::string_view | input | ) |
Definition at line 11993 of file ada.cpp.
References set_host().
Referenced by ada::parser::parse_url_impl(), and set_host().
bool ada::url::set_host | ( | std::string_view | input | ) |
References set_host().
bool ada::url::set_hostname | ( | std::string_view | input | ) |
Definition at line 11997 of file ada.cpp.
References set_hostname().
Referenced by ada::parser::parse_url_impl(), and set_hostname().
bool ada::url::set_hostname | ( | std::string_view | input | ) |
References set_hostname().
bool ada::url::set_href | ( | std::string_view | input | ) |
Definition at line 12115 of file ada.cpp.
References ada::url_base::has_opaque_path, tl::expected< T, E >::has_value(), ada::parse(), and set_href().
Referenced by set_href().
bool ada::url::set_href | ( | std::string_view | input | ) |
References set_href().
bool ada::url::set_password | ( | std::string_view | input | ) |
Definition at line 12010 of file ada.cpp.
References set_password(), and ada::character_sets::USERINFO_PERCENT_ENCODE.
Referenced by set_password().
bool ada::url::set_password | ( | std::string_view | input | ) |
References set_password().
bool ada::url::set_pathname | ( | std::string_view | input | ) |
Definition at line 12082 of file ada.cpp.
References ada::url_base::has_opaque_path, and set_pathname().
Referenced by set_pathname().
bool ada::url::set_pathname | ( | std::string_view | input | ) |
References set_pathname().
bool ada::url::set_port | ( | std::string_view | input | ) |
Definition at line 12019 of file ada.cpp.
References ada::url_base::is_valid, and set_port().
Referenced by set_port().
bool ada::url::set_port | ( | std::string_view | input | ) |
References set_port().
bool ada::url::set_protocol | ( | std::string_view | input | ) |
Definition at line 12091 of file ada.cpp.
References ada::checkers::is_alpha(), and set_protocol().
Referenced by set_protocol().
bool ada::url::set_protocol | ( | std::string_view | input | ) |
References set_protocol().
void ada::url::set_search | ( | std::string_view | input | ) |
This function always succeeds.
Definition at line 12063 of file ada.cpp.
References ada::url_base::is_special(), ada::character_sets::QUERY_PERCENT_ENCODE, set_search(), and ada::character_sets::SPECIAL_QUERY_PERCENT_ENCODE.
Referenced by set_search().
void ada::url::set_search | ( | std::string_view | input | ) |
This function always succeeds.
References set_search().
bool ada::url::set_username | ( | std::string_view | input | ) |
Definition at line 12001 of file ada.cpp.
References set_username(), and ada::character_sets::USERINFO_PERCENT_ENCODE.
Referenced by set_username().
bool ada::url::set_username | ( | std::string_view | input | ) |
References set_username().
|
nodiscardoverridevirtual |
Returns a JSON string representation of this URL.
Implements ada::url_base.
Definition at line 11749 of file ada.cpp.
References get_protocol(), has_credentials(), ada::url_base::has_opaque_path, has_search(), ada::url_base::is_valid, and to_string().
Referenced by ada::operator<<(), and to_string().
|
nodiscardoverridevirtual |
|
friend |
References ada::helpers::strip_trailing_spaces_from_opaque_path, and url().
Referenced by ada::helpers::strip_trailing_spaces_from_opaque_path.
|
friend |
References ada::helpers::strip_trailing_spaces_from_opaque_path, and url().
|
friend |
References ada::parser::parse_url, and url().
Referenced by ada::parser::parse_url, and ada::parser::parse_url.
|
friend |
References ada::parser::parse_url, and url().
|
friend |
References ada::parser::parse_url.
|
friend |
References ada::parser::parse_url.
|
friend |
References ada::parser::parse_url_impl, and url().
Referenced by ada::parser::parse_url_impl, and ada::parser::parse_url_impl.
|
friend |
References ada::parser::parse_url_impl, and url().
|
friend |
References ada::parser::parse_url_impl.
|
friend |
References ada::parser::parse_url_impl.