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

Includes the definitions for validation functions. More...

Functions

bool has_hex_prefix_unsafe (std::string_view input)
 
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
 
ada_really_inline bool begins_with (std::string_view view, std::string_view prefix)
 

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

◆ begins_with()

ada_really_inline bool ada::checkers::begins_with ( std::string_view view,
std::string_view prefix )
Warning
Will be removed when Ada requires C++20.

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

References ada::parse().

Referenced by ada::url::get_components(), ada::url::get_href(), ada::parser::parse_url(), and ada::url_aggregator::set_pathname().

◆ has_hex_prefix()

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

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

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

References has_hex_prefix_unsafe(), and ada::parse().

◆ has_hex_prefix_unsafe()

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

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 16 of file checkers-inl.h.

References ada::parse().

Referenced by has_hex_prefix().

◆ is_alpha()

constexpr 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 41 of file checkers-inl.h.

References ada::parse(), and to_lower().

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

◆ is_digit()

constexpr 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 37 of file checkers-inl.h.

References ada::parse().

◆ is_normalized_windows_drive_letter()

constexpr 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 52 of file checkers-inl.h.

References is_alpha(), and ada::parse().

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

◆ is_windows_drive_letter()

constexpr 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 45 of file checkers-inl.h.

References is_alpha(), and ada::parse().

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

◆ to_lower()

constexpr 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 39 of file checkers-inl.h.

References ada::parse().

Referenced by is_alpha().

Variable Documentation

◆ path_signature_table

constexpr std::array<uint8_t, 256> ada::checkers::path_signature_table
staticconstexpr
Initial value:
=
[]() constexpr {
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 == 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.