LookupTable< EnumType, RecordType, Hasher > Class Template Reference

#include <LookupTable.h>

Collaboration diagram for LookupTable< EnumType, RecordType, Hasher >:

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

template<typename EnumType, typename RecordType = LookupTableRecord<EnumType>, typename Hasher = CaseInsensitiveSBufHash>
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

template<typename EnumType , typename RecordType = LookupTableRecord<EnumType>, typename Hasher = CaseInsensitiveSBufHash>
using LookupTable< EnumType, RecordType, Hasher >::lookupTable_t = std::unordered_map<const SBuf, EnumType, Hasher, CaseInsensitiveSBufEqual>
private

Definition at line 73 of file LookupTable.h.

◆ Record

template<typename EnumType , typename RecordType = LookupTableRecord<EnumType>, typename Hasher = CaseInsensitiveSBufHash>
typedef RecordType LookupTable< EnumType, RecordType, Hasher >::Record

Definition at line 55 of file LookupTable.h.

Constructor & Destructor Documentation

◆ LookupTable()

template<typename EnumType , typename RecordType = LookupTableRecord<EnumType>, typename Hasher = CaseInsensitiveSBufHash>
LookupTable< EnumType, RecordType, Hasher >::LookupTable ( const EnumType  theInvalid,
const Record  data[] 
)
inline

Member Function Documentation

◆ lookup()

template<typename EnumType , typename RecordType = LookupTableRecord<EnumType>, typename Hasher = CaseInsensitiveSBufHash>
EnumType LookupTable< EnumType, RecordType, Hasher >::lookup ( const SBuf key) const
inline

Member Data Documentation

◆ invalidValue

template<typename EnumType , typename RecordType = LookupTableRecord<EnumType>, typename Hasher = CaseInsensitiveSBufHash>
EnumType LookupTable< EnumType, RecordType, Hasher >::invalidValue
private

Definition at line 75 of file LookupTable.h.

Referenced by LookupTable< EnumType, RecordType, Hasher >::lookup().

◆ lookupTable

template<typename EnumType , typename RecordType = LookupTableRecord<EnumType>, typename Hasher = CaseInsensitiveSBufHash>
lookupTable_t LookupTable< EnumType, RecordType, Hasher >::lookupTable
private

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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors