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  string_ref name, string_ref description,
13  bool initialValue, SaveSetting save = SAVE);
14  string_ref getTypeString() const override;
15  void tabCompletion(std::vector<std::string>& tokens) const override;
16 
17  bool getBoolean() const { return getValue().getBoolean(getInterpreter()); }
18  void setBoolean(bool b) { setValue(TclObject(toString(b))); }
19 
20 private:
21  static string_ref toString(bool b) { return b ? "true" : "false"; }
22 };
23 
24 } // namespace openmsx
25 
26 #endif
BooleanSetting(CommandController &commandController, string_ref name, string_ref description, bool initialValue, SaveSetting save=SAVE)
string_ref getTypeString() const override
Returns a string describing the setting type (integer, string, ..) Could be used in a GUI to pick an ...
This class implements a subset of the proposal for std::string_ref (proposed for the next c++ standar...
Definition: string_ref.hh:18
const TclObject & getValue() const final override
Gets the current value of this setting as a TclObject.
Definition: Setting.hh:133
void tabCompletion(std::vector< std::string > &tokens) const override
Complete a partly typed value.
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
bool getBoolean(Interpreter &interp) const
Definition: TclObject.cc:119
void setValue(const TclObject &value) final override
Change the value of this setting to the given value.
Definition: Setting.cc:89
Interpreter & getInterpreter() const
Definition: Setting.cc:162