1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-02 10:24:12 +01:00

[util] Add tristate config option type

This commit is contained in:
Philip Rebohle 2019-01-08 20:57:38 +01:00
parent 214891ffc6
commit 524227d21c
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 49 additions and 0 deletions

View File

@ -195,6 +195,24 @@ namespace dxvk {
}
bool Config::parseOptionValue(
const std::string& value,
Tristate& result) {
if (value == "True") {
result = Tristate::True;
return true;
} else if (value == "False") {
result = Tristate::False;
return true;
} else if (value == "Auto") {
result = Tristate::Auto;
return true;
} else {
return false;
}
}
Config Config::getAppConfig(const std::string& appName) {
auto appConfig = g_appDefaults.find(appName);
if (appConfig != g_appDefaults.end()) {

View File

@ -5,6 +5,18 @@
namespace dxvk {
/**
* \brief Tri-state
*
* Used to conditionally override
* booleans if desired.
*/
enum class Tristate : int32_t {
Auto = -1,
False = 0,
True = 1,
};
/**
* \brief Config option set
*
@ -109,6 +121,25 @@ namespace dxvk {
const std::string& value,
int32_t& result);
static bool parseOptionValue(
const std::string& value,
Tristate& result);
};
/**
* \brief Applies tristate option
*
* Overrides the given value if \c state is
* \c True or \c False, and leaves it intact
* otherwise.
* \param [out] option The value to override
* \param [in] state Tristate to apply
*/
inline void applyTristate(bool& option, Tristate state) {
option &= state != Tristate::False;
option |= state == Tristate::True;
}
}