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, std::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
openmsx::Setting::getInterpreter
Interpreter & getInterpreter() const
Definition: Setting.cc:162
openmsx::CommandController
Definition: CommandController.hh:18
Setting.hh
openmsx::TclObject::getBoolean
bool getBoolean(Interpreter &interp) const
Definition: TclObject.cc:82
openmsx::Setting::setValue
void setValue(const TclObject &newValue) final
Change the value of this setting to the given value.
Definition: Setting.cc:89
openmsx::Setting
Definition: Setting.hh:120
openmsx::BooleanSetting::tabCompletion
void tabCompletion(std::vector< std::string > &tokens) const override
Complete a partly typed value.
Definition: BooleanSetting.cc:26
openmsx::Setting::getValue
const TclObject & getValue() const final
Gets the current value of this setting as a TclObject.
Definition: Setting.hh:135
openmsx::Setting::SaveSetting
SaveSetting
Definition: Setting.hh:125
openmsx::Setting::SAVE
@ SAVE
Definition: Setting.hh:126
openmsx::BooleanSetting
Definition: BooleanSetting.hh:9
openmsx::BooleanSetting::getTypeString
std::string_view getTypeString() const override
Returns a string describing the setting type (integer, string, ..) Could be used in a GUI to pick an ...
Definition: BooleanSetting.cc:21
openmsx::TclObject
Definition: TclObject.hh:22
openmsx::BooleanSetting::setBoolean
void setBoolean(bool b)
Definition: BooleanSetting.hh:20
openmsx
This file implemented 3 utility functions:
Definition: Autofire.cc:5
openmsx::BooleanSetting::getBoolean
bool getBoolean() const noexcept
Definition: BooleanSetting.hh:17
openmsx::BooleanSetting::BooleanSetting
BooleanSetting(CommandController &commandController, std::string_view name, std::string_view description, bool initialValue, SaveSetting save=SAVE)
Definition: BooleanSetting.cc:6