pianod2
multisource multiuser scriptable networked music player
Public Member Functions | Private Attributes | List of all members
LookupTable< EnumClass, LookupTableType > Class Template Reference

Class to map between enumerations and their text values. More...

#include <lookup.h>

Public Member Functions

 LookupTable ()=delete
 
 LookupTable (const LookupTable< EnumClass, LookupTableType > &)=delete
 
 LookupTable (const LookupTable< EnumClass, LookupTableType > &&)=delete
 
 LookupTable (const LookupTableType *tab)
 Initialize the lookup table from an array. More...
 
 LookupTable (const std::initializer_list< LookupTableType > tab)
 Initialize the lookup table from an initializer list. More...
 
 ~LookupTable ()
 
virtual const LookupTableType * get (const char *s) const noexcept
 Retrieve a table entry by the text name of an entry. More...
 
const EnumClass operator[] (const char *s) const
 Retrieve the enumerator corresponding to text name. More...
 
const EnumClass operator[] (const std::string &s) const
 Retrieve the enumerator corresponding to text name. More...
 
const bool tryGetValue (const char *s, EnumClass *value) const
 Retrieve the enumerator corresponding to a text value. More...
 
const bool tryGetValue (const std::string &s, EnumClass *value) const
 
const LookupTableType * get (const EnumClass id) const
 Retrieve a table entry by the enumerator of an entry. More...
 
const char * operator[] (const EnumClass id) const
 Retrieve the text name of an enumerator. More...
 
const LookupTableType * begin () const
 
const LookupTableType * end () const
 

Private Attributes

const LookupTableType * table = NULL
 
const int table_size = 0
 
bool release = false
 

Detailed Description

template<class EnumClass, class LookupTableType = StandardLookupValues <EnumClass>>
class LookupTable< EnumClass, LookupTableType >

Class to map between enumerations and their text values.

Constructor & Destructor Documentation

◆ LookupTable() [1/5]

template<class EnumClass , class LookupTableType = StandardLookupValues <EnumClass>>
LookupTable< EnumClass, LookupTableType >::LookupTable ( )
delete

◆ LookupTable() [2/5]

template<class EnumClass , class LookupTableType = StandardLookupValues <EnumClass>>
LookupTable< EnumClass, LookupTableType >::LookupTable ( const LookupTable< EnumClass, LookupTableType > &  )
delete

◆ LookupTable() [3/5]

template<class EnumClass , class LookupTableType = StandardLookupValues <EnumClass>>
LookupTable< EnumClass, LookupTableType >::LookupTable ( const LookupTable< EnumClass, LookupTableType > &&  )
delete

◆ LookupTable() [4/5]

template<class EnumClass , class LookupTableType = StandardLookupValues <EnumClass>>
LookupTable< EnumClass, LookupTableType >::LookupTable ( const LookupTableType *  tab)
inline

Initialize the lookup table from an array.

Requires a NULL entry at the end.

◆ LookupTable() [5/5]

template<class EnumClass , class LookupTableType = StandardLookupValues <EnumClass>>
LookupTable< EnumClass, LookupTableType >::LookupTable ( const std::initializer_list< LookupTableType >  tab)
inline

Initialize the lookup table from an initializer list.

No NULL entry needed.

◆ ~LookupTable()

template<class EnumClass , class LookupTableType = StandardLookupValues <EnumClass>>
LookupTable< EnumClass, LookupTableType >::~LookupTable ( )
inline

Member Function Documentation

◆ begin()

template<class EnumClass , class LookupTableType = StandardLookupValues <EnumClass>>
const LookupTableType* LookupTable< EnumClass, LookupTableType >::begin ( ) const
inline

◆ end()

template<class EnumClass , class LookupTableType = StandardLookupValues <EnumClass>>
const LookupTableType* LookupTable< EnumClass, LookupTableType >::end ( ) const
inline

◆ get() [1/2]

template<class EnumClass , class LookupTableType = StandardLookupValues <EnumClass>>
virtual const LookupTableType* LookupTable< EnumClass, LookupTableType >::get ( const char *  s) const
inlinevirtualnoexcept

Retrieve a table entry by the text name of an entry.

Parameters
sthe text name
Returns
Pointer to table entry, or NULL if not found.

Reimplemented in RatingLookup.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get() [2/2]

template<class EnumClass , class LookupTableType = StandardLookupValues <EnumClass>>
const LookupTableType* LookupTable< EnumClass, LookupTableType >::get ( const EnumClass  id) const
inline

Retrieve a table entry by the enumerator of an entry.

Parameters
idThe enumerator
Returns
Pointer to table entry, or NULL if not found.

◆ operator[]() [1/3]

template<class EnumClass , class LookupTableType = StandardLookupValues <EnumClass>>
const EnumClass LookupTable< EnumClass, LookupTableType >::operator[] ( const char *  s) const
inline

Retrieve the enumerator corresponding to text name.

Exceptions
CommandErrorif the text name is invalid.
Parameters
sThe text name
Returns
Enumerator corresponding to text.
Here is the call graph for this function:

◆ operator[]() [2/3]

template<class EnumClass , class LookupTableType = StandardLookupValues <EnumClass>>
const char* LookupTable< EnumClass, LookupTableType >::operator[] ( const EnumClass  id) const
inline

Retrieve the text name of an enumerator.

Parameters
idThe enumerator
Returns
The text name, or NULL if not found.
Here is the call graph for this function:

◆ operator[]() [3/3]

template<class EnumClass , class LookupTableType = StandardLookupValues <EnumClass>>
const EnumClass LookupTable< EnumClass, LookupTableType >::operator[] ( const std::string &  s) const
inline

Retrieve the enumerator corresponding to text name.

Exceptions
CommandErrorif the text name is invalid.
Parameters
sThe text name
Returns
Enumerator corresponding to text.

◆ tryGetValue() [1/2]

template<class EnumClass , class LookupTableType = StandardLookupValues <EnumClass>>
const bool LookupTable< EnumClass, LookupTableType >::tryGetValue ( const char *  s,
EnumClass *  value 
) const
inline

Retrieve the enumerator corresponding to a text value.

Parameters
sThe text name
valueThe destination for the enumerator. Existing value is unchanged if text name is invalid.
Returns
true if successful, false if text name was invalid.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tryGetValue() [2/2]

template<class EnumClass , class LookupTableType = StandardLookupValues <EnumClass>>
const bool LookupTable< EnumClass, LookupTableType >::tryGetValue ( const std::string &  s,
EnumClass *  value 
) const
inline
Here is the call graph for this function:

Member Data Documentation

◆ release

template<class EnumClass , class LookupTableType = StandardLookupValues <EnumClass>>
bool LookupTable< EnumClass, LookupTableType >::release = false
private

◆ table

template<class EnumClass , class LookupTableType = StandardLookupValues <EnumClass>>
const LookupTableType* LookupTable< EnumClass, LookupTableType >::table = NULL
private

◆ table_size

template<class EnumClass , class LookupTableType = StandardLookupValues <EnumClass>>
const int LookupTable< EnumClass, LookupTableType >::table_size = 0
private

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