libfly  6.2.2
C++20 utility library for Linux, macOS, and Windows
fly::detail::BasicClassifier< CharType > Class Template Reference

#include <classifier.hpp>

Public Member Functions

template<fly::StandardStringLike T>
constexpr auto size (T &&value) -> size_type
 
template<std::size_t N>
constexpr auto size (const CharType(&value)[N]) -> size_type
 

Static Public Member Functions

template<fly::StandardStringLike T>
static constexpr size_type size (T &&value)
 
template<std::size_t N>
static constexpr size_type size (const CharType(&value)[N])
 
static constexpr bool is_alpha (CharType ch)
 
static constexpr bool is_upper (CharType ch)
 
static constexpr bool is_lower (CharType ch)
 
static constexpr CharType to_upper (CharType ch)
 
static constexpr CharType to_lower (CharType ch)
 
static constexpr bool is_digit (CharType ch)
 
static constexpr bool is_x_digit (CharType ch)
 
static constexpr bool is_space (CharType ch)
 

Detailed Description

template<fly::StandardCharacter CharType>
class fly::detail::BasicClassifier< CharType >

Helper class to provide safe alernatives to the STL's <cctype> methods.

Author
Timothy Flynn (trfly.nosp@m.nn89.nosp@m.@pm.m.nosp@m.e)
Version
January 3, 2021

Member Function Documentation

◆ is_alpha()

template<fly::StandardCharacter CharType>
constexpr bool fly::detail::BasicClassifier< CharType >::is_alpha ( CharType  ch)
staticconstexpr

Checks if the given character is an alphabetic character as classified by the default C locale.

The STL's std::isalpha and std::iswalpha require that the provided character fits into an unsigned char and unsigned wchar_t, respectively. Other values result in undefined behavior. This method has no such restriction.

Parameters
chThe character to classify.
Returns
True if the character is an alphabetic character.

◆ is_digit()

template<fly::StandardCharacter CharType>
constexpr bool fly::detail::BasicClassifier< CharType >::is_digit ( CharType  ch)
staticconstexpr

Checks if the given character is a decimal digit character.

The STL's std::isdigit and std::iswdigit require that the provided character fits into an unsigned char and unsigned wchar_t, respectively. Other values result in undefined behavior. This method has no such restriction.

Parameters
chThe character to classify.
Returns
True if the character is a decimal digit character.

◆ is_lower()

template<fly::StandardCharacter CharType>
constexpr bool fly::detail::BasicClassifier< CharType >::is_lower ( CharType  ch)
staticconstexpr

Checks if the given character is a lower-case alphabetic character as classified by the default C locale.

The STL's std::islower and std::iswlower require that the provided character fits into an unsigned char and unsigned wchar_t, respectively. Other values result in undefined behavior. This method has no such restriction.

Parameters
chThe character to classify.
Returns
True if the character is an alphabetic character.

◆ is_space()

template<fly::StandardCharacter CharType>
constexpr bool fly::detail::BasicClassifier< CharType >::is_space ( CharType  ch)
staticconstexpr

Checks if the given character is a whitespace character as classified by the default C locale.

The STL's std::isspace and std::iswspace require that the provided character fits into an unsigned char and unsigned wchar_t, respectively. Other values result in undefined behavior. This method has no such restriction.

Parameters
chThe character to classify.
Returns
True if the character is a whitespace character.

◆ is_upper()

template<fly::StandardCharacter CharType>
constexpr bool fly::detail::BasicClassifier< CharType >::is_upper ( CharType  ch)
staticconstexpr

Checks if the given character is an upper-case alphabetic character as classified by the default C locale.

The STL's std::isupper and std::iswupper require that the provided character fits into an unsigned char and unsigned wchar_t, respectively. Other values result in undefined behavior. This method has no such restriction.

Parameters
chThe character to classify.
Returns
True if the character is an alphabetic character.

◆ is_x_digit()

template<fly::StandardCharacter CharType>
constexpr bool fly::detail::BasicClassifier< CharType >::is_x_digit ( CharType  ch)
staticconstexpr

Checks if the given character is a hexadecimal digit character.

The STL's std::isxdigit and std::iswxdigit require that the provided character fits into an unsigned char and unsigned wchar_t, respectively. Other values result in undefined behavior. This method has no such restriction.

Parameters
chThe character to classify.
Returns
True if the character is a hexadecimal digit character.

◆ size() [1/2]

template<fly::StandardCharacter CharType>
template<std::size_t N>
static constexpr size_type fly::detail::BasicClassifier< CharType >::size ( const CharType(&)  value[N])
staticconstexpr

Determine the length of a character array value, excluding the null terminator (if present).

Parameters
valueThe character array.
Returns
The length of the character array.

◆ size() [2/2]

template<fly::StandardCharacter CharType>
template<fly::StandardStringLike T>
static constexpr size_type fly::detail::BasicClassifier< CharType >::size ( T &&  value)
staticconstexpr

Determine the length of any string-like value. Accepts std::basic_string and std::basic_string_view specializations.

Template Parameters
TThe string-like type.
Parameters
valueThe string-like value.
Returns
The length of the string-like value.

◆ to_lower()

template<fly::StandardCharacter CharType>
constexpr CharType fly::detail::BasicClassifier< CharType >::to_lower ( CharType  ch)
staticconstexpr

Converts the given character to a lower-case alphabetic character as classified by the default C locale.

The STL's std:tolower and std::towlower require that the provided character fits into an unsigned char and unsigned wchar_t, respectively. Other values result in undefined behavior. This method has no such restriction.

Parameters
chThe character to convert.
Returns
The converted character.

◆ to_upper()

template<fly::StandardCharacter CharType>
constexpr CharType fly::detail::BasicClassifier< CharType >::to_upper ( CharType  ch)
staticconstexpr

Converts the given character to an upper-case alphabetic character as classified by the default C locale.

The STL's std:toupper and std::towupper require that the provided character fits into an unsigned char and unsigned wchar_t, respectively. Other values result in undefined behavior. This method has no such restriction.

Parameters
chThe character to convert.
Returns
The converted character.

The documentation for this class was generated from the following file: