Skip to content

Commit 5bd747b

Browse files
committed
SettingsInterface: Make strings the only virtual type
Others can be resolved by the base class.
1 parent 3d1f479 commit 5bd747b

19 files changed

+348
-470
lines changed

src/common/layered_settings_interface.cpp

Lines changed: 4 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -14,132 +14,23 @@ bool LayeredSettingsInterface::IsEmpty()
1414
return false;
1515
}
1616

17-
bool LayeredSettingsInterface::GetIntValue(const char* section, const char* key, s32* value) const
17+
bool LayeredSettingsInterface::LookupValue(const char* section, const char* key, std::string_view* value) const
1818
{
1919
for (u32 layer = FIRST_LAYER; layer <= LAST_LAYER; layer++)
2020
{
2121
if (SettingsInterface* sif = m_layers[layer]; sif != nullptr)
2222
{
23-
if (sif->GetIntValue(section, key, value))
23+
if (sif->LookupValue(section, key, value))
2424
return true;
2525
}
2626
}
2727

2828
return false;
2929
}
3030

31-
bool LayeredSettingsInterface::GetUIntValue(const char* section, const char* key, u32* value) const
31+
void LayeredSettingsInterface::StoreValue(const char* section, const char* key, std::string_view value)
3232
{
33-
for (u32 layer = FIRST_LAYER; layer <= LAST_LAYER; layer++)
34-
{
35-
if (SettingsInterface* sif = m_layers[layer]; sif != nullptr)
36-
{
37-
if (sif->GetUIntValue(section, key, value))
38-
return true;
39-
}
40-
}
41-
42-
return false;
43-
}
44-
45-
bool LayeredSettingsInterface::GetFloatValue(const char* section, const char* key, float* value) const
46-
{
47-
for (u32 layer = FIRST_LAYER; layer <= LAST_LAYER; layer++)
48-
{
49-
if (SettingsInterface* sif = m_layers[layer]; sif != nullptr)
50-
{
51-
if (sif->GetFloatValue(section, key, value))
52-
return true;
53-
}
54-
}
55-
56-
return false;
57-
}
58-
59-
bool LayeredSettingsInterface::GetDoubleValue(const char* section, const char* key, double* value) const
60-
{
61-
for (u32 layer = FIRST_LAYER; layer <= LAST_LAYER; layer++)
62-
{
63-
if (SettingsInterface* sif = m_layers[layer]; sif != nullptr)
64-
{
65-
if (sif->GetDoubleValue(section, key, value))
66-
return true;
67-
}
68-
}
69-
70-
return false;
71-
}
72-
73-
bool LayeredSettingsInterface::GetBoolValue(const char* section, const char* key, bool* value) const
74-
{
75-
for (u32 layer = FIRST_LAYER; layer <= LAST_LAYER; layer++)
76-
{
77-
if (SettingsInterface* sif = m_layers[layer]; sif != nullptr)
78-
{
79-
if (sif->GetBoolValue(section, key, value))
80-
return true;
81-
}
82-
}
83-
84-
return false;
85-
}
86-
87-
bool LayeredSettingsInterface::GetStringValue(const char* section, const char* key, std::string* value) const
88-
{
89-
for (u32 layer = FIRST_LAYER; layer <= LAST_LAYER; layer++)
90-
{
91-
if (SettingsInterface* sif = m_layers[layer]; sif != nullptr)
92-
{
93-
if (sif->GetStringValue(section, key, value))
94-
return true;
95-
}
96-
}
97-
98-
return false;
99-
}
100-
101-
bool LayeredSettingsInterface::GetStringValue(const char* section, const char* key, SmallStringBase* value) const
102-
{
103-
for (u32 layer = FIRST_LAYER; layer <= LAST_LAYER; layer++)
104-
{
105-
if (SettingsInterface* sif = m_layers[layer]; sif != nullptr)
106-
{
107-
if (sif->GetStringValue(section, key, value))
108-
return true;
109-
}
110-
}
111-
112-
return false;
113-
}
114-
115-
void LayeredSettingsInterface::SetIntValue(const char* section, const char* key, int value)
116-
{
117-
Panic("Attempt to call SetIntValue() on layered settings interface");
118-
}
119-
120-
void LayeredSettingsInterface::SetUIntValue(const char* section, const char* key, u32 value)
121-
{
122-
Panic("Attempt to call SetUIntValue() on layered settings interface");
123-
}
124-
125-
void LayeredSettingsInterface::SetFloatValue(const char* section, const char* key, float value)
126-
{
127-
Panic("Attempt to call SetFloatValue() on layered settings interface");
128-
}
129-
130-
void LayeredSettingsInterface::SetDoubleValue(const char* section, const char* key, double value)
131-
{
132-
Panic("Attempt to call SetDoubleValue() on layered settings interface");
133-
}
134-
135-
void LayeredSettingsInterface::SetBoolValue(const char* section, const char* key, bool value)
136-
{
137-
Panic("Attempt to call SetBoolValue() on layered settings interface");
138-
}
139-
140-
void LayeredSettingsInterface::SetStringValue(const char* section, const char* key, const char* value)
141-
{
142-
Panic("Attempt to call SetStringValue() on layered settings interface");
33+
Panic("Attempt to call StoreValue() on layered settings interface");
14334
}
14435

14536
bool LayeredSettingsInterface::ContainsValue(const char* section, const char* key) const

src/common/layered_settings_interface.h

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,8 @@ class LayeredSettingsInterface final : public SettingsInterface
2424

2525
bool IsEmpty() override;
2626

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;
27+
bool LookupValue(const char* section, const char* key, std::string_view* value) const override;
28+
void StoreValue(const char* section, const char* key, std::string_view value) override;
4129
bool ContainsValue(const char* section, const char* key) const override;
4230
void DeleteValue(const char* section, const char* key) override;
4331
void ClearSection(const char* section) override;
@@ -52,14 +40,6 @@ class LayeredSettingsInterface final : public SettingsInterface
5240
std::vector<std::pair<std::string, std::string>> GetKeyValueList(const char* section) const override;
5341
void SetKeyValueList(const char* section, const std::vector<std::pair<std::string, std::string>>& items) override;
5442

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-
6343
private:
6444
static constexpr Layer FIRST_LAYER = LAYER_GAME;
6545
static constexpr Layer LAST_LAYER = LAYER_BASE;

0 commit comments

Comments
 (0)