#include <LookupTable.h>
Public Types | |
typedef RecordType | Record |
element of the lookup table initialization list More... | |
Public Member Functions | |
LookupTable (const EnumType theInvalid, const Record data[]) | |
EnumType | lookup (const SBuf &key) const |
Private Types | |
using | lookupTable_t = std::unordered_map< const SBuf, EnumType, Hasher, CaseInsensitiveSBufEqual > |
Private Attributes | |
lookupTable_t | lookupTable |
EnumType | invalidValue |
Detailed Description
class LookupTable< EnumType, RecordType, Hasher >
SBuf -> case-insensitive enum lookup table
How to use: enum enum_type { ... }; static const LookupTable<enum_type>::Record initializerTable[] = { {"key1", ENUM_1}, {"key2", ENUM_2}, ... {nullptr, ENUM_INVALID_VALUE} }; LookupTable<enum_type> lookupTableInstance(ENUM_INVALID_VALUE, initializerTable);
then in the code: SBuf s(string_to_lookup); enum_type item = lookupTableInstance.lookup(s); if (item != ENUM_INVALID_VALUE) { // do stuff }
Definition at line 51 of file LookupTable.h.
Member Typedef Documentation
◆ lookupTable_t
|
private |
Definition at line 73 of file LookupTable.h.
◆ Record
typedef RecordType LookupTable< EnumType, RecordType, Hasher >::Record |
Definition at line 55 of file LookupTable.h.
Constructor & Destructor Documentation
◆ LookupTable()
|
inline |
Definition at line 57 of file LookupTable.h.
References LookupTableRecord< EnumType >::id, LookupTable< EnumType, RecordType, Hasher >::lookupTable, and LookupTableRecord< EnumType >::name.
Member Function Documentation
◆ lookup()
|
inline |
Definition at line 65 of file LookupTable.h.
References LookupTable< EnumType, RecordType, Hasher >::invalidValue, and LookupTable< EnumType, RecordType, Hasher >::lookupTable.
Referenced by TestLookupTable::testLookupTableLookup().
Member Data Documentation
◆ invalidValue
|
private |
Definition at line 75 of file LookupTable.h.
Referenced by LookupTable< EnumType, RecordType, Hasher >::lookup().
◆ lookupTable
|
private |
Definition at line 74 of file LookupTable.h.
Referenced by LookupTable< EnumType, RecordType, Hasher >::LookupTable(), and LookupTable< EnumType, RecordType, Hasher >::lookup().
The documentation for this class was generated from the following file:
- src/base/LookupTable.h