mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-23 18:46:59 +08:00
Store "true" and "false" in bool options
UCI protocol uses "true" and "false" for check and button types, so store that values instead of "1" and "0", this simplifies a bit the code. Also a bit strictier option's type checking in debug mode. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
@@ -27,8 +27,8 @@
|
||||
|
||||
class Option {
|
||||
public:
|
||||
Option(); // To allow insertion in a std::map
|
||||
Option(const char* defaultValue, std::string type = "string");
|
||||
Option() {} // To allow insertion in a std::map
|
||||
Option(const char* defaultValue);
|
||||
Option(bool defaultValue, std::string type = "check");
|
||||
Option(int defaultValue, int minValue, int maxValue);
|
||||
|
||||
@@ -47,17 +47,24 @@ private:
|
||||
template<typename T>
|
||||
inline T Option::value() const {
|
||||
|
||||
assert(type != "UNDEFINED");
|
||||
assert(type == "spin");
|
||||
return T(atoi(currentValue.c_str()));
|
||||
}
|
||||
|
||||
template<>
|
||||
inline std::string Option::value<std::string>() const {
|
||||
|
||||
assert(type != "UNDEFINED");
|
||||
assert(type == "string");
|
||||
return currentValue;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline bool Option::value<bool>() const {
|
||||
|
||||
assert(type == "check" || type == "button");
|
||||
return currentValue == "true";
|
||||
}
|
||||
|
||||
typedef std::map<std::string, Option> OptionsMap;
|
||||
|
||||
extern OptionsMap Options;
|
||||
|
||||
Reference in New Issue
Block a user