OXYGENHUB
◆ main openmsx / src / settings / BooleanSetting.hh
810 B · C++ · last changed chore(): initial commit 1 month ago source blame history raw
1
#ifndef BOOLEANSETTING_HH
2
#define BOOLEANSETTING_HH
3
4
#include "Setting.hh"
5
6
namespace openmsx {
7
8
using namespace std::literals;
9
10
class BooleanSetting final : public Setting
11
{
12
public:
13
	BooleanSetting(CommandController& commandController,
14
	               std::string_view name, static_string_view description,
15
	               bool initialValue, Save save = Save::YES);
16
	[[nodiscard]] std::string_view getTypeString() const override;
17
	void tabCompletion(std::vector<std::string>& tokens) const override;
18
19
	[[nodiscard]] bool getBoolean() const noexcept {
20
		return getValue().getBoolean(getInterpreter());
21
	}
22
	void setBoolean(bool b) { setValue(TclObject(toString(b))); }
23
24
private:
25
	[[nodiscard]] static std::string_view toString(bool b) {
26
		 return b ? "true"sv : "false"sv;
27
	}
28
};
29
30
} // namespace openmsx
31
32
#endif