diff options
Diffstat (limited to 'src/common/settings_enums.h')
| -rw-r--r-- | src/common/settings_enums.h | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/common/settings_enums.h b/src/common/settings_enums.h index a1a29ebf6..e7cb59ea5 100644 --- a/src/common/settings_enums.h +++ b/src/common/settings_enums.h | |||
| @@ -12,8 +12,8 @@ namespace Settings { | |||
| 12 | 12 | ||
| 13 | template <typename T> | 13 | template <typename T> |
| 14 | struct EnumMetadata { | 14 | struct EnumMetadata { |
| 15 | static constexpr std::vector<std::pair<std::string, T>> Canonicalizations(); | 15 | static std::vector<std::pair<std::string, T>> Canonicalizations(); |
| 16 | static constexpr u32 Index(); | 16 | static u32 Index(); |
| 17 | }; | 17 | }; |
| 18 | 18 | ||
| 19 | #define PAIR_45(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_46(N, __VA_ARGS__)) | 19 | #define PAIR_45(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_46(N, __VA_ARGS__)) |
| @@ -66,11 +66,11 @@ struct EnumMetadata { | |||
| 66 | #define ENUM(NAME, ...) \ | 66 | #define ENUM(NAME, ...) \ |
| 67 | enum class NAME : u32 { __VA_ARGS__ }; \ | 67 | enum class NAME : u32 { __VA_ARGS__ }; \ |
| 68 | template <> \ | 68 | template <> \ |
| 69 | constexpr std::vector<std::pair<std::string, NAME>> EnumMetadata<NAME>::Canonicalizations() { \ | 69 | inline std::vector<std::pair<std::string, NAME>> EnumMetadata<NAME>::Canonicalizations() { \ |
| 70 | return {PAIR(NAME, __VA_ARGS__)}; \ | 70 | return {PAIR(NAME, __VA_ARGS__)}; \ |
| 71 | } \ | 71 | } \ |
| 72 | template <> \ | 72 | template <> \ |
| 73 | constexpr u32 EnumMetadata<NAME>::Index() { \ | 73 | inline u32 EnumMetadata<NAME>::Index() { \ |
| 74 | return __COUNTER__; \ | 74 | return __COUNTER__; \ |
| 75 | } | 75 | } |
| 76 | 76 | ||
| @@ -85,7 +85,7 @@ enum class AudioEngine : u32 { | |||
| 85 | }; | 85 | }; |
| 86 | 86 | ||
| 87 | template <> | 87 | template <> |
| 88 | constexpr std::vector<std::pair<std::string, AudioEngine>> | 88 | inline std::vector<std::pair<std::string, AudioEngine>> |
| 89 | EnumMetadata<AudioEngine>::Canonicalizations() { | 89 | EnumMetadata<AudioEngine>::Canonicalizations() { |
| 90 | return { | 90 | return { |
| 91 | {"auto", AudioEngine::Auto}, | 91 | {"auto", AudioEngine::Auto}, |
| @@ -96,7 +96,7 @@ EnumMetadata<AudioEngine>::Canonicalizations() { | |||
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | template <> | 98 | template <> |
| 99 | constexpr u32 EnumMetadata<AudioEngine>::Index() { | 99 | inline u32 EnumMetadata<AudioEngine>::Index() { |
| 100 | // This is just a sufficiently large number that is more than the number of other enums declared | 100 | // This is just a sufficiently large number that is more than the number of other enums declared |
| 101 | // here | 101 | // here |
| 102 | return 100; | 102 | return 100; |
| @@ -147,7 +147,7 @@ ENUM(AntiAliasing, None, Fxaa, Smaa, MaxEnum); | |||
| 147 | ENUM(AspectRatio, R16_9, R4_3, R21_9, R16_10, Stretch); | 147 | ENUM(AspectRatio, R16_9, R4_3, R21_9, R16_10, Stretch); |
| 148 | 148 | ||
| 149 | template <typename Type> | 149 | template <typename Type> |
| 150 | constexpr std::string CanonicalizeEnum(Type id) { | 150 | inline std::string CanonicalizeEnum(Type id) { |
| 151 | const auto group = EnumMetadata<Type>::Canonicalizations(); | 151 | const auto group = EnumMetadata<Type>::Canonicalizations(); |
| 152 | for (auto& [name, value] : group) { | 152 | for (auto& [name, value] : group) { |
| 153 | if (value == id) { | 153 | if (value == id) { |
| @@ -158,7 +158,7 @@ constexpr std::string CanonicalizeEnum(Type id) { | |||
| 158 | } | 158 | } |
| 159 | 159 | ||
| 160 | template <typename Type> | 160 | template <typename Type> |
| 161 | constexpr Type ToEnum(const std::string& canonicalization) { | 161 | inline Type ToEnum(const std::string& canonicalization) { |
| 162 | const auto group = EnumMetadata<Type>::Canonicalizations(); | 162 | const auto group = EnumMetadata<Type>::Canonicalizations(); |
| 163 | for (auto& [name, value] : group) { | 163 | for (auto& [name, value] : group) { |
| 164 | if (name == canonicalization) { | 164 | if (name == canonicalization) { |