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
ada_really_inline constexpr uint64_t | try_parse_ipv4_fast (std::string_view input) noexcept

## Variables

constexpr uint64_t | ipv4_fast_fail = uint64_t(1) << 32
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 14 of file checkers-inl.h.

Referenced by has_hex_prefix().

## is_alpha()

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

constexpr noexcept

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 | ) |

constexpr noexcept

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 | ) |

inline constexpr noexcept

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 | ) |

inline constexpr noexcept

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 | ) |

constexpr noexcept

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().

## try_parse_ipv4_fast()

ada_really_inline constexpr uint64_t ada::checkers::try_parse_ipv4_fast | ( | std::string_view | input | ) |

constexpr noexcept

Fast-path parser for pure decimal IPv4 addresses (e.g., "192.168.1.1"). Returns the packed 32-bit IPv4 address on success, or a value > 0xFFFFFFFF to indicate failure (caller should fall back to general parser). This is optimized for the common case where the input is a well-formed decimal IPv4 address with exactly 4 octets.

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

References ada_really_inline, and ipv4_fast_fail.

## Variable Documentation

## ipv4_fast_fail

uint64_t ada::checkers::ipv4_fast_fail = uint64_t(1) << 32

constexpr

Sentinel value indicating try_parse_ipv4_fast() did not succeed. Any value > 0xFFFFFFFF indicates the fast path should not be used.

Definition at line 129 of file checkers.h.

Referenced by try_parse_ipv4_fast().

## path_signature_table

std::array<uint8_t, 256> ada::checkers::path_signature_table

static constexpr

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 == 0x5e || 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;
}()
ada::result
tl::expected< result_type, ada::errors > result
Definition implementation.h:44

Definition at line 65 of file checkers.cpp.