5#ifndef ADA_URL_AGGREGATOR_INL_H
6#define ADA_URL_AGGREGATOR_INL_H
24inline void url_aggregator::update_base_authority(
28 ada_log(
"url_aggregator::update_base_authority ",
input);
38 input.remove_prefix(2);
59 }
else if (!
input.empty()) {
69 if (buffer.size() >
base.host_start && buffer[
base.host_start] !=
'@') {
83inline void url_aggregator::update_unencoded_base_hash(std::string_view
input) {
84 ada_log(
"url_aggregator::update_unencoded_base_hash ",
input,
" [",
85 input.size(),
" bytes], buffer is '", buffer,
"' [", buffer.size(),
86 " bytes] components.hash_start = ", components.
hash_start);
101 ada_log(
"url_aggregator::update_unencoded_base_hash final buffer is '",
102 buffer,
"' [", buffer.size(),
" bytes]");
127inline void url_aggregator::update_base_hostname(
const std::string_view
input) {
129 " bytes], buffer is '", buffer,
"' [", buffer.size(),
" bytes]");
134 add_authority_slashes_if_needed();
157 ada_log(
"url_aggregator::get_pathname_length");
172inline void url_aggregator::update_base_search(std::string_view
input) {
181 if (
input[0] ==
'?') {
182 input.remove_prefix(1);
193 buffer.append(
input);
211inline void url_aggregator::update_base_search(
231 buffer.append(
input);
264inline void url_aggregator::update_base_pathname(
const std::string_view
input) {
295 ada_log(
"url_aggregator::update_base_pathname end '",
input,
"' [",
300inline void url_aggregator::append_base_pathname(
const std::string_view
input) {
305#if ADA_DEVELOPMENT_CHECKS
324#if ADA_DEVELOPMENT_CHECKS
328 "append_base_pathname problem after inserting " + std::string(
input));
333inline void url_aggregator::update_base_username(
const std::string_view
input) {
339 add_authority_slashes_if_needed();
371inline void url_aggregator::append_base_username(
const std::string_view
input) {
372 ada_log(
"url_aggregator::append_base_username ",
input);
375#if ADA_DEVELOPMENT_CHECKS
380 add_authority_slashes_if_needed();
406#if ADA_DEVELOPMENT_CHECKS
410 "append_base_username problem after inserting " + std::string(
input));
415inline void url_aggregator::clear_password() {
435inline void url_aggregator::update_base_password(
const std::string_view
input) {
436 ada_log(
"url_aggregator::update_base_password ",
input);
440 add_authority_slashes_if_needed();
448 update_base_username(
"");
489inline void url_aggregator::append_base_password(
const std::string_view
input) {
494#if ADA_DEVELOPMENT_CHECKS
499 add_authority_slashes_if_needed();
532#if ADA_DEVELOPMENT_CHECKS
536 "append_base_password problem after inserting " + std::string(
input));
541inline void url_aggregator::update_base_port(
uint32_t input) {
542 ada_log(
"url_aggregator::update_base_port");
550 std::string value = helpers::concat(
":", std::to_string(
input));
559 buffer.insert(components.
host_end, value);
572 ada_log(
"url_aggregator::clear_port");
578 buffer.erase(components.
host_end, length);
591 ada_log(
"url_aggregator::retrieve_base_port");
592 return components.
port;
596 ada_log(
"url_aggregator::clear_search");
612#if ADA_DEVELOPMENT_CHECKS
614 "search should have been cleared on buffer=" + buffer +
621 ada_log(
"url_aggregator::clear_hash");
629#if ADA_DEVELOPMENT_CHECKS
631 "hash should have been cleared on buffer=" + buffer +
637inline void url_aggregator::clear_pathname() {
638 ada_log(
"url_aggregator::clear_pathname");
650 buffer[components.
host_end] ==
'/' &&
651 buffer[components.
host_end + 1] ==
'.') {
653 buffer.erase(components.
host_end, 2);
662 ada_log(
"url_aggregator::clear_pathname completed, running checks...");
663#if ADA_DEVELOPMENT_CHECKS
665 "pathname should have been cleared on buffer=" + buffer +
669 ada_log(
"url_aggregator::clear_pathname completed, running checks... ok");
672inline void url_aggregator::clear_hostname() {
673 ada_log(
"url_aggregator::clear_hostname");
675 if (!has_authority()) {
697#if ADA_DEVELOPMENT_CHECKS
699 "hostname should have been cleared on buffer=" + buffer +
704 "hostname should have been cleared on buffer=" + buffer +
710 ada_log(
"url_aggregator::has_hash");
715 ada_log(
"url_aggregator::has_search");
720 ada_log(
"url_aggregator::has_credentials");
724inline bool url_aggregator::cannot_have_credentials_or_port()
const {
725 ada_log(
"url_aggregator::cannot_have_credentials_or_port");
736 ada_log(
"url_aggregator::has_authority");
739 return components.protocol_end + 2 <= components.host_start &&
740 helpers::substring(buffer, components.protocol_end,
741 components.protocol_end + 2) ==
"//";
744inline void ada::url_aggregator::add_authority_slashes_if_needed()
noexcept {
745 ada_log(
"url_aggregator::add_authority_slashes_if_needed");
750 if (has_authority()) {
756 buffer.insert(components.protocol_end,
"//");
757 components.username_end += 2;
758 components.host_start += 2;
759 components.host_end += 2;
760 components.pathname_start += 2;
762 components.search_start += 2;
765 components.hash_start += 2;
775 ada_log(
"url_aggregator::has_non_empty_username");
780 ada_log(
"url_aggregator::has_non_empty_password");
785 ada_log(
"url_aggregator::has_password");
805 return has_authority();
809 ada_log(
"url_aggregator::has_port");
819 ada_log(
"url_aggregator::has_dash_dot");
820#if ADA_DEVELOPMENT_CHECKS
826 buffer[components.
host_end + 1] ==
'.') ||
827 (buffer[components.
host_end] ==
':' &&
831 buffer[components.
host_end] ==
'/' &&
832 buffer[components.
host_end + 1] ==
'.') {
844 buffer[components.
host_end + 1] ==
'.';
849 ada_log(
"url_aggregator::get_href");
858 if (
r.ec == std::errc::result_out_of_range) {
859 ada_log(
"parse_port: std::errc::result_out_of_range");
871 ada_log(
"parse_port: is_valid = ", is_valid);
873 ada_log(
"parse_port",
r.ec == std::errc());
887inline void url_aggregator::set_protocol_as_file() {
888 ada_log(
"url_aggregator::set_protocol_as_file ");
895 if (buffer.empty()) {
896 buffer.append(
"file:");
899 buffer.insert(0,
"file:");
919 return out <<
u.to_string();
Definitions of the character sets used by unicode functions.
Declaration of the character sets used by unicode functions.
Definitions for URL specific checkers used within Ada.
#define ADA_ASSERT_TRUE(COND)
#define ADA_ASSERT_EQUAL(LHS, RHS, MESSAGE)
#define ada_really_inline
Definitions for helper functions used within Ada.
constexpr uint8_t FRAGMENT_PERCENT_ENCODE[32]
constexpr bool is_digit(char x) noexcept
ada_really_inline bool begins_with(std::string_view view, std::string_view prefix)
ada_really_inline size_t percent_encode_index(const std::string_view input, const uint8_t character_set[])
std::ostream & operator<<(std::ostream &out, const ada::url &u)
ada_warn_unused ada::result< result_type > parse(std::string_view input, const result_type *base_url=nullptr)
Declarations for the URL scheme.
bool has_non_empty_username() const noexcept
std::string_view get_pathname() const noexcept
ada_really_inline const ada::url_components & get_components() const noexcept
void clear_search() override
bool has_hostname() const noexcept
bool has_non_empty_password() const noexcept
ada_really_inline bool has_credentials() const noexcept
std::string_view get_search() const noexcept
std::string_view get_username() const noexcept
std::string to_string() const override
bool has_empty_hostname() const noexcept
bool has_search() const noexcept override
std::string to_diagram() const
bool validate() const noexcept
bool has_password() const noexcept
std::string_view get_hostname() const noexcept
ada_really_inline uint32_t get_pathname_length() const noexcept
std::string_view get_href() const noexcept
std::string_view get_password() const noexcept
bool has_hash() const noexcept override
bool has_port() const noexcept
std::string_view get_hash() const noexcept
URL Component representations using offsets.
std::string to_string() const
static constexpr uint32_t omitted
Definitions for unicode operations.
Definitions for all unicode specific functions.
Declaration for the basic URL definitions.
Declaration for the URL Components.