header_utils
Loading...
Searching...
No Matches

Functions that operate on codepoints and strings encoded as ASCII. More...

Functions

template<stringable T>
constexpr bool ghassanpl::string_ops::ascii::is_identifier (T const &str) noexcept
 Returns true if the given str is a C-style identifier (e.g. matches /[\w_][\w_0-9]+/)
 
template<stringable T>
constexpr std::string ghassanpl::string_ops::ascii::tolower (T const &str) noexcept
 Returns a copy of the string with all characters transformed to lower case.
 
constexpr std::string ghassanpl::string_ops::ascii::tolower (std::string str) noexcept
 Returns a copy of the string with all characters transformed to lower case.
 
constexpr std::string ghassanpl::string_ops::ascii::tolower (const char *str) noexcept
 Returns a copy of the string with all characters transformed to lower case.
 
template<stringable T>
std::string ghassanpl::string_ops::ascii::toupper (T const &str) noexcept
 Returns a copy of the string with all characters transformed to upper case.
 
std::string ghassanpl::string_ops::ascii::toupper (std::string str) noexcept
 Returns a copy of the string with all characters transformed to upper case.
 
std::string ghassanpl::string_ops::ascii::toupper (const char *str) noexcept
 Returns a copy of the string with all characters transformed to upper case.
 
std::string ghassanpl::string_ops::ascii::capitalize (std::string str) noexcept
 Returns a copy of the string with the first letter transformed to upper case if possible.
 
constexpr char32_t ghassanpl::string_ops::ascii::number_to_digit (int v) noexcept
 Convert a number between 0 and 9 to its ASCII representation (only gives meaningful results with arguments between 0 and 9)
 
constexpr char32_t ghassanpl::string_ops::ascii::number_to_xdigit (int v) noexcept
 Convert a number between 0 and 15 to its ASCII representation (only gives meaningful results with arguments between 0 and 15)
 
constexpr int ghassanpl::string_ops::ascii::digit_to_number (char32_t cp) noexcept
 Convert an ASCII digit character to its numerical value (only gives meaningful results with valid digit arguments)
 
constexpr int ghassanpl::string_ops::ascii::xdigit_to_number (char32_t cp) noexcept
 Convert an ASCII xdigit to its numerical value (only gives meaningful results with valid xdigit arguments)
 

*_chars variables

Constexpr arrays listing the characters that match their respective ascii::is* functions

constexpr auto ghassanpl::string_ops::ascii::alphabetic_chars
 All characters that match ascii::isalpha.
 
constexpr auto ghassanpl::string_ops::ascii::digit_chars
 All characters that match ascii::isdigit.
 
constexpr auto ghassanpl::string_ops::ascii::octal_digit_chars
 All characters that match ascii::isodigit.
 
constexpr auto ghassanpl::string_ops::ascii::hex_digit_chars
 All characters that match ascii::isxdigit.
 
constexpr auto ghassanpl::string_ops::ascii::alphanumeric_chars
 All characters that match ascii::isalnum.
 
constexpr auto ghassanpl::string_ops::ascii::identifier_chars
 All characters that match ascii::isident.
 
constexpr auto ghassanpl::string_ops::ascii::identifier_start_chars
 All characters that match ascii::isidentstart.
 
constexpr auto ghassanpl::string_ops::ascii::whitespace_chars
 All characters that match ascii::isspace.
 
constexpr auto ghassanpl::string_ops::ascii::punctuation_chars
 All characters that match ascii::ispunct.
 
constexpr auto ghassanpl::string_ops::ascii::lowercase_chars
 All characters that match ascii::islower.
 
constexpr auto ghassanpl::string_ops::ascii::uppercase_chars
 All characters that match ascii::isupper.
 
constexpr auto ghassanpl::string_ops::ascii::control_chars
 All characters that match ascii::iscntrl.
 
constexpr auto ghassanpl::string_ops::ascii::blank_chars
 All characters that match ascii::isblank.
 
constexpr auto ghassanpl::string_ops::ascii::graphical_chars
 All characters that match ascii::isgraph.
 
constexpr auto ghassanpl::string_ops::ascii::printable_chars
 All characters that match ascii::isprint.
 

is* and to* functions

These are our own versions of <cctype> functions that do not block, are defined (false) for values outside of uint8_t, and do not depend on locale (plus you can take pointers to them).

constexpr bool ghassanpl::string_ops::ascii::isalpha (char32_t cp) noexcept
 
constexpr bool ghassanpl::string_ops::ascii::isdigit (char32_t cp) noexcept
 
constexpr bool ghassanpl::string_ops::ascii::isodigit (char32_t cp) noexcept
 
constexpr bool ghassanpl::string_ops::ascii::isxdigit (char32_t d) noexcept
 
