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:
parent
214891ffc6
commit
524227d21c
@ -193,6 +193,24 @@ namespace dxvk {
|
||||
result = sign * intval;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
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) {
|
||||
|
@ -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
|
||||
*
|
||||
@ -108,7 +120,26 @@ namespace dxvk {
|
||||
static bool parseOptionValue(
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user