Enumeration string mapping template class. More...

#include "murl_enum.h"

Classes

struct  Item
 Definition of an Enum initialization item. More...
 

Public Types

typedef EnumType ValueType
 The template parameter value type. More...
 

Public Member Functions

 Enum (const Item *items, UInt32 numberOfElements)
 Constructor taking an array of enum items. More...
 
 Enum (const String &name, const Item *items, UInt32 numberOfElements)
 Constructor taking an enumeration name and an array of enum items. More...
 
 Enum (const String &name, EnumContainer &container, const Item *items, UInt32 numberOfElements)
 Constructor taking an array of enum items and a container. More...
 
const StringGetName () const
 Get the name of the enumerator. More...
 
EnumType GetDefaultValue () const
 Get the default enumeration value. More...
 
UInt32 GetCount () const
 Get the total number of enumeration entries. More...
 
Bool IsEnumValueAvailable (EnumType value) const
 Check if an enumeration value is available. More...
 
Bool IsEnumNameAvailable (const String &name) const
 Check if an enumeration name is available. More...
 
SInt32 GetEnumIndexByValue (EnumType value) const
 Get the zero-based index of an enumeration value. More...
 
SInt32 GetEnumIndexByValue (EnumType value, UInt32 hash) const
 Get the zero-based index of an enumeration value. More...
 
SInt32 GetEnumIndexByName (const String &name) const
 Get the zero-based index of an enumeration name. More...
 
SInt32 GetEnumIndexByName (const String &name, UInt32 hash) const
 Get the zero-based index of an enumeration name. More...
 
const StringGetEnumNameByIndex (UInt32 index) const
 Get the enumeration name at a given index. More...
 
EnumType GetEnumValueByIndex (UInt32 index) const
 Get the enumeration value at a given index. More...
 
const StringGetEnumNameByValue (EnumType value, Bool &error, Bool clearError) const
 Get the enumeration name for a given enumeration value. More...
 
const StringGetEnumNameByValue (EnumType value, Bool &error) const
 Get the enumeration name for a given enumeration value. More...
 
const StringGetEnumNameByValue (EnumType value) const
 Get the enumeration name for a given enumeration value. More...
 
EnumType GetEnumValueByName (const String &name, Bool &error, Bool clearError) const
 Get the enumeration value for a given enumeration name. More...
 
EnumType GetEnumValueByName (const String &name, Bool &error) const
 Get the enumeration value for a given enumeration name. More...
 
EnumType GetEnumValueByName (const String &name) const
 Get the enumeration value for a given enumeration name. More...
 
const StringGetEnumNameByValue (EnumType value, UInt32 hash, Bool &error, Bool clearError) const
 Get the enumeration name for a given enumeration value, using a precomputed hash value. More...
 
const StringGetEnumNameByValue (EnumType value, UInt32 hash, Bool &error) const
 Get the enumeration name for a given enumeration value, using a precomputed hash value. More...
 
const StringGetEnumNameByValue (EnumType value, UInt32 hash) const
 Get the enumeration name for a given enumeration value, using a precomputed hash value. More...
 
EnumType GetEnumValueByName (const String &name, UInt32 hash, Bool &error, Bool clearError) const
 Get the enumeration value for a given enumeration name, using a precomputed hash value. More...
 
EnumType GetEnumValueByName (const String &name, UInt32 hash, Bool &error) const
 Get the enumeration value for a given enumeration name, using a precomputed hash value. More...
 
EnumType GetEnumValueByName (const String &name, UInt32 hash) const
 Get the enumeration value for a given enumeration name, using a precomputed hash value. More...
 
const Map< String, UInt32 > & GetItemsByName () const
 Get the enumeration values by name map. More...
 
const Map< UInt32, String > & GetItemsByValue () const
 Get the names by enumeration value map. More...
 
 operator const Enum< SInt32 > & () const
 Conversion operator. More...
 

Protected Attributes

Map< String, UInt32mItemsByName
 The enumeration values by name map. More...
 
Map< UInt32, StringmItemsByValue
 The names by enumeration value map. More...
 