constexpr bool ghassanpl::string_ops::ascii::isalnum (char32_t cp) noexcept
 
constexpr bool ghassanpl::string_ops::ascii::isident (char32_t cp) noexcept
 
constexpr bool ghassanpl::string_ops::ascii::isidentstart (char32_t cp) noexcept
 
constexpr bool ghassanpl::string_ops::ascii::isspace (char32_t cp) noexcept
 
constexpr bool ghassanpl::string_ops::ascii::ispunct (char32_t cp) noexcept
 
constexpr bool ghassanpl::string_ops::ascii::islower (char32_t cp) noexcept
 
constexpr bool ghassanpl::string_ops::ascii::isupper (char32_t cp) noexcept
 
constexpr bool ghassanpl::string_ops::ascii::iscntrl (char32_t cp) noexcept
 
constexpr bool ghassanpl::string_ops::ascii::isblank (char32_t cp) noexcept
 
constexpr bool ghassanpl::string_ops::ascii::isgraph (char32_t cp) noexcept
 
constexpr bool ghassanpl::string_ops::ascii::isprint (char32_t cp) noexcept
 
constexpr char32_t ghassanpl::string_ops::ascii::toupper (char32_t cp) noexcept
 
constexpr char32_t ghassanpl::string_ops::ascii::tolower (char32_t cp) noexcept
 

Case-invariant Comparisons

constexpr bool ghassanpl::string_ops::ascii::strings_equal_ignore_case (std::string_view sa, std::string_view sb)
 
constexpr bool ghassanpl::string_ops::ascii::string_starts_with_ignore_case (std::string_view a, std::string_view b)
 
constexpr bool ghassanpl::string_ops::ascii::string_ends_with_ignore_case (std::string_view a, std::string_view b)
 
constexpr auto ghassanpl::string_ops::ascii::string_find_ignore_case (std::string_view haystack, std::string_view pattern)
 
constexpr auto ghassanpl::string_ops::ascii::string_find_last_ignore_case (std::string_view a, std::string_view b)
 
constexpr auto ghassanpl::string_ops::ascii::string_contains_ignore_case (std::string_view a, std::string_view b)
 
constexpr bool ghassanpl::string_ops::ascii::lexicographical_compare_ignore_case (std::string_view first, std::string_view second)
 
constexpr auto ghassanpl::string_ops::ascii::lexicographical_compare_ignore_case_three_way (std::string_view a, std::string_view b)
 
consteval detail::string_view_case_insensitive ghassanpl::string_ops::ascii::operator""_i (const char *str, size_t size) noexcept
 A version of the sv suffix that returns a special type allowing for case-insensitive comparisons.
 

Detailed Description

Functions that operate on codepoints and strings encoded as ASCII.

Function Documentation

◆ capitalize()

std::string ghassanpl::string_ops::ascii::capitalize ( std::string  str)
inlinenoexcept

Returns a copy of the string with the first letter transformed to upper case if possible.

Definition at line 445 of file string_ops.h.

◆ digit_to_number()

constexpr int ghassanpl::string_ops::ascii::digit_to_number ( char32_t  cp)
constexprnoexcept

Convert an ASCII digit character to its numerical value (only gives meaningful results with valid digit arguments)

Definition at line 457 of file string_ops.h.

◆ is_identifier()

template<stringable T>
constexpr bool ghassanpl::string_ops::ascii::is_identifier ( T const str)
constexprnoexcept

Returns true if the given str is a C-style identifier (e.g. matches /[\w_][\w_0-9]+/)

Definition at line 389 of file string_ops.h.

◆ isalnum()

constexpr bool ghassanpl::string_ops::ascii::isalnum ( char32_t  cp)
constexprnoexcept

Definition at line 330 of file string_ops.h.

◆ isalpha()

constexpr bool ghassanpl::string_ops::ascii::isalpha ( char32_t  cp)
constexprnoexcept

Definition at line 326 of file string_ops.h.

◆ isblank()

constexpr bool ghassanpl::string_ops::ascii::isblank ( char32_t  cp)
constexprnoexcept

Definition at line 338 of file string_ops.h.

◆ iscntrl()

constexpr bool ghassanpl::string_ops::ascii::iscntrl ( char32_t  cp)
constexprnoexcept

Definition at line 337 of file string_ops.h.

◆ isdigit()

constexpr bool ghassanpl::string_ops::ascii::isdigit ( char32_t  cp)
constexprnoexcept

Definition at line 327 of file string_ops.h.

◆ isgraph()

constexpr bool ghassanpl::string_ops::ascii::isgraph ( char32_t  cp)
constexprnoexcept

Definition at line 339 of file string_ops.h.

◆ isident()

constexpr bool ghassanpl::string_ops::ascii::isident ( char32_t  cp)
constexprnoexcept

Definition at line 331 of file string_ops.h.

