15template <
typename out_iter>
19 "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f";
24 }
else if (
c ==
'"') {
27 }
else if (
c <= 0x1f) {
45 return "Scheme Start";
55 return "Relative Scheme";
57 return "Relative Slash";
65 return "Path or Authority";
67 return "Special Authority Ignore Slashes";
69 return "Special Authority Slashes";
71 return "Special Relative or Authority";
83 return "unknown state";
88 std::string_view&
input)
noexcept {
95 std::string_view hash =
input;
111 helpers::substring(path, 1))) {
136 helpers::substring(path, 1))) {
144 if (
slash_loc != std::string_view::npos) {
145 path.remove_suffix(path.size() -
slash_loc);
154 std::string&
input)
noexcept {
159 return ada::unicode::is_ascii_tab_or_newline(c);
165 size_t pos)
noexcept {
169 return input.substr(pos);
180#ifdef ADA_REGULAR_VISUAL_STUDIO
198#ifndef ada_make_uint8x16_t
199#define ada_make_uint8x16_t(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, \
200 x13, x14, x15, x16) \
202 static uint8_t array[16] = {x1, x2, x3, x4, x5, x6, x7, x8, \
203 x9, x10, x11, x12, x13, x14, x15, x16}; \
204 return vld1q_u8(array); \
223 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80);
235 0x00, 0x01, 0x04, 0x04, 0x00, 0x00, 0x03);
238 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
241 for (;
i + 15 <
view.size();
i += 16) {
253 if (
i <
view.size()) {
288 for (;
i + 15 <
view.size();
i += 16) {
302 if (
i <
view.size()) {
323 std::array<uint8_t, 256>
result{};
324 for (
int i : {
':',
'/',
'[',
'\\',
'?'}) {
333 for (
auto pos =
str.begin(); pos !=
str.end(); ++pos) {
361 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80);
373 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, 0x03);
376 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
379 for (;
i + 15 <
view.size();
i += 16) {
391 if (
i <
view.size()) {
425 for (;
i + 15 <
view.size();
i += 16) {
437 if (
i <
view.size()) {
455 std::array<uint8_t, 256>
result{};
456 for (
int i : {
':',
'/',
'?',
'['}) {
465 for (
auto pos =
str.begin(); pos !=
str.end(); ++pos) {
475 const bool is_special, std::string_view&
view)
noexcept {
515 if (
location == std::string_view::npos) {
536 if (
location == std::string_view::npos) {
555 while (!
input.empty() &&
556 ada::unicode::is_c0_control_or_space(
input.front())) {
557 input.remove_prefix(1);
559 while (!
input.empty() && ada::unicode::is_c0_control_or_space(
input.back())) {
560 input.remove_suffix(1);
593 if (
input[0] !=
'.') {
595 if (
slashdot == std::string_view::npos) {
620 ada_log(
"parse_prepared_path fast");
639 if (path.back() ==
'/') {
644 path.resize(path.rfind(
'/') + 1);
675 ?
input.find_first_of(
"/\\")
678 if (
location != std::string_view::npos) {
686 ada::unicode::percent_encode<false>(
690 if (unicode::is_double_dot_path_segment(
path_buffer)) {
691 if ((helpers::shorten_path(path, type) ||
special) &&
692 location == std::string_view::npos) {
695 }
else if (unicode::is_single_dot_path_segment(
path_buffer) &&
696 (
location == std::string_view::npos)) {
700 else if (!unicode::is_single_dot_path_segment(
path_buffer)) {
717 if (
location == std::string_view::npos) {
724bool overlaps(std::string_view
input1,
const std::string&
input2)
noexcept {
725 ada_log(
"helpers::overlaps check if string_view '",
input1,
"' [",
726 input1.size(),
" bytes] is part of string '",
input2,
"' [",
727 input2.size(),
" bytes]");
732template <
class url_type>
735 ada_log(
"helpers::strip_trailing_spaces_from_opaque_path");
736 if (!url.has_opaque_path)
return;
737 if (url.has_hash())
return;
738 if (url.has_search())
return;
740 auto path = std::string(url.get_pathname());
741 while (!path.empty() && path.back() ==
' ') {
742 path.resize(path.size() - 1);
744 url.update_base_pathname(path);
750 std::array<uint8_t, 256>
result{};
751 for (
int i : {
'@',
'/',
'\\',
'?'}) {
758find_authority_delimiter_special(std::string_view
view)
noexcept {
761 for (
auto pos =
view.begin(); pos !=
view.end(); ++pos) {
763 return pos -
view.begin();
771 std::array<uint8_t, 256>
result{};
772 for (
int i : {
'@',
'/',
'?'}) {
779find_authority_delimiter(std::string_view
view)
noexcept {
782 for (
auto pos =
view.begin(); pos !=
view.end(); ++pos) {
784 return pos -
view.begin();
796#undef ada_make_uint8x16_t
Includes all definitions for Ada.
Definitions for URL specific checkers used within Ada.
Declarations 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.
Definitions for all unicode specific functions.