Utility for generating unique, stable string keys from enum values. More...
#include <EnumKey.h>
Static Public Member Functions | |
| template<typename EnumType> | |
| static std::string | get (EnumType value) |
| Generate a unique string key for an enum value. | |
| template<typename EnumType> | |
| static std::string | typeKey () |
| Generate a unique string key for an enum type alone. | |
Utility for generating unique, stable string keys from enum values.
EnumKey converts any scoped or unscoped enum value into a std::string key by combining the enum type's mangled name with the enum's integer value. The resulting key is:
typeid().name() strings; different values produce different integers. No collision is possible."N2ml5EventE::0" are debuggable.Keys are std::string — map lookups are slightly slower than size_t but collision-free and correct at any scale. If Malena grows to a scale where string lookup cost matters, switch to a hash-combine approach (e.g. boost::hash_combine) and benchmark.
typeid().name() is implementation-defined. Do not persist or serialize EnumKey values.
|
inlinestatic |
Generate a unique string key for an enum value.
Combines typeid(EnumType).name() with the integer value of value via "::". Guaranteed unique per (type, value) pair.
| EnumType | Any enum type (scoped or unscoped). Enforced at compile time via std::is_enum_v. |
| value | The enum value to convert to a key. |
std::string key for this (type, value) pair.
|
inlinestatic |