Sugar
[*] enum values 'eEnumInvalid' and 'eEnumCount' are reserved. rationale -> it's easy to work around, now we don't have to switch between enum 'k' and 'e' conventions
This commit is contained in:
parent
0fcca45387
commit
17ac98ef4f
@ -78,7 +78,7 @@
|
||||
// API
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define AUE_DEFINE(name, vals) enum class name { AU_FOR_EACH(AUE_EMIT_ARRAY, AUE_STRIP_BRACKETS(vals)) kEnumCount }; \
|
||||
#define AUE_DEFINE(name, vals) enum class name { AU_FOR_EACH(AUE_EMIT_ARRAY, AUE_STRIP_BRACKETS(vals)) kEnumCount, kEnumInvalid = -1, eEnumInvalid = -1, eEnumCount = kEnumCount }; \
|
||||
static inline const AuString k ## name ## ToString[static_cast<AuUInt>(name::kEnumCount)] = { AU_FOR_EACH(AUE_EMIT_A, AUE_STRIP_BRACKETS(vals)) }; \
|
||||
static inline const name k ## name ## Values[static_cast<AuUInt>(name::kEnumCount)] = { AU_FOR_EACH_THAT(AUE_EMIT_D, name, AUE_STRIP_BRACKETS(vals)) }; \
|
||||
inline const AuHashMap<AuString, name> k ## name ## FromString = { AU_FOR_EACH_THAT(AUE_EMIT_PAIRNAME, name, AUE_STRIP_BRACKETS(vals)) {"kEnumCount", name::kEnumCount} }; \
|
||||
@ -100,7 +100,7 @@
|
||||
|
||||
#if defined(AUE_NOCPPSTL)
|
||||
#undef AUE_DEFINE
|
||||
#define AUE_DEFINE(name, vals) enum class name { AU_FOR_EACH(AUE_EMIT_ARRAY, AUE_STRIP_BRACKETS(vals)) kEnumCount }; \
|
||||
#define AUE_DEFINE(name, vals) enum class name { AU_FOR_EACH(AUE_EMIT_ARRAY, AUE_STRIP_BRACKETS(vals)) kEnumCount, kEnumInvalid = -1, eEnumInvalid = -1, eEnumCount = kEnumCount }; \
|
||||
static inline const char * k ## name ## ToString[static_cast<AuUInt>(name::kEnumCount)] = { AU_FOR_EACH(AUE_EMIT_A, AUE_STRIP_BRACKETS(vals)) }; \
|
||||
static inline const name k ## name ## Values[static_cast<AuUInt>(name::kEnumCount)] = { AU_FOR_EACH_THAT(AUE_EMIT_D, name, AUE_STRIP_BRACKETS(vals)) }; \
|
||||
static inline const char * name ## ToString(name val) { static const char * invalid = "kEnumCount"; if (static_cast<AuUInt>(val) >= static_cast<AuUInt>(name::kEnumCount)) return invalid; return k ## name ## ToString[static_cast<AuUInt>(val)]; } \
|
||||
|
Loading…
Reference in New Issue
Block a user