GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
grem::ascii Namespace Reference

Functions

constexpr bool isValidCharacter (char ch) noexcept
 Check if a character value represents a valid character in the ASCII table (values 0-127).
constexpr bool isControlCharacter (char ch) noexcept
 Check if a character value represents a control character in the ASCII table (values 0-31 and 127).
constexpr bool isPrintableCharacter (char ch) noexcept
 Check if a character value represents a printable character in the ASCII table (values 32-126).
constexpr bool isUppercase (char ch) noexcept
 Check if a character is an uppercase ASCII letter (A-Z).
constexpr bool isLowercase (char ch) noexcept
 Check if a character is a lowercase ASCII letter (a-z).
constexpr bool isLetter (char ch) noexcept
 Check if a character is an ASCII letter (A-Z or a-z).
constexpr bool isDecimalDigit (char ch) noexcept
 Check if a character is an ASCII decimal numeric digit (0-9).
constexpr char convertUppercaseToLowercaseCharacter (char ch)
 Convert an uppercase ASCII letter (A-Z) to its corresponding lowercase ASCII letter (a-z).
constexpr char convertLowercaseToUppercaseCharacter (char ch)
 Convert a lowercase ASCII letter (a-z) to its corresponding uppercase ASCII letter (A-Z).
constexpr char convertToLowercaseCharacter (char ch) noexcept
 Convert a character to its corresponding lowercase ASCII letter (a-z) if it has one.
constexpr char convertToUppercaseCharacter (char ch) noexcept
 Convert a character to its corresponding uppercase ASCII letter (A-Z) if it has one.
constexpr char convertToOppositeCaseCharacter (char ch) noexcept
 Convert a character to its opposite case if it is an ASCII letter.
constexpr String convertToLowercaseString (StringView string)
 Convert each character in a string to its corresponding lowercase ASCII letter (a-z) if it has one.
constexpr String convertToLowercaseString (String &&string)
 Convert each character in a string to its corresponding lowercase ASCII letter (a-z) if it has one.
constexpr String convertToUppercaseString (StringView string)
 Convert each character in a string to its corresponding uppercase ASCII letter (A-Z) if it has one.
constexpr String convertToUppercaseString (String &&string)
 Convert each character in a string to its corresponding uppercase ASCII letter (A-Z) if it has one.
constexpr bool caseInsensitiveEqual (char a, char b) noexcept
 Check if two characters are equal if any ASCII letters are treated as the same case, i.e. ignoring whether they are lowercase (a-z) or uppercase (A-Z).
constexpr bool caseInsensitiveEqual (const char *a, const char *b)
 Check if two null-terminated strings are equal if any ASCII letters are treated as the same case, i.e. ignoring whether they are lowercase (a-z) or uppercase (A-Z).
constexpr bool caseInsensitiveEqual (StringView a, StringView b)
 Check if two strings are equal if any ASCII letters are treated as the same case, i.e. ignoring whether they are lowercase (a-z) or uppercase (A-Z).

Function Documentation

◆ isValidCharacter()

bool grem::ascii::isValidCharacter ( char ch)
nodiscardconstexprnoexcept

Check if a character value represents a valid character in the ASCII table (values 0-127).

Parameters
chcharacter to check.
Returns
true if the character is valid, false otherwise.
Note
The null character ('\0') is considered valid.

◆ isControlCharacter()

bool grem::ascii::isControlCharacter ( char ch)
nodiscardconstexprnoexcept

Check if a character value represents a control character in the ASCII table (values 0-31 and 127).

Parameters
chcharacter to check.
Returns
true if the character is an ASCII control character, false otherwise.

◆ isPrintableCharacter()

bool grem::ascii::isPrintableCharacter ( char ch)
nodiscardconstexprnoexcept

Check if a character value represents a printable character in the ASCII table (values 32-126).

Parameters
chcharacter to check.
Returns
true if the character is a printable ASCII character, false otherwise.
Note
Control characters, like horizontal tab ('\t') or line feed ('\n'), are NOT considered printable. However, space (' ') is.

◆ isUppercase()

bool grem::ascii::isUppercase ( char ch)
nodiscardconstexprnoexcept

Check if a character is an uppercase ASCII letter (A-Z).

Parameters
chcharacter to check.
Returns
true if the character is an uppercase ASCII letter, false otherwise.

◆ isLowercase()

bool grem::ascii::isLowercase ( char ch)
nodiscardconstexprnoexcept

Check if a character is a lowercase ASCII letter (a-z).

Parameters
chcharacter to check.
Returns
true if the character is a lowercase ASCII letter, false otherwise.

◆ isLetter()

bool grem::ascii::isLetter ( char ch)
nodiscardconstexprnoexcept

Check if a character is an ASCII letter (A-Z or a-z).

Parameters
chcharacter to check.
Returns
true if the character is an ASCII letter, false otherwise.

◆ isDecimalDigit()

bool grem::ascii::isDecimalDigit ( char ch)
nodiscardconstexprnoexcept

Check if a character is an ASCII decimal numeric digit (0-9).

Parameters
chcharacter to check.
Returns
true if the character is an ASCII decimal digit, false otherwise.

