MayaFlux 0.2.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ from_char()

MAYAFLUX_API std::optional< Keys > MayaFlux::IO::from_char ( char  c)
noexcept

Converts a character to the corresponding Keys enum value.

Parameters
cThe character to convert.
Returns
An optional Keys value if the character matches a key, std::nullopt otherwise.

Definition at line 21 of file Keys.cpp.

22{
23 for (const auto& [ch, key] : char_to_keys) {
24 if (ch == c)
25 return key;
26 }
27
28 if (c >= '0' && c <= '9') {
29 return static_cast<Keys>(static_cast<int>(c));
30 }
31 if (c >= 'A' && c <= 'Z') {
32 return static_cast<Keys>(static_cast<int>(c));
33 }
34 if (c >= 'a' && c <= 'z') {
35 return static_cast<Keys>(static_cast<int>(c) - 32);
36 }
37
38 return std::nullopt;
39}

Referenced by from_string().

+ Here is the caller graph for this function: