Enumeration string mapping template class. More...
#include "murl_enum.h"
Classes | |
struct | Item |
Definition of an Enum initialization item. More... | |
Public Types | |
using | ValueType = EnumType |
The template parameter value type. | |
Public Member Functions | |
Enum (const Item *items, const UInt32 numberOfElements) | |
Constructor taking an array of enum items. More... | |
Enum (const String &name, const Item *items, const UInt32 numberOfElements) | |
Constructor taking an enumeration name and an array of enum items. More... | |
Enum (const String &name, EnumContainer &container, const Item *items, const UInt32 numberOfElements) | |
Constructor taking an array of enum items and a container. More... | |
Enum (const Enum &other) | |
Copy constructor. More... | |
~Enum () | |
Destructor. | |
Enum & | operator= (const Enum &other) |
Assignment operator. More... | |
const String & | GetName () 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 String & | GetEnumNameByIndex (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 String & | GetEnumNameByValue (EnumType value, Bool &error, Bool clearError) const |
Get the enumeration name for a given enumeration value. More... | |
const String & | GetEnumNameByValue (EnumType value, Bool &error) const |
Get the enumeration name for a given enumeration value. More... | |
const String & | GetEnumNameByValue (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 String & | GetEnumNameByValue (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 String & | GetEnumNameByValue (EnumType value, UInt32 hash, Bool &error) const |
Get the enumeration name for a given enumeration value, using a precomputed hash value. More... | |
const String & | GetEnumNameByValue (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, UInt32 > | mItemsByName |
The enumeration values by name map. | |
Map< UInt32, String > | mItemsByValue |
The names by enumeration value map. | |
EnumType | mDefaultValue |
The default enumeration value. | |
String | mName |
The name of the enumerator. | |
EnumContainer * | mEnumContainer |
The optional container. | |
Detailed Description
template<class EnumType>
class Murl::Enum< EnumType >
Enumeration string mapping template class.
Constructor & Destructor Documentation
◆ Enum() [1/4]
|
inline |
Constructor taking an array of enum items.
- Parameters
-
items Pointer to an array of initialization items. If the item's mName has a null pointer, the mValue is the default value. numberOfElements The number of elements in the array. The macro NUMBER_OF_ARRAY_ELEMENTS can be used to determine the number.
◆ Enum() [2/4]
|
inline |
Constructor taking an enumeration name and an array of enum items.
- Parameters
-
name The enumeration's name. items Pointer to an array of initialization items. If the item's mName has a null pointer, the mValue is the default value. numberOfElements The number of elements in the array. The macro NUMBER_OF_ARRAY_ELEMENTS can be used to determine the number.
◆ Enum() [3/4]
|
inline |
Constructor taking an array of enum items and a container.
- Parameters
-
name The enumeration's name. container The container to add this enumeration to. items Pointer to an array of initialization items. If the item's mName has a null pointer, the mValue is the default value. numberOfElements The number of elements in the array. The macro NUMBER_OF_ARRAY_ELEMENTS can be used to determine the number.
References Murl::EnumContainer::Add().
◆ Enum() [4/4]
|
inline |
Copy constructor.
- Parameters
-
other The enumeration to copy.
Member Function Documentation
◆ operator=()
|
inline |
Assignment operator.
- Parameters
-
other The enumeration to assign.
- Returns
- The object itself.
References Murl::Enum< EnumType >::mDefaultValue, Murl::Enum< EnumType >::mEnumContainer, Murl::Enum< EnumType >::mItemsByName, Murl::Enum< EnumType >::mItemsByValue, Murl::Enum< EnumType >::mName, and Murl::EnumContainer::Remove().
◆ GetName()
|
inline |
Get the name of the enumerator.
- Returns
- The name of the enumerator.
References Murl::Enum< EnumType >::mName.
◆ GetDefaultValue()
|
inline |
Get the default enumeration value.
- Returns
- The default value.
References Murl::Enum< EnumType >::mDefaultValue.
◆ GetCount()
|
inline |
Get the total number of enumeration entries.
- Returns
- The number of entries.
References Murl::Enum< EnumType >::mItemsByName.
◆ IsEnumValueAvailable()
|
inline |
Check if an enumeration value is available.
- Parameters
-
value The enumeration value to check.
- Returns
- true if the enumeration value is available.
References Murl::Enum< EnumType >::mItemsByValue.
◆ IsEnumNameAvailable()
|
inline |
Check if an enumeration name is available.
- Parameters
-
name The enumeration name to check.
- Returns
- true if the enumeration name is available.
References Murl::Enum< EnumType >::mItemsByName.
◆ GetEnumIndexByValue() [1/2]
|
inline |
Get the zero-based index of an enumeration value.
- Parameters
-
value The enumeration value to check.
- Returns
- The index in the range from 0 to GetCount()-1, or -1 if not found.
References Murl::Enum< EnumType >::mItemsByValue.
◆ GetEnumIndexByValue() [2/2]
|
inline |
Get the zero-based index of an enumeration value.
- Parameters
-
value The enumeration value to check. hash The precomputed hash value.
- Returns
- The index in the range from 0 to GetCount()-1, or -1 if not found.
References Murl::Enum< EnumType >::mItemsByValue.
◆ GetEnumIndexByName() [1/2]
|
inline |
Get the zero-based index of an enumeration name.
- Parameters
-
name The enumeration name to check.
- Returns
- The index in the range from 0 to GetCount()-1, or -1 if not found.
References Murl::Enum< EnumType >::mItemsByName.
◆ GetEnumIndexByName() [2/2]
|
inline |
Get the zero-based index of an enumeration name.
- Parameters
-
name The enumeration name to check. hash The precomputed hash value.
- Returns
- The index in the range from 0 to GetCount()-1, or -1 if not found.
References Murl::Enum< EnumType >::mItemsByName.
◆ GetEnumNameByIndex()
|
inline |
Get the enumeration name at a given index.
- Parameters
-
index The 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.
References Murl::Enum< EnumType >::mItemsByValue, and Murl::Util::StaticEmptyString().
◆ GetEnumValueByIndex()
|
inline |
Get the enumeration value at a given index.
- Parameters
-
index The 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.
References Murl::Enum< EnumType >::mDefaultValue, and Murl::Enum< EnumType >::mItemsByName.
◆ GetEnumNameByValue() [1/6]
|
inline |
Get the enumeration name for a given enumeration value.
- Parameters
-
value The enumeration value to look up. error The error return value is set to true if the value is not found. clearError If 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.
References Murl::Enum< EnumType >::mItemsByValue, and Murl::Util::StaticEmptyString().
Referenced by Murl::Enum< EnumType >::GetEnumNameByValue().
◆ GetEnumNameByValue() [2/6]
|
inline |
Get the enumeration name for a given enumeration value.
- Parameters
-
value The enumeration value to look up. error The 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.
References Murl::Enum< EnumType >::GetEnumNameByValue().
◆ GetEnumNameByValue() [3/6]
|
inline |
Get the enumeration name for a given enumeration value.
- Parameters
-
value The enumeration value to look up.
- Returns
- The string of the enumeration value or an empty string if the value is not found.
References Murl::Enum< EnumType >::GetEnumNameByValue().
◆ GetEnumValueByName() [1/6]
|
inline |
Get the enumeration value for a given enumeration name.
- Parameters
-
name The name string to look up. error The error return value is set to true if the name is not found. clearError If 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.
References Murl::Enum< EnumType >::mDefaultValue, and Murl::Enum< EnumType >::mItemsByName.
Referenced by Murl::IAttributes::GetEnumBitsToSetByIndex(), Murl::IAttributes::GetEnumValueByIndex(), Murl::Enum< EnumType >::GetEnumValueByName(), and Murl::IAttributes::GetEnumValuesByIndex().
◆ GetEnumValueByName() [2/6]
|
inline |
Get the enumeration value for a given enumeration name.
- Parameters
-
name The name string to look up. error The 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.
References Murl::Enum< EnumType >::GetEnumValueByName().
◆ GetEnumValueByName() [3/6]
|
inline |
Get the enumeration value for a given enumeration name.
- Parameters
-
name The name string to look up.
- Returns
- The enumeration value of the string or the default value if the string is not found.
References Murl::Enum< EnumType >::GetEnumValueByName().
◆ GetEnumNameByValue() [4/6]
|
inline |
Get the enumeration name for a given enumeration value, using a precomputed hash value.
- Parameters
-
value The enumeration value to look up. hash The precomputed hash value. error The error return value is set to true if the value is not found. clearError If 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.
References Murl::Enum< EnumType >::mItemsByValue, and Murl::Util::StaticEmptyString().
◆ GetEnumNameByValue() [5/6]
|
inline |
Get the enumeration name for a given enumeration value, using a precomputed hash value.
- Parameters
-
value The enumeration value to look up. hash The precomputed hash value. error The 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.
References Murl::Enum< EnumType >::GetEnumNameByValue().
◆ GetEnumNameByValue() [6/6]
|
inline |
Get the enumeration name for a given enumeration value, using a precomputed hash value.
- Parameters
-
value The enumeration value to look up. hash The precomputed hash value.
- Returns
- The string of the enumeration value or an empty string if the value is not found.
References Murl::Enum< EnumType >::GetEnumNameByValue().
◆ GetEnumValueByName() [4/6]
|
inline |
Get the enumeration value for a given enumeration name, using a precomputed hash value.
- Parameters
-
name The name string to look up. hash The precomputed hash value. error The error return value is set to true if the name is not found. clearError If 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.
References Murl::Enum< EnumType >::mDefaultValue, and Murl::Enum< EnumType >::mItemsByName.
◆ GetEnumValueByName() [5/6]
|
inline |
Get the enumeration value for a given enumeration name, using a precomputed hash value.
- Parameters
-
name The name string to look up. hash The precomputed hash value. error The 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.
References Murl::Enum< EnumType >::GetEnumValueByName().
◆ GetEnumValueByName() [6/6]
|
inline |
Get the enumeration value for a given enumeration name, using a precomputed hash value.
- Parameters
-
name The name string to look up. hash The precomputed hash value.
- Returns
- The enumeration value of the string or the default value if the string is not found.
References Murl::Enum< EnumType >::GetEnumValueByName().
◆ GetItemsByName()
|
inline |
Get the enumeration values by name map.
- Returns
- The enumeration values by name map.
References Murl::Enum< EnumType >::mItemsByName.
◆ GetItemsByValue()
|
inline |
Get the names by enumeration value map.
- Returns
- The names by enumeration value map.
References Murl::Enum< EnumType >::mItemsByValue.
◆ operator const Enum< SInt32 > &()
|
inline |
Conversion operator.
- Returns
- This Enum instance with SInt32 specialization.
The documentation for this class was generated from the following file:
- murl_enum.h