EnumType mDefaultValue
 The default enumeration value. More...
 
String mName
 The name of the enumerator. More...
 

Detailed Description

template<class EnumType>
class Murl::Enum< EnumType >

Enumeration string mapping template class.

Member Typedef Documentation

◆ ValueType

template<class EnumType>
typedef EnumType Murl::Enum< EnumType >::ValueType

The template parameter value type.

Constructor & Destructor Documentation

◆ Enum() [1/3]

template<class EnumType>
Murl::Enum< EnumType >::Enum ( const Item items,
UInt32  numberOfElements 
)
inline

Constructor taking an array of enum items.

Parameters
itemsPointer to an array of initialization items. If the item's mName has a null pointer, the mValue is the default value.
numberOfElementsThe number of elements in the array. The macro NUMBER_OF_ARRAY_ELEMENTS can be used to determine the number.

◆ Enum() [2/3]

template<class EnumType>
Murl::Enum< EnumType >::Enum ( const String name,
const Item items,
UInt32  numberOfElements 
)
inline

Constructor taking an enumeration name and an array of enum items.

Parameters
nameThe enumeration's name.
itemsPointer to an array of initialization items. If the item's mName has a null pointer, the mValue is the default value.
numberOfElementsThe number of elements in the array. The macro NUMBER_OF_ARRAY_ELEMENTS can be used to determine the number.

◆ Enum() [3/3]

template<class EnumType>
Murl::Enum< EnumType >::Enum ( const String name,
EnumContainer container,
const Item items,
UInt32  numberOfElements 
)
inline

Constructor taking an array of enum items and a container.

Parameters
nameThe enumeration's name.
containerThe container to add this enumeration to.
itemsPointer to an array of initialization items. If the item's mName has a null pointer, the mValue is the default value.
numberOfElementsThe number of elements in the array. The macro NUMBER_OF_ARRAY_ELEMENTS can be used to determine the number.

Member Function Documentation

◆ GetName()

template<class EnumType>
const String& Murl::Enum< EnumType >::GetName ( ) const
inline

Get the name of the enumerator.

Returns
The name of the enumerator.

◆ GetDefaultValue()

template<class EnumType>
EnumType Murl::Enum< EnumType >::GetDefaultValue ( ) const
inline

Get the default enumeration value.

Returns
The default value.

◆ GetCount()

template<class EnumType>
UInt32 Murl::Enum< EnumType >::GetCount ( ) const
inline

Get the total number of enumeration entries.

Returns
The number of entries.

◆ IsEnumValueAvailable()

template<class EnumType>
Bool Murl::Enum< EnumType >::IsEnumValueAvailable ( EnumType  value) const
inline

Check if an enumeration value is available.

Parameters
valueThe enumeration value to check.
Returns
true if the enumeration value is available.

◆ IsEnumNameAvailable()

template<class EnumType>
Bool Murl::Enum< EnumType >::IsEnumNameAvailable ( const String name) const
inline

Check if an enumeration name is available.

Parameters
nameThe enumeration name to check.
Returns
true if the enumeration name is available.

◆ GetEnumIndexByValue() [1/2]

template<class EnumType>
SInt32 Murl::Enum< EnumType >::GetEnumIndexByValue ( EnumType  value) const
inline

Get the zero-based index of an enumeration value.

Parameters
valueThe enumeration value to check.
Returns
The index in the range from 0 to GetCount()-1, or -1 if not found.

◆ GetEnumIndexByValue() [2/2]

template<class EnumType>
SInt32 Murl::Enum< EnumType >::GetEnumIndexByValue ( EnumType  value,
UInt32  hash 
) const
inline

Get the zero-based index of an enumeration value.

Parameters
valueThe enumeration value to check.
hashThe precomputed hash value.
Returns
The index in the range from 0 to GetCount()-1, or -1 if not found.

◆ GetEnumIndexByName() [1/2]

template<class EnumType>
SInt32 Murl::Enum< EnumType >::GetEnumIndexByName ( const String name) const
inline

Get the zero-based index of an enumeration name.