◆ isidentstart()

constexpr bool ghassanpl::string_ops::ascii::isidentstart ( char32_t  cp)
constexprnoexcept

Definition at line 332 of file string_ops.h.

◆ islower()

constexpr bool ghassanpl::string_ops::ascii::islower ( char32_t  cp)
constexprnoexcept

Definition at line 335 of file string_ops.h.

◆ isodigit()

constexpr bool ghassanpl::string_ops::ascii::isodigit ( char32_t  cp)
constexprnoexcept

Definition at line 328 of file string_ops.h.

◆ isprint()

constexpr bool ghassanpl::string_ops::ascii::isprint ( char32_t  cp)
constexprnoexcept

Definition at line 340 of file string_ops.h.

◆ ispunct()

constexpr bool ghassanpl::string_ops::ascii::ispunct ( char32_t  cp)
constexprnoexcept

Definition at line 334 of file string_ops.h.

◆ isspace()

constexpr bool ghassanpl::string_ops::ascii::isspace ( char32_t  cp)
constexprnoexcept

Definition at line 333 of file string_ops.h.

◆ isupper()

constexpr bool ghassanpl::string_ops::ascii::isupper ( char32_t  cp)
constexprnoexcept

Definition at line 336 of file string_ops.h.

◆ isxdigit()

constexpr bool ghassanpl::string_ops::ascii::isxdigit ( char32_t  d)
constexprnoexcept

Definition at line 329 of file string_ops.h.

◆ lexicographical_compare_ignore_case()

constexpr bool ghassanpl::string_ops::ascii::lexicographical_compare_ignore_case ( std::string_view  first,
std::string_view  second 
)
constexpr

Definition at line 503 of file string_ops.h.

◆ lexicographical_compare_ignore_case_three_way()

constexpr auto ghassanpl::string_ops::ascii::lexicographical_compare_ignore_case_three_way ( std::string_view  a,
std::string_view  b 
)
constexpr

Definition at line 509 of file string_ops.h.

◆ number_to_digit()

constexpr char32_t ghassanpl::string_ops::ascii::number_to_digit ( int  v)
constexprnoexcept

Convert a number between 0 and 9 to its ASCII representation (only gives meaningful results with arguments between 0 and 9)

Definition at line 452 of file string_ops.h.

◆ number_to_xdigit()

constexpr char32_t ghassanpl::string_ops::ascii::number_to_xdigit ( int  v)
constexprnoexcept

Convert a number between 0 and 15 to its ASCII representation (only gives meaningful results with arguments between 0 and 15)

Definition at line 454 of file string_ops.h.

◆ operator""_i()

consteval detail::string_view_case_insensitive ghassanpl::string_ops::ascii::operator""_i ( const char str,
size_t  size 
)
noexcept

A version of the sv suffix that returns a special type allowing for case-insensitive comparisons.

Definition at line 530 of file string_ops.h.

◆ string_contains_ignore_case()

constexpr auto ghassanpl::string_ops::ascii::string_contains_ignore_case ( std::string_view  a,
std::string_view  b 
)
constexpr

Definition at line 498 of file string_ops.h.

◆ string_ends_with_ignore_case()

constexpr bool ghassanpl::string_ops::ascii::string_ends_with_ignore_case ( std::string_view  a,
std::string_view  b 
)
constexpr

Definition at line 474 of file string_ops.h.

◆ string_find_ignore_case()

constexpr auto ghassanpl::string_ops::ascii::string_find_ignore_case ( std::string_view  haystack,
std::string_view  pattern 
)
constexpr

Definition at line 480 of file string_ops.h.

◆ string_find_last_ignore_case()

constexpr auto ghassanpl::string_ops::ascii::string_find_last_ignore_case ( std::string_view  a,
std::string_view  b 
)
constexpr

Definition at line 489 of file string_ops.h.

◆ string_starts_with_ignore_case()

constexpr bool ghassanpl::string_ops::ascii::string_starts_with_ignore_case ( std::string_view  a,
std::string_view  b 
)
constexpr

Definition at line 469 of file string_ops.h.

◆ strings_equal_ignore_case()

constexpr bool ghassanpl::string_ops::ascii::strings_equal_ignore_case ( std::string_view  sa,
std::string_view  sb 
)
constexpr

Definition at line 464 of file string_ops.h.

◆ tolower() [1/4]

constexpr char32_t ghassanpl::string_ops::ascii::tolower ( char32_t  cp)
constexprnoexcept

Definition at line 345 of file string_ops.h.

◆ tolower() [2/4]

constexpr std::string ghassanpl::string_ops::ascii::tolower ( const char str)
constexprnoexcept

Returns a copy of the string with all characters transformed to lower case.

Definition at line 413 of file string_ops.h.

◆ tolower() [3/4]

