Loading...
Searching...
No Matches
EnumKey.h
Go to the documentation of this file.
1// Copyright (c) 2025 Dave R. Smith. All rights reserved.
2// Malena Framework — Proprietary Software. See LICENSE for terms.
3
4//
5// EnumKey.h
6//
7
8#ifndef MALENA_ENUMKEY_H
9#define MALENA_ENUMKEY_H
10
11#pragma once
12
14#include <string>
15#include <typeinfo>
16#include <type_traits>
17
18namespace ml
19{
53 struct EnumKey
54 {
66 template<typename EnumType>
67 static std::string get(EnumType value)
68 {
69 static_assert(std::is_enum_v<EnumType>,
70 "[Malena] EnumKey::get — template parameter must be an enum type.");
71
72 return std::string(typeid(EnumType).name())
73 + "::"
74 + std::to_string(static_cast<int>(value));
75 }
76
86 template<typename EnumType>
87 static std::string typeKey()
88 {
89 static_assert(std::is_enum_v<EnumType>,
90 "[Malena] EnumKey::typeKey — template parameter must be an enum type.");
91
92 return std::string(typeid(EnumType).name());
93 }
94 };
95
96} // namespace ml
97
98#endif // MALENA_ENUMKEY_H
Definition Component.h:22
Utility for generating unique, stable string keys from enum values.
Definition EnumKey.h:54
static std::string typeKey()
Generate a unique string key for an enum type alone.
Definition EnumKey.h:87
static std::string get(EnumType value)
Generate a unique string key for an enum value.
Definition EnumKey.h:67