KanoopCommonQt 2.1.1
Kanoop foundational Qt utility library
Loading...
Searching...
No Matches
KANOOP::EnumToStringMap< T > Class Template Reference

A QMap subclass providing bidirectional enum-to-string lookups. More...

#include <kanoopcommon.h>

+ Inheritance diagram for KANOOP::EnumToStringMap< T >:
+ Collaboration diagram for KANOOP::EnumToStringMap< T >:

Public Member Functions

QString getString (T type, const QString &defaultValue=QString()) const
 Look up the string name for an enum value.
 
getType (const QString &name, Qt::CaseSensitivity caseSensitivity, const T defaultValue=T()) const
 Look up the enum value for a string name, with case sensitivity control.
 
getType (const QString &name, const T defaultValue=T()) const
 Look up the enum value for a string name using case-sensitive comparison.
 
QList< T > getTypes () const
 Return all enum values registered in this map.
 
bool containsString (const QString &name, Qt::CaseSensitivity cs=Qt::CaseInsensitive) const
 Test whether the map contains a given string value.
 

Detailed Description

template<class T>
class KANOOP::EnumToStringMap< T >

A QMap subclass providing bidirectional enum-to-string lookups.

Template Parameters
TEnumeration type used as the map key

Definition at line 48 of file kanoopcommon.h.

Member Function Documentation

◆ containsString()

template<class T >
bool KANOOP::EnumToStringMap< T >::containsString ( const QString &  name,
Qt::CaseSensitivity  cs = Qt::CaseInsensitive 
) const
inline

Test whether the map contains a given string value.

Parameters
nameString to search for
csCase sensitivity flag (default Qt::CaseInsensitive)
Returns
true if name matches any registered string value

Definition at line 116 of file kanoopcommon.h.

◆ getString()

template<class T >
QString KANOOP::EnumToStringMap< T >::getString ( type,
const QString &  defaultValue = QString() 
) const
inline

Look up the string name for an enum value.

Parameters
typeEnum value to look up
defaultValueValue to return if not found
Returns
Registered string name, or defaultValue

Definition at line 57 of file kanoopcommon.h.

◆ getType() [1/2]

template<class T >
T KANOOP::EnumToStringMap< T >::getType ( const QString &  name,
const T  defaultValue = T() 
) const
inline

Look up the enum value for a string name using case-sensitive comparison.

Parameters
nameString to look up
defaultValueValue returned when no match is found
Returns
Matching enum value, or defaultValue

Definition at line 95 of file kanoopcommon.h.

References KANOOP::EnumToStringMap< T >::getType().

◆ getType() [2/2]

template<class T >
T KANOOP::EnumToStringMap< T >::getType ( const QString &  name,
Qt::CaseSensitivity  caseSensitivity,
const T  defaultValue = T() 
) const
inline

Look up the enum value for a string name, with case sensitivity control.

Parameters
nameString to look up
caseSensitivityQt::CaseSensitive or Qt::CaseInsensitive
defaultValueValue returned when no match is found
Returns
Matching enum value, or defaultValue

Definition at line 72 of file kanoopcommon.h.

Referenced by KANOOP::EnumToStringMap< T >::getType().

◆ getTypes()

template<class T >
QList< T > KANOOP::EnumToStringMap< T >::getTypes ( ) const
inline

Return all enum values registered in this map.

Returns
List of all registered enum values

Definition at line 104 of file kanoopcommon.h.


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