mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
Config: Allow passing a DefaultState object to Set functions to delete keys.
This commit is contained in:
@ -8,7 +8,6 @@
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
#include "Common/Config/ConfigInfo.h"
|
||||
#include "Common/Config/Enums.h"
|
||||
@ -16,6 +15,12 @@
|
||||
|
||||
namespace Config
|
||||
{
|
||||
// Setting a key to an object of this type will delete the key.
|
||||
struct DefaultState
|
||||
{
|
||||
friend constexpr bool operator==(DefaultState, DefaultState) { return true; };
|
||||
};
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <typename T, std::enable_if_t<!std::is_enum<T>::value>* = nullptr>
|
||||
@ -116,12 +121,20 @@ public:
|
||||
return detail::TryParse<T>(*iter->second);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool Set(const Info<T>& config_info, DefaultState)
|
||||
{
|
||||
return DeleteKey(config_info.GetLocation());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool Set(const Info<T>& config_info, const std::common_type_t<T>& value)
|
||||
{
|
||||
return Set(config_info.GetLocation(), value);
|
||||
}
|
||||
|
||||
bool Set(const Location& location, DefaultState) { return DeleteKey(location); }
|
||||
|
||||
template <typename T>
|
||||
bool Set(const Location& location, const T& value)
|
||||
{
|
||||
|
Reference in New Issue
Block a user