Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
stenzek
GitHub Repository: stenzek/duckstation
Path: blob/master/src/common/layered_settings_interface.h
4223 views
1
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <[email protected]>
2
// SPDX-License-Identifier: CC-BY-NC-ND-4.0
3
4
#pragma once
5
#include "settings_interface.h"
6
#include <array>
7
8
class LayeredSettingsInterface final : public SettingsInterface
9
{
10
public:
11
enum Layer : u32
12
{
13
LAYER_GAME,
14
LAYER_INPUT,
15
LAYER_BASE,
16
NUM_LAYERS
17
};
18
19
LayeredSettingsInterface();
20
~LayeredSettingsInterface() override;
21
22
SettingsInterface* GetLayer(Layer layer) const { return m_layers[layer]; }
23
void SetLayer(Layer layer, SettingsInterface* sif) { m_layers[layer] = sif; }
24
25
bool IsEmpty() override;
26
27
bool GetIntValue(const char* section, const char* key, s32* value) const override;
28
bool GetUIntValue(const char* section, const char* key, u32* value) const override;
29
bool GetFloatValue(const char* section, const char* key, float* value) const override;
30
bool GetDoubleValue(const char* section, const char* key, double* value) const override;
31
bool GetBoolValue(const char* section, const char* key, bool* value) const override;
32
bool GetStringValue(const char* section, const char* key, std::string* value) const override;
33
bool GetStringValue(const char* section, const char* key, SmallStringBase* value) const override;
34
35
void SetIntValue(const char* section, const char* key, s32 value) override;
36
void SetUIntValue(const char* section, const char* key, u32 value) override;
37
void SetFloatValue(const char* section, const char* key, float value) override;
38
void SetDoubleValue(const char* section, const char* key, double value) override;
39
void SetBoolValue(const char* section, const char* key, bool value) override;
40
void SetStringValue(const char* section, const char* key, const char* value) override;
41
bool ContainsValue(const char* section, const char* key) const override;
42
void DeleteValue(const char* section, const char* key) override;
43
void ClearSection(const char* section) override;
44
void RemoveSection(const char* section) override;
45
void RemoveEmptySections() override;
46
47
std::vector<std::string> GetStringList(const char* section, const char* key) const override;
48
void SetStringList(const char* section, const char* key, const std::vector<std::string>& items) override;
49
bool RemoveFromStringList(const char* section, const char* key, const char* item) override;
50
bool AddToStringList(const char* section, const char* key, const char* item) override;
51
52
std::vector<std::pair<std::string, std::string>> GetKeyValueList(const char* section) const override;
53
void SetKeyValueList(const char* section, const std::vector<std::pair<std::string, std::string>>& items) override;
54
55
// default parameter overloads
56
using SettingsInterface::GetBoolValue;
57
using SettingsInterface::GetDoubleValue;
58
using SettingsInterface::GetFloatValue;
59
using SettingsInterface::GetIntValue;
60
using SettingsInterface::GetStringValue;
61
using SettingsInterface::GetUIntValue;
62
63
private:
64
static constexpr Layer FIRST_LAYER = LAYER_GAME;
65
static constexpr Layer LAST_LAYER = LAYER_BASE;
66
67
std::array<SettingsInterface*, NUM_LAYERS> m_layers{};
68
};
69