#include <genesis/utils/tools/char_lookup.hpp>
Simple lookup table providing a value lookup for each ASCII char (0-127).
The class provides a fast mapping from each char to the provided template parameter type.
Definition at line 54 of file char_lookup.hpp.
Public Member Functions | |
CharLookup () | |
Constructor that sets all values to the default value of the template parameter type. More... | |
CharLookup (CharLookup &&)=default | |
CharLookup (CharLookup const &)=default | |
CharLookup (std::initializer_list< T > init) | |
Constructor that takes an initializer list of the template type. More... | |
CharLookup (T const &init_all) | |
Constructor that sets all values to a given one. More... | |
~CharLookup ()=default | |
bool | all_equal_to (T comp_value) const |
Return whether all chars compare equal to a given value. More... | |
T | get (char c) const |
Return the lookup status for a given char. More... | |
std::string | get_chars_equal_to (T comp_value) const |
Return a std::string containg all chars which have lookup status equal to a given value. More... | |
CharLookup & | operator= (CharLookup &&)=default |
CharLookup & | operator= (CharLookup const &)=default |
T | operator[] (char c) const |
Return the lookup status for a given char. More... | |
void | set_all (T value) |
Set the lookup status for all chars at once. More... | |
void | set_char (char c, T value) |
Set the lookup status for a given char. More... | |
void | set_char_upper_lower (char c, T value) |
Set the lookup status for both the upper and lower case of a given char. More... | |
void | set_if (std::function< bool(char)> predicate, T value) |
Set the lookup status for all chars that fulfill a given predicate. More... | |
void | set_range (char first, char last, T value) |
Set the lookup status for all chars in an inlcuding range between two chars. More... | |
void | set_selection (std::string const &chars, T value) |
Set the lookup status for all chars that are contained in a given std::string. More... | |
void | set_selection_upper_lower (std::string const &chars, T value) |
Set the lookup status for both the upper and lower case of all chars that are contained in a given std::string. More... | |
Public Types | |
using | key_type = char |
using | value_type = T |
Static Public Attributes | |
static const size_t | ArraySize = 128 |
|
inline |
Constructor that sets all values to the default value of the template parameter type.
Definition at line 74 of file char_lookup.hpp.
|
inlineexplicit |
Constructor that sets all values to a given one.
Definition at line 81 of file char_lookup.hpp.
|
inlineexplicit |
Constructor that takes an initializer list of the template type.
The given list needs to have as many entries as the lookup table itself (see ArraySize), otherwise it throws.
Definition at line 94 of file char_lookup.hpp.
|
default |
|
default |
|
default |
|
inline |
Return whether all chars compare equal to a given value.
Definition at line 242 of file char_lookup.hpp.
|
inline |
Return the lookup status for a given char.
Definition at line 218 of file char_lookup.hpp.
|
inline |
Return a std::string
containg all chars which have lookup status equal to a given value.
Definition at line 228 of file char_lookup.hpp.
|
default |
|
default |
|
inline |
Return the lookup status for a given char.
We only provide the const getter version of this operator in order to avoid accidentally setting the value. Use one of the set...()
functions explicitily for this.
Definition at line 209 of file char_lookup.hpp.
|
inline |
Set the lookup status for all chars at once.
Definition at line 192 of file char_lookup.hpp.
|
inline |
Set the lookup status for a given char.
Definition at line 126 of file char_lookup.hpp.
|
inline |
Set the lookup status for both the upper and lower case of a given char.
Definition at line 135 of file char_lookup.hpp.
|
inline |
Set the lookup status for all chars that fulfill a given predicate.
Definition at line 145 of file char_lookup.hpp.
|
inline |
Set the lookup status for all chars in an inlcuding range between two chars.
Definition at line 181 of file char_lookup.hpp.
|
inline |
Set the lookup status for all chars that are contained in a given std::string.
Definition at line 157 of file char_lookup.hpp.
|
inline |
Set the lookup status for both the upper and lower case of all chars that are contained in a given std::string.
Definition at line 169 of file char_lookup.hpp.
using key_type = char |
Definition at line 63 of file char_lookup.hpp.
using value_type = T |
Definition at line 62 of file char_lookup.hpp.
|
static |
Definition at line 65 of file char_lookup.hpp.