X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fucioption.h;fp=src%2Fucioption.h;h=b8622e51d124baee07a75040ffe82d258476e4bc;hp=d0d655cd9f8825023b5e148edfb684904efba42f;hb=87b483f99922c493d20b40d9dd16beeb9ee443c1;hpb=c2d42ea8339b49e52a116e488214a14fda09d413 diff --git a/src/ucioption.h b/src/ucioption.h index d0d655cd..b8622e51 100644 --- a/src/ucioption.h +++ b/src/ucioption.h @@ -25,41 +25,30 @@ #include #include +struct OptionsMap; + +/// UCIOption class implements an option as defined by UCI protocol class UCIOption { public: - UCIOption() {} // To be used in a std::map - UCIOption(const char* defaultValue); - UCIOption(bool defaultValue, std::string type = "check"); - UCIOption(int defaultValue, int minValue, int maxValue); + UCIOption() {} // Required by std::map::operator[] + UCIOption(const char* v); + UCIOption(bool v, std::string type = "check"); + UCIOption(int v, int min, int max); - void set_value(const std::string& v); template T value() const; + void operator=(const std::string& v); + void operator=(bool v) { *this = std::string(v ? "true" : "false"); } private: - friend struct OptionsMap; + friend std::ostream& operator<<(std::ostream&, const OptionsMap&); std::string defaultValue, currentValue, type; - int minValue, maxValue; + int min, max; size_t idx; }; -/// Custom comparator because UCI options should be case insensitive -struct CaseInsensitiveLess { - bool operator() (const std::string&, const std::string&) const; -}; - - -/// Our options container is actually a map with a customized c'tor -struct OptionsMap : public std::map { - OptionsMap(); - std::string print_all() const; -}; - -extern OptionsMap Options; - - -/// Option::value() definition and specializations +/// UCIOption::value() definition and specializations template T UCIOption::value() const { @@ -81,4 +70,19 @@ inline bool UCIOption::value() const { return currentValue == "true"; } + +/// Custom comparator because UCI options should be case insensitive +struct CaseInsensitiveLess { + bool operator() (const std::string&, const std::string&) const; +}; + + +/// Our options container is actually a map with a customized c'tor +struct OptionsMap : public std::map { + OptionsMap(); +}; + +extern std::ostream& operator<<(std::ostream&, const OptionsMap&); +extern OptionsMap Options; + #endif // !defined(UCIOPTION_H_INCLUDED)