| 45 | |
| 46 | template <typename T> |
| 47 | T GetRegValue(LPCWSTR section, LPCWSTR entry, const T &default_value) { |
| 48 | if constexpr (std::is_enum_v<T>) |
| 49 | return enum_cast<T>(FTEnv.GetMainApp()->GetProfileIntW(section, entry, static_cast<int>(default_value))); |
| 50 | else if constexpr (std::is_integral_v<T>) |
| 51 | return static_cast<T>(FTEnv.GetMainApp()->GetProfileIntW(section, entry, static_cast<int>(default_value))); |
| 52 | else if constexpr (std::is_same_v<T, std::wstring>) { |
| 53 | CStringW v = FTEnv.GetMainApp()->GetProfileStringW(section, entry, default_value.data()); |
| 54 | return std::wstring {(LPCWSTR)v, static_cast<std::size_t>(v.GetLength())}; |
| 55 | } |
| 56 | else if constexpr (std::is_same_v<T, fs::path>) { |
| 57 | CStringW v = FTEnv.GetMainApp()->GetProfileStringW(section, entry, default_value.c_str()); |
| 58 | return fs::path {(LPCWSTR)v, (LPCWSTR)v + v.GetLength()}; |
| 59 | } |
| 60 | else |
| 61 | static_assert(!sizeof(T), "Unknown value type"); |
| 62 | } |
| 63 | |
| 64 | template <typename T> |
| 65 | void SetRegValue(LPCWSTR section, LPCWSTR entry, const T &val) { |
no test coverage detected