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
7#include "hash_map.hh"
8#include "xxhash.hh"
9
10#include <string>
11#include <string_view>
12
13namespace openmsx {
14
15class FileContext;
16class HotKey;
17class GlobalCommandController;
18class CommandController;
19class Shortcuts;
20
22{
23public:
24 SettingsConfig(GlobalCommandController& globalCommandController,
25 HotKey& hotKey, Shortcuts& shortcuts);
27
28 void loadSetting(const FileContext& context, std::string_view filename);
29 void saveSetting(std::string filename = {});
30 void setSaveSettings(bool save) { mustSaveSettings = save; }
31 void setSaveFilename(const FileContext& context, std::string_view filename);
32
33 [[nodiscard]] SettingsManager& getSettingsManager() { return settingsManager; }
34
35 // manipulate info that would be stored in settings.xml
36 [[nodiscard]] const std::string* getValueForSetting(std::string_view setting) const;
37 void setValueForSetting(std::string_view setting, std::string_view value);
38 void removeValueForSetting(std::string_view setting);
39
40private:
41 CommandController& commandController;
42
43 struct SaveSettingsCommand final : Command {
44 explicit SaveSettingsCommand(CommandController& commandController);
45 void execute(std::span<const TclObject> tokens, TclObject& result) override;
46 [[nodiscard]] std::string help(std::span<const TclObject> tokens) const override;
47 void tabCompletion(std::vector<std::string>& tokens) const override;
48 } saveSettingsCommand;
49
50 struct LoadSettingsCommand final : Command {
51 explicit LoadSettingsCommand(CommandController& commandController);
52 void execute(std::span<const TclObject> tokens, TclObject& result) override;
53 [[nodiscard]] std::string help(std::span<const TclObject> tokens) const override;
54 void tabCompletion(std::vector<std::string>& tokens) const override;
55 } loadSettingsCommand;
56
57 SettingsManager settingsManager;
59 HotKey& hotKey;
60 Shortcuts& shortcuts;
61 std::string saveName;
62 bool mustSaveSettings = false;
63};
64
65} // namespace openmsx
66
67#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:11