13template <
typename out_iter>
17 "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f";
22 }
else if (
c ==
'"') {
25 }
else if (
c <= 0x1f) {
43 return "Scheme Start";
53 return "Relative Scheme";
55 return "Relative Slash";
63 return "Path or Authority";
65 return "Special Authority Ignore Slashes";
67 return "Special Authority Slashes";
69 return "Special Relative or Authority";
81 return "unknown state";
86 std::string_view&
input)
noexcept {
93 std::string_view hash =
input;
106 if (type == ada::scheme::type::FILE &&
109 helpers::substring(path, 1))) {
131 if (type == ada::scheme::type::FILE &&
134 helpers::substring(path, 1))) {
142 if (
slash_loc != std::string_view::npos) {
143 path.remove_suffix(path.size() -
slash_loc);
152 std::string&
input)
noexcept {
157 return ada::unicode::is_ascii_tab_or_newline(c);
163 size_t pos)
noexcept {
167 return input.substr(pos);
178#ifdef ADA_REGULAR_VISUAL_STUDIO
196#ifndef ada_make_uint8x16_t
197#define ada_make_uint8x16_t(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, \
198 x13, x14, x15, x16) \
200 static uint8_t array[16] = {x1, x2, x3, x4, x5, x6, x7, x8, \
201 x9, x10, x11, x12, x13, x14, x15, x16}; \
202 return vld1q_u8(array); \
221 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80);
233 0x00, 0x01, 0x04, 0x04, 0x00, 0x00, 0x03);
236 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
239 for (;
i + 15 <
view.size();
i += 16) {
251 if (
i <
view.size()) {
286 for (;
i + 15 <
view.size();
i += 16) {
300 if (
i <
view.size()) {
321 std::array<uint8_t, 256>
result{};
322 for (
int i : {
':',
'/',
'[',
'\\',
'?'}) {
331 for (
auto pos =
str.begin(); pos !=
str.end(); ++pos) {
359 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80);
371 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, 0x03);
374 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
377 for (;
i + 15 <
view.size();
i += 16) {
389 if (
i <
view.size()) {
423 for (;
i + 15 <
view.size();
i += 16) {
435 if (
i <
view.size()) {
453 std::array<uint8_t, 256>
result{};
454 for (
int i : {
':',
'/',
'?',
'['}) {
463 for (
auto pos =
str.begin(); pos !=
str.end(); ++pos) {
473 const bool is_special, std::string_view&
view)
noexcept {
513 if (
location == std::string_view::npos) {
534 if (
location == std::string_view::npos) {
553 while (!
input.empty() &&
554 ada::unicode::is_c0_control_or_space(
input.front())) {
555 input.remove_prefix(1);
557 while (!
input.empty() && ada::unicode::is_c0_control_or_space(
input.back())) {
558 input.remove_suffix(1);
591 if (
input[0] !=
'.') {
593 if (
slashdot == std::string_view::npos) {
616 (type != ada::scheme::type::FILE);
618 ada_log(
"parse_prepared_path fast");
637 if (path.back() ==
'/') {
642 path.resize(path.rfind(
'/') + 1);
673 ?
input.find_first_of(
"/\\")
676 if (
location != std::string_view::npos) {
684 ada::unicode::percent_encode<false>(
688 if (unicode::is_double_dot_path_segment(
path_buffer)) {
689 if ((helpers::shorten_path(path, type) ||
special) &&
690 location == std::string_view::npos) {
693 }
else if (unicode::is_single_dot_path_segment(
path_buffer) &&
694 (
location == std::string_view::npos)) {
698 else if (!unicode::is_single_dot_path_segment(
path_buffer)) {
702 if (type == ada::scheme::type::FILE && path.empty() &&
715 if (
location == std::string_view::npos) {
722bool overlaps(std::string_view
input1,
const std::string&
input2)
noexcept {
723 ada_log(
"helpers::overlaps check if string_view '",
input1,
"' [",
724 input1.size(),
" bytes] is part of string '",
input2,
"' [",
725 input2.size(),
" bytes]");
730template <
class url_type>
733 ada_log(
"helpers::strip_trailing_spaces_from_opaque_path");
734 if (!url.has_opaque_path)
return;
735 if (url.has_hash())
return;
736 if (url.has_search())
return;
738 auto path = std::string(url.get_pathname());
739 while (!path.empty() && path.back() ==
' ') {
740 path.resize(path.size() - 1);
742 url.update_base_pathname(path);
748 std::array<uint8_t, 256>
result{};
749 for (
uint8_t i : {
'@',
'/',
'\\',
'?'}) {
756find_authority_delimiter_special(std::string_view
view)
noexcept {
759 for (
auto pos =
view.begin(); pos !=
view.end(); ++pos) {
761 return pos -
view.begin();
769 std::array<uint8_t, 256>
result{};
777find_authority_delimiter(std::string_view
view)
noexcept {
780 for (
auto pos =
view.begin(); pos !=
view.end(); ++pos) {
782 return pos -
view.begin();
794#undef ada_make_uint8x16_t
Definitions for URL specific checkers used within Ada.
Common definitions for cross-platform compiler support.
#define ADA_ASSERT_TRUE(COND)
#define ada_really_inline
constexpr uint8_t PATH_PERCENT_ENCODE[32]
constexpr bool is_normalized_windows_drive_letter(std::string_view input) noexcept
constexpr bool is_windows_drive_letter(std::string_view input) noexcept
Includes the definitions for helper functions.
ada_really_inline size_t find_next_host_delimiter(std::string_view view, size_t location) noexcept
static constexpr std::array< uint8_t, 256 > authority_delimiter_special
static constexpr std::array< uint8_t, 256 > host_delimiters
ada_really_inline size_t find_next_host_delimiter_special(std::string_view view, size_t location) noexcept
ada_unused std::string get_state(ada::state s)
static constexpr std::array< uint8_t, 256 > authority_delimiter
static constexpr std::array< uint8_t, 256 > special_host_delimiters
ada_really_inline int trailing_zeroes(uint32_t input_num) noexcept
ada_warn_unused std::string to_string(encoding_type type)
@ SPECIAL_RELATIVE_OR_AUTHORITY
@ SPECIAL_AUTHORITY_SLASHES
@ SPECIAL_AUTHORITY_IGNORE_SLASHES
tl::expected< result_type, ada::errors > result
ada_warn_unused ada::result< result_type > parse(std::string_view input, const result_type *base_url=nullptr)
Declarations for the URL scheme.