openMSX
BooleanSetting.hh
Go to the documentation of this file.
1 #ifndef BOOLEANSETTING_HH
2 #define BOOLEANSETTING_HH
3 
4 #include "Setting.hh"
5 
6 namespace openmsx {
7 
8 class BooleanSetting final : public Setting
9 {
10 public:
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 
22 private:
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.
const TclObject & getValue() const final
Gets the current value of this setting as a TclObject.
Definition: Setting.hh:142
Interpreter & getInterpreter() const
Definition: Setting.cc:162
void setValue(const TclObject &newValue) final
Change the value of this setting to the given value.
Definition: Setting.cc:89
bool getBoolean(Interpreter &interp) const
Definition: TclObject.cc:91
static_string_view
This file implemented 3 utility functions:
Definition: Autofire.cc:5