-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathucioptions.hpp
More file actions
67 lines (54 loc) · 2.23 KB
/
ucioptions.hpp
File metadata and controls
67 lines (54 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#pragma once
#include <charconv>
#include <functional>
#include <string>
#include <unordered_map>
#include <variant>
#include <vector>
namespace UCIOptions {
struct Option {
enum Type {
CHECK,
SPIN,
COMBO,
BUTTON,
STRING
} type;
std::string default_str;
std::vector<std::string> vars; // for COMBO
int min = 0, max = 0;
std::variant<int, std::string> value;
// Optional callback when the option is set
std::function<void(const Option&)> on_change;
Option() = default;
Option(Type t, int def, int min_ = 0, int max_ = 0, std::function<void(const Option&)> cb = {});
Option(Type t, const std::string& def, std::function<void(const Option&)> cb = {});
Option(Type t,
const std::string& def,
const std::vector<std::string>& _options,
std::function<void(const Option&)> cb = {});
};
// Declare the global options map
extern std::unordered_map<std::string, Option> options;
// Adders with optional callback support
void addSpin(const std::string& name,
int defaultValue,
int min,
int max,
std::function<void(const Option&)> cb = {});
void addCheck(const std::string& name,
bool defaultValue,
std::function<void(const Option&)> cb = {});
void addString(const std::string& name,
const std::string& defaultValue,
std::function<void(const Option&)> cb = {});
void addCombo(const std::string& name,
const std::string& defaultValue,
const std::vector<std::string>& vars,
std::function<void(const Option&)> cb = {});
void addButton(const std::string& name, std::function<void(const Option&)> cb = {});
void setOption(const std::string& name, const std::string& val);
int getInt(const std::string& name);
std::string getString(const std::string& name);
void printOptions();
} // namespace UCIOptions