◆ convertUppercaseToLowercaseCharacter()

char grem::ascii::convertUppercaseToLowercaseCharacter ( char ch)
nodiscardconstexpr

Convert an uppercase ASCII letter (A-Z) to its corresponding lowercase ASCII letter (a-z).

Parameters
chcharacter to convert. Must be a valid uppercase ASCII letter.
Returns
the lowercase version of the given uppercase letter.

◆ convertLowercaseToUppercaseCharacter()

char grem::ascii::convertLowercaseToUppercaseCharacter ( char ch)
nodiscardconstexpr

Convert a lowercase ASCII letter (a-z) to its corresponding uppercase ASCII letter (A-Z).

Parameters
chcharacter to convert. Must be a valid lowercase ASCII letter.
Returns
the uppercase version of the given lowercase letter.

◆ convertToLowercaseCharacter()

char grem::ascii::convertToLowercaseCharacter ( char ch)
nodiscardconstexprnoexcept

Convert a character to its corresponding lowercase ASCII letter (a-z) if it has one.

Parameters
chcharacter to convert.
Returns
the lowercase version of the given character if it is an uppercase ASCII letter, or a copy of the given character otherwise.

◆ convertToUppercaseCharacter()

char grem::ascii::convertToUppercaseCharacter ( char ch)
nodiscardconstexprnoexcept

Convert a character to its corresponding uppercase ASCII letter (A-Z) if it has one.

Parameters
chcharacter to convert.
Returns
the uppercase version of the given character if it is a lowercase ASCII letter, or a copy of the given character otherwise.

◆ convertToOppositeCaseCharacter()

char grem::ascii::convertToOppositeCaseCharacter ( char ch)
nodiscardconstexprnoexcept

Convert a character to its opposite case if it is an ASCII letter.

Parameters
chcharacter to convert.
Returns
the lowercase version of the given character if it is an uppercase ASCII letter, or the uppercase version of the given character if it is a lowercase ASCII letter, or a copy of the given character otherwise.

◆ convertToLowercaseString() [1/2]

String grem::ascii::convertToLowercaseString ( StringView string)
nodiscardconstexpr

Convert each character in a string to its corresponding lowercase ASCII letter (a-z) if it has one.

Parameters
stringstring to convert.
Returns
a string containing the lowercase version of each character in the given string that is an uppercase ASCII letter, or a copy for each character that isn't.
Exceptions
std::length_errorif the length of the given string exceeds the maximum supported allocated string size.
std::bad_allocon allocation failure.

◆ convertToLowercaseString() [2/2]

String grem::ascii::convertToLowercaseString ( String && string)
nodiscardconstexpr

Convert each character in a string to its corresponding lowercase ASCII letter (a-z) if it has one.

Parameters
stringstring to convert.
Returns
a string containing the lowercase version of each character in the given string that is an uppercase ASCII letter, or a copy for each character that isn't.

◆ convertToUppercaseString() [1/2]

String grem::ascii::convertToUppercaseString ( StringView string)
nodiscardconstexpr

Convert each character in a string to its corresponding uppercase ASCII letter (A-Z) if it has one.

Parameters
stringstring to convert.
Returns
a string containing the uppercase version of each character in the given string that is a lowercase ASCII letter, or a copy for each character that isn't.
Exceptions
std::length_errorif the length of the given string exceeds the maximum supported allocated string size.
std::bad_allocon allocation failure.

◆ convertToUppercaseString() [2/2]

String grem::ascii::convertToUppercaseString ( String && string)
nodiscardconstexpr

Convert each character in a string to its corresponding uppercase ASCII letter (A-Z) if it has one.

Parameters
stringstring to convert.
Returns
a string containing the uppercase version of each character in the given string that is a lowercase ASCII letter, or a copy for each character that isn't.

◆ caseInsensitiveEqual() [1/3]

bool grem::ascii::caseInsensitiveEqual ( char a,
char b )
nodiscardconstexprnoexcept

Check if two characters are equal if any ASCII letters are treated as the same case, i.e. ignoring whether they are lowercase (a-z) or uppercase (A-Z).

Parameters
afirst character.
bsecond character.
Returns
true if the given characters are equivalent when ignoring case, false otherwise.

◆ caseInsensitiveEqual() [2/3]

bool grem::ascii::caseInsensitiveEqual ( const char * a,
const char * b )
nodiscardconstexpr

Check if two null-terminated strings are equal if any ASCII letters are treated as the same case, i.e. ignoring whether they are lowercase (a-z) or uppercase (A-Z).

Parameters
afirst string. Must be null-terminated. Must not be nullptr.
bsecond string. Must be null-terminated. Must not be nullptr.
Returns
true if the given strings are equivalent when ignoring case, false otherwise.

◆ caseInsensitiveEqual() [3/3]

bool grem::ascii::caseInsensitiveEqual ( StringView a,
StringView b )
nodiscardconstexpr

Check if two strings are equal if any ASCII letters are treated as the same case, i.e. ignoring whether they are lowercase (a-z) or uppercase (A-Z).

Parameters
afirst string.
bsecond string.
Returns
true if the given strings are equivalent when ignoring case, false otherwise.