Parameters
nameThe enumeration name to check.
Returns
The index in the range from 0 to GetCount()-1, or -1 if not found.

◆ GetEnumIndexByName() [2/2]

template<class EnumType>
SInt32 Murl::Enum< EnumType >::GetEnumIndexByName ( const String name,
UInt32  hash 
) const
inline

Get the zero-based index of an enumeration name.

Parameters
nameThe enumeration name to check.
hashThe precomputed hash value.
Returns
The index in the range from 0 to GetCount()-1, or -1 if not found.

◆ GetEnumNameByIndex()

template<class EnumType>
const String& Murl::Enum< EnumType >::GetEnumNameByIndex ( UInt32  index) const
inline

Get the enumeration name at a given index.

Parameters
indexThe index to query, in the range from 0 to GetCount()-1.
Returns
The enumeration name, or an empty string if index is out of range.

◆ GetEnumValueByIndex()

template<class EnumType>
EnumType Murl::Enum< EnumType >::GetEnumValueByIndex ( UInt32  index) const
inline

Get the enumeration value at a given index.

Parameters
indexThe index to query, in the range from 0 to GetCount()-1.
Returns
The enumeration value, or the default value if index is out of range.

◆ GetEnumNameByValue() [1/6]

template<class EnumType>
const String& Murl::Enum< EnumType >::GetEnumNameByValue ( EnumType  value,
Bool error,
Bool  clearError 
) const
inline

Get the enumeration name for a given enumeration value.

Parameters
valueThe enumeration value to look up.
errorThe error return value is set to true if the value is not found.
clearErrorIf false, the error parameter is left in its given state if no error occurred.
Returns
The string of the enumeration value or an empty string if the value is not found.

Referenced by Murl::Enum< SInt32 >::GetEnumNameByValue().

◆ GetEnumNameByValue() [2/6]

template<class EnumType>
const String& Murl::Enum< EnumType >::GetEnumNameByValue ( EnumType  value,
Bool error 
) const
inline

Get the enumeration name for a given enumeration value.

Parameters
valueThe enumeration value to look up.
errorThe error return value is set to true if the value is not found, or false if OK.
Returns
The string of the enumeration value or an empty string if the value is not found.

◆ GetEnumNameByValue() [3/6]

template<class EnumType>
const String& Murl::Enum< EnumType >::GetEnumNameByValue ( EnumType  value) const
inline

Get the enumeration name for a given enumeration value.

Parameters
valueThe enumeration value to look up.
Returns
The string of the enumeration value or an empty string if the value is not found.

◆ GetEnumValueByName() [1/6]

template<class EnumType>
EnumType Murl::Enum< EnumType >::GetEnumValueByName ( const String name,
Bool error,
Bool  clearError 
) const
inline

Get the enumeration value for a given enumeration name.

Parameters
nameThe name string to look up.
errorThe error return value is set to true if the name is not found.
clearErrorIf false, the error parameter is left in its given state if no error occurred.
Returns
The enumeration value of the string or the default value if the string is not found.

Referenced by Murl::IAttributes::GetEnumBitsToSetByIndex(), Murl::IAttributes::GetEnumValueByIndex(), Murl::Enum< SInt32 >::GetEnumValueByName(), and Murl::IAttributes::GetEnumValuesByIndex().

◆ GetEnumValueByName() [2/6]

template<class EnumType>
EnumType Murl::Enum< EnumType >::GetEnumValueByName ( const String name,
Bool error 
) const
inline

Get the enumeration value for a given enumeration name.

Parameters
nameThe name string to look up.
errorThe error return value is set to true if the value is not found, or false if OK.
Returns
The enumeration value of the string or the default value if the string is not found.

◆ GetEnumValueByName() [3/6]

template<class EnumType>
EnumType Murl::Enum< EnumType >::GetEnumValueByName ( const String name) const
inline

Get the enumeration value for a given enumeration name.

Parameters
nameThe name string to look up.
Returns
The enumeration value of the string or the default value if the string is not found.

◆ GetEnumNameByValue() [4/6]