constexpr std::string ghassanpl::string_ops::ascii::tolower ( std::string  str)
constexprnoexcept

Returns a copy of the string with all characters transformed to lower case.

Definition at line 407 of file string_ops.h.

◆ tolower() [4/4]

template<stringable T>
constexpr std::string ghassanpl::string_ops::ascii::tolower ( T const str)
constexprnoexcept

Returns a copy of the string with all characters transformed to lower case.

Definition at line 396 of file string_ops.h.

◆ toupper() [1/4]

constexpr char32_t ghassanpl::string_ops::ascii::toupper ( char32_t  cp)
constexprnoexcept

Definition at line 342 of file string_ops.h.

◆ toupper() [2/4]

std::string ghassanpl::string_ops::ascii::toupper ( const char str)
inlinenoexcept

Returns a copy of the string with all characters transformed to upper case.

Definition at line 438 of file string_ops.h.

◆ toupper() [3/4]

std::string ghassanpl::string_ops::ascii::toupper ( std::string  str)
inlinenoexcept

Returns a copy of the string with all characters transformed to upper case.

Definition at line 432 of file string_ops.h.

◆ toupper() [4/4]

template<stringable T>
std::string ghassanpl::string_ops::ascii::toupper ( T const str)
inlinenoexcept

Returns a copy of the string with all characters transformed to upper case.

Definition at line 421 of file string_ops.h.

◆ xdigit_to_number()

constexpr int ghassanpl::string_ops::ascii::xdigit_to_number ( char32_t  cp)
constexprnoexcept

Convert an ASCII xdigit to its numerical value (only gives meaningful results with valid xdigit arguments)

Definition at line 460 of file string_ops.h.

Variable Documentation

◆ alphabetic_chars

constexpr auto ghassanpl::string_ops::ascii::alphabetic_chars
inlineconstexpr

All characters that match ascii::isalpha.

Definition at line 370 of file string_ops.h.

◆ alphanumeric_chars

constexpr auto ghassanpl::string_ops::ascii::alphanumeric_chars
inlineconstexpr

All characters that match ascii::isalnum.

Definition at line 374 of file string_ops.h.

◆ blank_chars

constexpr auto ghassanpl::string_ops::ascii::blank_chars
inlineconstexpr

All characters that match ascii::isblank.

Definition at line 382 of file string_ops.h.

◆ control_chars

constexpr auto ghassanpl::string_ops::ascii::control_chars
inlineconstexpr

All characters that match ascii::iscntrl.

Definition at line 381 of file string_ops.h.

◆ digit_chars

constexpr auto ghassanpl::string_ops::ascii::digit_chars
inlineconstexpr

All characters that match ascii::isdigit.

Definition at line 371 of file string_ops.h.

◆ graphical_chars

constexpr auto ghassanpl::string_ops::ascii::graphical_chars
inlineconstexpr

All characters that match ascii::isgraph.

Definition at line 383 of file string_ops.h.

◆ hex_digit_chars

constexpr auto ghassanpl::string_ops::ascii::hex_digit_chars
inlineconstexpr

All characters that match ascii::isxdigit.

Definition at line 373 of file string_ops.h.

◆ identifier_chars

constexpr auto ghassanpl::string_ops::ascii::identifier_chars
inlineconstexpr

All characters that match ascii::isident.

Definition at line 375 of file string_ops.h.

◆ identifier_start_chars

constexpr auto ghassanpl::string_ops::ascii::identifier_start_chars
inlineconstexpr

All characters that match ascii::isidentstart.

Definition at line 376 of file string_ops.h.

◆ lowercase_chars

constexpr auto ghassanpl::string_ops::ascii::lowercase_chars
inlineconstexpr

All characters that match ascii::islower.

Definition at line 379 of file string_ops.h.

◆ octal_digit_chars

constexpr auto ghassanpl::string_ops::ascii::octal_digit_chars
inlineconstexpr

All characters that match ascii::isodigit.

Definition at line 372 of file string_ops.h.

◆ printable_chars

constexpr auto ghassanpl::string_ops::ascii::printable_chars
inlineconstexpr

All characters that match ascii::isprint.

Definition at line 384 of file string_ops.h.

◆ punctuation_chars

constexpr auto ghassanpl::string_ops::ascii::punctuation_chars
inlineconstexpr

All characters that match ascii::ispunct.

Definition at line 378 of file string_ops.h.

◆ uppercase_chars

constexpr auto ghassanpl::string_ops::ascii::uppercase_chars
inlineconstexpr

All characters that match ascii::isupper.

Definition at line 380 of file string_ops.h.

◆ whitespace_chars

constexpr auto ghassanpl::string_ops::ascii::whitespace_chars
inlineconstexpr

All characters that match ascii::isspace.

Definition at line 377 of file string_ops.h.