Mercurial > minori
diff include/core/ini.h @ 221:53211cb1e7f5
library: add initial library stuff
nice
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Mon, 08 Jan 2024 13:21:08 -0500 |
parents | 7d3ad9529c4c |
children | 862d0d8619f6 |
line wrap: on
line diff
--- a/include/core/ini.h Mon Jan 08 11:56:09 2024 -0500 +++ b/include/core/ini.h Mon Jan 08 13:21:08 2024 -0500 @@ -13,22 +13,19 @@ /* very simple tutorial on how to give anyone who reads your code an aneurysm */ -template< class... > -using void_t = void; - template <typename T, typename = void> struct is_toutf8string_available : std::false_type {}; template<typename T> struct is_toutf8string_available<T, - void_t<decltype(Strings::ToUtf8String(std::declval<T>()))>> : std::true_type {}; + std::void_t<decltype(Strings::ToUtf8String(std::declval<T>()))>> : std::true_type {}; template <typename T, typename = void> struct is_translation_available : std::false_type {}; template<typename T> struct is_translation_available<T, - void_t<decltype(Translate::ToString(std::declval<T>()))>> : std::true_type {}; + std::void_t<decltype(Translate::ToString(std::declval<T>()))>> : std::true_type {}; template<typename T> T GetIniValue(const mINI::INIStructure& ini, const std::string& section, @@ -38,7 +35,7 @@ const std::string val = ini.get(section).get(value); - if constexpr (std::is_arithmetic<T>::value) { + if constexpr (std::is_integral<T>::value) { /* Integer? */ if constexpr (std::is_same<T, bool>::value) { /* Boolean? */ @@ -59,11 +56,11 @@ auto& ini_key = ini[section][key]; if constexpr (is_translation_available<T>::value) { + /* prioritize translation */ ini_key = Translate::ToString(value); } else if constexpr (std::is_same<T, std::string>::value) { + /* lmfao */ ini_key = value; - } else if constexpr (std::is_arithmetic<T>::value && !std::is_same<T, bool>::value) { - ini_key = std::to_string(value); } else if constexpr (is_toutf8string_available<T>::value) { ini_key = Strings::ToUtf8String(value); }