template<class EnumType>
const String& Murl::Enum< EnumType >::GetEnumNameByValue ( EnumType  value,
UInt32  hash,
Bool error,
Bool  clearError 
) const
inline

Get the enumeration name for a given enumeration value, using a precomputed hash value.

Parameters
valueThe enumeration value to look up.
hashThe precomputed hash value.
errorThe error return value is set to true if the value is not found.
clearErrorIf false, the error parameter is left in its given state if no error occurred.
Returns
The string of the enumeration value or an empty string if the value is not found.

◆ GetEnumNameByValue() [5/6]

template<class EnumType>
const String& Murl::Enum< EnumType >::GetEnumNameByValue ( EnumType  value,
UInt32  hash,
Bool error 
) const
inline

Get the enumeration name for a given enumeration value, using a precomputed hash value.

Parameters
valueThe enumeration value to look up.
hashThe precomputed hash value.
errorThe error return value is set to true if the value is not found, or false if OK.
Returns
The string of the enumeration value or an empty string if the value is not found.

◆ GetEnumNameByValue() [6/6]

template<class EnumType>
const String& Murl::Enum< EnumType >::GetEnumNameByValue ( EnumType  value,
UInt32  hash 
) const
inline

Get the enumeration name for a given enumeration value, using a precomputed hash value.

Parameters
valueThe enumeration value to look up.
hashThe precomputed hash value.
Returns
The string of the enumeration value or an empty string if the value is not found.

◆ GetEnumValueByName() [4/6]

template<class EnumType>
EnumType Murl::Enum< EnumType >::GetEnumValueByName ( const String name,
UInt32  hash,
Bool error,
Bool  clearError 
) const
inline

Get the enumeration value for a given enumeration name, using a precomputed hash value.

Parameters
nameThe name string to look up.
hashThe precomputed hash value.
errorThe error return value is set to true if the name is not found.
clearErrorIf false, the error parameter is left in its given state if no error occurred.
Returns
The enumeration value of the string or the default value if the string is not found.

◆ GetEnumValueByName() [5/6]

template<class EnumType>
EnumType Murl::Enum< EnumType >::GetEnumValueByName ( const String name,
UInt32  hash,
Bool error 
) const
inline

Get the enumeration value for a given enumeration name, using a precomputed hash value.

Parameters
nameThe name string to look up.
hashThe precomputed hash value.
errorThe error return value is set to true if the value is not found, or false if OK.
Returns
The enumeration value of the string or the default value if the string is not found.

◆ GetEnumValueByName() [6/6]

template<class EnumType>
EnumType Murl::Enum< EnumType >::GetEnumValueByName ( const String name,
UInt32  hash 
) const
inline

Get the enumeration value for a given enumeration name, using a precomputed hash value.

Parameters
nameThe name string to look up.
hashThe precomputed hash value.
Returns
The enumeration value of the string or the default value if the string is not found.

◆ GetItemsByName()

template<class EnumType>
const Map<String, UInt32>& Murl::Enum< EnumType >::GetItemsByName ( ) const
inline

Get the enumeration values by name map.

Returns
The enumeration values by name map.

◆ GetItemsByValue()

template<class EnumType>
const Map<UInt32, String>& Murl::Enum< EnumType >::GetItemsByValue ( ) const
inline

Get the names by enumeration value map.

Returns
The names by enumeration value map.

◆ operator const Enum< SInt32 > &()

template<class EnumType>
Murl::Enum< EnumType >::operator const Enum< SInt32 > & ( ) const
inline

Conversion operator.

Returns
This Enum instance with SInt32 specialization.

Member Data Documentation

◆ mItemsByName

◆ mItemsByValue

◆ mDefaultValue

template<class EnumType>
EnumType Murl::Enum< EnumType >::mDefaultValue
protected

◆ mName

template<class EnumType>
String Murl::Enum< EnumType >::mName
protected

The name of the enumerator.

Referenced by Murl::Enum< SInt32 >::GetName().


The documentation for this class was generated from the following file:
  • murl_enum.h


Copyright © 2011-2018 Spraylight GmbH.