Ada 2.9.2
Fast spec-compliant URL parser
Loading...
Searching...
No Matches
ada::checkers Namespace Reference

Includes the definitions for validation functions. More...

Functions

constexpr bool has_hex_prefix_unsafe (std::string_view input)
 
constexpr bool has_hex_prefix (std::string_view input)
 
constexpr bool is_digit (char x) noexcept
 
constexpr char to_lower (char x) noexcept
 
constexpr bool is_alpha (char x) noexcept
 
constexpr bool is_windows_drive_letter (std::string_view input) noexcept
 
constexpr bool is_normalized_windows_drive_letter (std::string_view input) noexcept
 

Variables

static constexpr std::array< uint8_t, 256 > path_signature_table
 

Detailed Description

Includes the definitions for validation functions.

These functions are not part of our public API and may change at any time.

Function Documentation

◆ has_hex_prefix()

bool ada::checkers::has_hex_prefix ( std::string_view input)
constexpr

Check whether a string starts with 0x or 0X.

Definition at line 29 of file checkers-inl.h.

References has_hex_prefix_unsafe().

◆ has_hex_prefix_unsafe()

bool ada::checkers::has_hex_prefix_unsafe ( std::string_view input)
constexpr

Check whether a string starts with 0x or 0X. The function is only safe if input.size() >=2.

See also
has_hex_prefix

Definition at line 13 of file checkers-inl.h.

Referenced by has_hex_prefix().

◆ is_alpha()

bool ada::checkers::is_alpha ( char x)
constexprnoexcept

Returns true if the character is an ASCII letter. Equivalent to std::isalpha but more likely to be inlined by the compiler.

Attention
std::isalpha is not constexpr generally.

Definition at line 37 of file checkers-inl.h.

References to_lower().

Referenced by is_normalized_windows_drive_letter(), is_windows_drive_letter(), ada::parser::parse_url_impl(), ada::url::set_protocol(), and ada::url_aggregator::set_protocol().

◆ is_digit()

bool ada::checkers::is_digit ( char x)
constexprnoexcept

Check whether x is an ASCII digit. More likely to be inlined than std::isdigit.

Definition at line 33 of file checkers-inl.h.

◆ is_normalized_windows_drive_letter()

bool ada::checkers::is_normalized_windows_drive_letter ( std::string_view input)
inlineconstexprnoexcept

A normalized Windows drive letter is a Windows drive letter of which the second code point is U+003A (:).

Definition at line 48 of file checkers-inl.h.

References is_alpha().

Referenced by ada::parser::parse_url_impl().

◆ is_windows_drive_letter()

bool ada::checkers::is_windows_drive_letter ( std::string_view input)
inlineconstexprnoexcept

A string starts with a Windows drive letter if all of the following are true:

  • its length is greater than or equal to 2
  • its first two code points are a Windows drive letter
  • its length is 2 or its third code point is U+002F (/), U+005C (), U+003F (?), or U+0023 (#).

https://url.spec.whatwg.org/#start-with-a-windows-drive-letter

Definition at line 41 of file checkers-inl.h.

References is_alpha().

Referenced by ada::parser::parse_url_impl().

◆ to_lower()

char ada::checkers::to_lower ( char x)
constexprnoexcept

Assuming that x is an ASCII letter, this function returns the lower case equivalent.

More likely to be inlined by the compiler and constexpr.

Definition at line 35 of file checkers-inl.h.

Referenced by is_alpha().

Variable Documentation

◆ path_signature_table

std::array<uint8_t, 256> ada::checkers::path_signature_table
staticconstexpr
Initial value:
=
[]() consteval {
std::array<uint8_t, 256> result{};
for (size_t i = 0; i < 256; i++) {
if (i <= 0x20 || i == 0x22 || i == 0x23 || i == 0x3c || i == 0x3e ||
i == 0x3f || i == 0x60 || i == 0x7b || i == 0x7d || i > 0x7e) {
result[i] = 1;
} else if (i == 0x25) {
result[i] = 8;
} else if (i == 0x2e) {
result[i] = 4;
} else if (i == 0x5c) {
result[i] = 2;
} else {
result[i] = 0;
}
}
return result;
}()
tl::expected< result_type, ada::errors > result

Definition at line 60 of file checkers.cpp.