22#include <riscv_vector.h>
30 return c ==
'\r' ||
c ==
'\n' ||
c ==
'\t';
34 return 0x101010101010101ull *
v;
37constexpr bool to_lower_ascii(
char*
input,
size_t length)
noexcept {
44 for (;
i + 7 < length;
i += 8) {
75 _mm_setr_epi8(1, 0, 0, 0, 0, 0, 0, 0, 0, 9, 10, 0, 0, 13, 0, 0);
116 0, 9, 10, 0, 0, 13, 0, 0};
207 if (
idx >= 0)
return true;
215 return ((
v - 0x0101010101010101) & ~(
v) & 0x8080808080808080);
248 std::array<uint8_t, 256>
result{};
249 for (
uint8_t c : {
'\0',
'\x09',
'\x0a',
'\x0d',
' ',
'#',
'/',
':',
'<',
250 '>',
'?',
'@',
'[',
'\\',
']',
'^',
'|'}) {
257 const char c)
noexcept {
263 std::array<uint8_t, 256>
result{};
264 for (
uint8_t c : {
'\0',
'\x09',
'\x0a',
'\x0d',
' ',
'#',
'/',
':',
'<',
265 '>',
'?',
'@',
'[',
'\\',
']',
'^',
'|',
'%'}) {
271 for (
size_t c = 127;
c < 256;
c++) {
280 const char c)
noexcept {
285 const char*
input,
size_t length)
noexcept {
288 for (;
i + 4 <= length;
i += 4) {
294 for (;
i < length;
i++) {
300constexpr static std::array<uint8_t, 256>
302 std::array<uint8_t, 256>
result{};
303 for (
uint8_t c : {
'\0',
'\x09',
'\x0a',
'\x0d',
' ',
'#',
'/',
':',
'<',
304 '>',
'?',
'@',
'[',
'\\',
']',
'^',
'|',
'%'}) {
313 for (
size_t c = 127;
c < 256;
c++) {
320contains_forbidden_domain_code_point_or_upper(
const char*
input,
321 size_t length)
noexcept {
324 for (;
i + 4 <= length;
i += 4) {
334 for (;
i < length;
i++) {
343 std::array<bool, 256>
result{};
344 for (
size_t c = 0;
c < 256;
c++) {
345 result[
c] = (
c >=
'0' &&
c <=
'9') || (
c >=
'a' &&
c <=
'z') ||
346 (
c >=
'A' &&
c <=
'Z') ||
c ==
'+' ||
c ==
'-' ||
c ==
'.';
359 return (
c >=
'0' &&
c <=
'9') || (
c >=
'A' &&
c <=
'F') ||
360 (
c >=
'a' &&
c <=
'f');
366 return (
c >=
'0' &&
c <=
'9');
375 return (
unsigned char)
c <=
' ';
379 const char c)
noexcept {
380 return c ==
'\t' ||
c ==
'\n' ||
c ==
'\r';
384 "..",
"%2e.",
".%2e",
"%2e%2e"};
387 std::string_view
input)
noexcept {
412 memcpy(&B,
b.data(),
sizeof(B));
418 for (
size_t i = 2;
i <
input.size();
i++) {
436 std::string_view
input)
noexcept {
441 return (
c >=
'0' &&
c <=
'9') || (
c >=
'a' &&
c <=
'f');
445 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 10, 11,
446 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
447 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 11, 12, 13, 14, 15};
448unsigned constexpr convert_hex_to_binary(
const char c)
noexcept {
456 return std::string(
input);
462 const char* end =
input.data() +
input.size();
470 (!is_ascii_hex_digit(
pointer[1]) ||
471 !is_ascii_hex_digit(
pointer[2])))) {
475 unsigned a = convert_hex_to_binary(
pointer[1]);
476 unsigned b = convert_hex_to_binary(
pointer[2]);
477 char c =
static_cast<char>(
a * 16 +
b);
485std::string percent_encode(
const std::string_view
input,
492 return std::string(
input);
511template <
bool append>
514 ada_log(
"percent_encode ",
input,
" to output string while ",
515 append ?
"appending" :
"overwriting");
519 ada_log(
"percent_encode done checking, moved to ",
524 ada_log(
"percent_encode encoding not needed.");
527 if constexpr (!append) {
564std::string percent_encode(
const std::string_view
input,
Definitions of the character sets used by unicode functions.
Declaration of the character sets used by unicode functions.
Cross-platform compiler macros and common definitions.
#define ADA_PUSH_DISABLE_ALL_WARNINGS
#define ADA_POP_DISABLE_WARNINGS
#define ada_really_inline
ada_really_inline constexpr bool bit_at(const uint8_t a[], const uint8_t i)
bool constexpr is_ascii(std::u32string_view view)
std::string to_ascii(std::string_view ut8_string)
bool contains_forbidden_domain_code_point(std::string_view ascii_string)
Includes the declarations for unicode operations.
static constexpr std::array< uint8_t, 256 > is_forbidden_domain_code_point_table
static constexpr std::array< uint8_t, 256 > is_forbidden_domain_code_point_table_or_upper
static constexpr char hex_to_binary_table[]
constexpr uint64_t broadcast(uint8_t v) noexcept
constexpr std::string_view table_is_double_dot_path_segment[]
constexpr bool is_tabs_or_newline(char c) noexcept
static constexpr std::array< uint8_t, 256 > is_forbidden_host_code_point_table
static constexpr std::array< bool, 256 > is_alnum_plus_table
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)
Definitions for all unicode specific functions.