summaryrefslogtreecommitdiff
path: root/src/frontend_common/config.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend_common/config.h')
-rw-r--r--src/frontend_common/config.h33
1 files changed, 24 insertions, 9 deletions
diff --git a/src/frontend_common/config.h b/src/frontend_common/config.h
index b3812af17..0c4d505b8 100644
--- a/src/frontend_common/config.h
+++ b/src/frontend_common/config.h
@@ -154,11 +154,20 @@ protected:
154 * @param use_global Specifies if the custom or global config should be in use, for custom 154 * @param use_global Specifies if the custom or global config should be in use, for custom
155 * configs 155 * configs
156 */ 156 */
157 template <typename Type = int> 157 void WriteBooleanSetting(const std::string& key, const bool& value,
158 void WriteSetting(const std::string& key, const Type& value, 158 const std::optional<bool>& default_value = std::nullopt,
159 const std::optional<Type>& default_value = std::nullopt, 159 const std::optional<bool>& use_global = std::nullopt);
160 const std::optional<bool>& use_global = std::nullopt); 160 template <typename T>
161 void WriteSettingInternal(const std::string& key, const std::string& value); 161 std::enable_if_t<std::is_integral_v<T>> WriteIntegerSetting(
162 const std::string& key, const T& value,
163 const std::optional<T>& default_value = std::nullopt,
164 const std::optional<bool>& use_global = std::nullopt);
165 void WriteDoubleSetting(const std::string& key, const double& value,
166 const std::optional<double>& default_value = std::nullopt,
167 const std::optional<bool>& use_global = std::nullopt);
168 void WriteStringSetting(const std::string& key, const std::string& value,
169 const std::optional<std::string>& default_value = std::nullopt,
170 const std::optional<bool>& use_global = std::nullopt);
162 171
163 void ReadCategory(Settings::Category category); 172 void ReadCategory(Settings::Category category);
164 void WriteCategory(Settings::Category category); 173 void WriteCategory(Settings::Category category);
@@ -175,8 +184,10 @@ protected:
175 return value_ ? "true" : "false"; 184 return value_ ? "true" : "false";
176 } else if constexpr (std::is_same_v<T, u64>) { 185 } else if constexpr (std::is_same_v<T, u64>) {
177 return std::to_string(static_cast<u64>(value_)); 186 return std::to_string(static_cast<u64>(value_));
178 } else { 187 } else if constexpr (std::is_same_v<T, s64>) {
179 return std::to_string(static_cast<s64>(value_)); 188 return std::to_string(static_cast<s64>(value_));
189 } else {
190 return std::to_string(value_);
180 } 191 }
181 } 192 }
182 193
@@ -197,9 +208,13 @@ protected:
197 const bool global; 208 const bool global;
198 209
199private: 210private:
200 inline static std::array<char, 19> special_characters = {'!', '#', '$', '%', '^', '&', '*', 211 void WritePreparedSetting(const std::string& key, const std::string& adjusted_value,
201 '|', ';', '\'', '\"', ',', '<', '.', 212 const std::optional<std::string>& adjusted_default_value,
202 '>', '?', '`', '~', '='}; 213 const std::optional<bool>& use_global);
214 void WriteString(const std::string& key, const std::string& value);
215
216 inline static std::array<char, 18> special_characters = {
217 '!', '#', '$', '%', '^', '&', '*', '|', ';', '\'', '\"', ',', '<', '>', '?', '`', '~', '='};
203 218
204 struct ConfigArray { 219 struct ConfigArray {
205 std::string name; 220 std::string name;