AuroraEnum/README.md

53 lines
1.1 KiB
Markdown
Raw Normal View History

2021-10-28 20:35:48 +00:00
## Aurora Enum
[TODO]
## Example
2021-10-28 20:58:06 +00:00
### Include
```c++
#define AUE_OUT_OF_ECOSYSTEM // Applications in the Aurora ecosystem do not need this line
2021-10-28 21:05:09 +00:00
#include <AuroraForEach.hpp>
2021-10-28 20:58:06 +00:00
#include <AuroraEnum.hpp>
```
2021-10-28 20:35:48 +00:00
2021-10-28 20:58:06 +00:00
### Example
2021-10-28 20:35:48 +00:00
```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));
});
}
2021-10-28 21:04:02 +00:00
```
## Dependencies
* [AuroraForEach](https://git.reece.sx/AuroraSupport/AuroraForEach) [header only]
2021-10-28 21:58:52 +00:00
## License
Public Domain or Unlicense