40 lines
794 B
Markdown
40 lines
794 B
Markdown
|
## Aurora Enum
|
||
|
|
||
|
[TODO]
|
||
|
|
||
|
## Example
|
||
|
|
||
|
```c++
|
||
|
#define AUE_DEFINE(name, enumerations)
|
||
|
|
||
|
AUE_DEFINE(EMyTestEnum, (
|
||
|
eValueA,
|
||
|
eValueB,
|
||
|
eValueC,
|
||
|
eValueD
|
||
|
));
|
||
|
|
||
|
static void TestAUE()
|
||
|
{
|
||
|
EMyTestEnum referenceValue = EMyTestEnum::eValueB;
|
||
|
|
||
|
// Convert the index to a string safely O(1)
|
||
|
const AuString &string = EMyTestEnumToString(referenceValue);
|
||
|
|
||
|
// Lookup O(n)
|
||
|
EMyTestEnum backAgain = EMyTestEnumFromString(string);
|
||
|
|
||
|
// Lookup using a hash table
|
||
|
EMyTestEnum fromHashTable = EMyTestEnumFromHashString(string);
|
||
|
|
||
|
// Assert
|
||
|
SysAssert(backAgain == referenceValue);
|
||
|
SysAssert(fromHashTable == referenceValue);
|
||
|
|
||
|
// And iteration for fun
|
||
|
EMyTestEnumForEach([](EMyTestEnum e)
|
||
|
{
|
||
|
LogDbg(EMyTestEnumToString(e));
|
||
|
});
|
||
|
}
|
||
|
```
|