Aurora Enumerations // "I forgot magic enum existed, and now I want to keep our STL-free basic implementation"
Go to file
2024-01-23 21:55:12 +00:00
Include [*] Update 2024: made the kEnumNameInvalids match kEnumNameEnumInvalids; and removed the consumer type 2024-01-23 21:55:12 +00:00
.gitignore [+] Initial Commit 2021-10-28 21:52:23 +01:00
Aurora.json [*] Update Aurora.json 2021-10-28 23:49:27 +01:00
LICENSE.txt Attach license 2021-10-28 22:58:52 +01:00
README.md Attach license 2021-10-28 22:58:52 +01:00

Aurora Enum

[TODO]

Example

Include

#define AUE_OUT_OF_ECOSYSTEM // Applications in the Aurora ecosystem do not need this line
#include <AuroraForEach.hpp>
#include <AuroraEnum.hpp>

Example

#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));
    });
}

Dependencies

License

Public Domain or Unlicense