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
11namespace openmsx {
12
13class FileContext;
14class HotKey;
15class GlobalCommandController;
16class CommandController;
17
19{
20public:
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 [[nodiscard]] 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
37private:
38 CommandController& commandController;
39
40 struct SaveSettingsCommand final : Command {
41 explicit SaveSettingsCommand(CommandController& commandController);
42 void execute(std::span<const TclObject> tokens, TclObject& result) override;
43 [[nodiscard]] std::string help(std::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(std::span<const TclObject> tokens, TclObject& result) override;
50 [[nodiscard]] std::string help(std::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 = false;
59};
60
61} // namespace openmsx
62
63#endif
BaseSetting * setting
void saveSetting(std::string filename={})
void loadSetting(const FileContext &context, std::string_view filename)
SettingsManager & getSettingsManager()
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.
This file implemented 3 utility functions:
Definition Autofire.cc:9