openMSX
BooleanSetting.hh
Go to the documentation of this file.
1#ifndef BOOLEANSETTING_HH
2#define BOOLEANSETTING_HH
3
4#include "Setting.hh"
5
6namespace openmsx {
7
8class BooleanSetting final : public Setting
9{
10public:
11 BooleanSetting(CommandController& commandController,
12 std::string_view name, static_string_view description,
13 bool initialValue, SaveSetting save = SAVE);
14 [[nodiscard]] std::string_view getTypeString() const override;
15 void tabCompletion(std::vector<std::string>& tokens) const override;
16
17 [[nodiscard]] bool getBoolean() const noexcept {
19 }
20 void setBoolean(bool b) { setValue(TclObject(toString(b))); }
21
22private:
23 [[nodiscard]] static std::string_view toString(bool b) {
24 return b ? "true" : "false";
25 }
26};
27
28} // namespace openmsx
29
30#endif
std::string_view getTypeString() const override
Returns a string describing the setting type (integer, string, ..) Could be used in a GUI to pick an ...
BooleanSetting(CommandController &commandController, std::string_view name, static_string_view description, bool initialValue, SaveSetting save=SAVE)
bool getBoolean() const noexcept
void tabCompletion(std::vector< std::string > &tokens) const override
Complete a partly typed value.
Interpreter & getInterpreter() const
Definition: Setting.cc:148
const TclObject & getValue() const final
Gets the current value of this setting as a TclObject.
Definition: Setting.hh:142
void setValue(const TclObject &newValue) final
Change the value of this setting to the given value.
Definition: Setting.cc:82
bool getBoolean(Interpreter &interp) const
Definition: TclObject.cc:91
static_string_view
This file implemented 3 utility functions:
Definition: Autofire.cc:9