diff --git a/Utilities/Config.cpp b/Utilities/Config.cpp index 381ee01079..bd0fe7a8b8 100644 --- a/Utilities/Config.cpp +++ b/Utilities/Config.cpp @@ -362,6 +362,27 @@ std::vector cfg::try_to_enum_list(decltype(&fmt_class_string:: return result; } +size_t cfg::try_to_enum_size(decltype(&fmt_class_string::format) func) +{ + size_t result = 0; + for (u64 i = 0;; i++) + { + std::string var; + func(var, i); + + std::string hex; + fmt_class_string::format(hex, i); + if (var == hex) + { + break; + } + + result++; + } + + return result; +} + void cfg::encode(YAML::Emitter& out, const cfg::_base& rhs) { switch (rhs.get_type()) diff --git a/Utilities/Config.h b/Utilities/Config.h index 35dcddc1a6..ca9af028a5 100644 --- a/Utilities/Config.h +++ b/Utilities/Config.h @@ -30,6 +30,9 @@ namespace cfg // Internal hack std::vector try_to_enum_list(decltype(&fmt_class_string::format) func); + // Internal hack + size_t try_to_enum_size(decltype(&fmt_class_string::format) func); + // Config tree entry type. enum class type : unsigned { @@ -312,6 +315,11 @@ namespace cfg { return try_to_enum_list(&fmt_class_string::format); } + + size_t size() const + { + return try_to_enum_size(&fmt_class_string::format); + } }; // Signed 32/64-bit integer entry with custom Min/Max range.