mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-02 04:29:14 +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;
|
result = sign * intval;
|
||||||
return true;
|
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) {
|
Config Config::getAppConfig(const std::string& appName) {
|
||||||
|
@ -5,6 +5,18 @@
|
|||||||
|
|
||||||
namespace dxvk {
|
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
|
* \brief Config option set
|
||||||
*
|
*
|
||||||
@ -108,7 +120,26 @@ namespace dxvk {
|
|||||||
static bool parseOptionValue(
|
static bool parseOptionValue(
|
||||||
const std::string& value,
|
const std::string& value,
|
||||||
int32_t& result);
|
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…
x
Reference in New Issue
Block a user