openMSX
SettingsConfig.hh
Go to the documentation of this file.
1 #ifndef SETTINGSCONFIG_HH
2 #define SETTINGSCONFIG_HH
3 
4 #include "SettingsManager.hh"
5 #include "Command.hh"
6 #include "hash_map.hh"
7 #include "xxhash.hh"
8 #include <string>
9 #include <string_view>
10 
11 namespace openmsx {
12 
13 class FileContext;
14 class HotKey;
15 class GlobalCommandController;
16 class CommandController;
17 
19 {
20 public:
21  SettingsConfig(GlobalCommandController& globalCommandController,
22  HotKey& hotKey);
24 
25  void loadSetting(const FileContext& context, std::string_view filename);
26  void saveSetting(std::string filename = {});
27  void setSaveSettings(bool save) { mustSaveSettings = save; }
28  void setSaveFilename(const FileContext& context, std::string_view filename);
29 
30  [[nodiscard]] SettingsManager& getSettingsManager() { return settingsManager; }
31 
32  // manipulate info that would be stored in settings.xml
33  const std::string* getValueForSetting(std::string_view setting) const;
34  void setValueForSetting(std::string_view setting, std::string_view value);
35  void removeValueForSetting(std::string_view setting);
36 
37 private:
38  CommandController& commandController;
39 
40  struct SaveSettingsCommand final : Command {
41  explicit SaveSettingsCommand(CommandController& commandController);
42  void execute(span<const TclObject> tokens, TclObject& result) override;
43  [[nodiscard]] std::string help(span<const TclObject> tokens) const override;
44  void tabCompletion(std::vector<std::string>& tokens) const override;
45  } saveSettingsCommand;
46 
47  struct LoadSettingsCommand final : Command {
48  explicit LoadSettingsCommand(CommandController& commandController);
49  void execute(span<const TclObject> tokens, TclObject& result) override;
50  [[nodiscard]] std::string help(span<const TclObject> tokens) const override;
51  void tabCompletion(std::vector<std::string>& tokens) const override;
52  } loadSettingsCommand;
53 
54  SettingsManager settingsManager;
56  HotKey& hotKey;
57  std::string saveName;
58  bool mustSaveSettings;
59 };
60 
61 } // namespace openmsx
62 
63 #endif
BaseSetting * setting
Definition: Interpreter.cc:27
SettingsConfig(GlobalCommandController &globalCommandController, HotKey &hotKey)
SettingsManager & getSettingsManager()
void saveSetting(std::string filename={})
void loadSetting(const FileContext &context, std::string_view filename)
void setSaveFilename(const FileContext &context, std::string_view filename)
void removeValueForSetting(std::string_view setting)
void setValueForSetting(std::string_view setting, std::string_view value)
const std::string * getValueForSetting(std::string_view setting) const
void setSaveSettings(bool save)
Manages all settings.
Definition: span.hh:126
std::optional< Context > context
Definition: GLContext.cc:9
This file implemented 3 utility functions:
Definition: Autofire.cc:9
constexpr const char *const filename