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.h39
1 files changed, 30 insertions, 9 deletions
diff --git a/src/frontend_common/config.h b/src/frontend_common/config.h
index b3812af17..b01631649 100644
--- a/src/frontend_common/config.h
+++ b/src/frontend_common/config.h
@@ -154,11 +154,26 @@ 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 void WriteDoubleSetting(const std::string& key, const double& value,
161 void WriteSettingInternal(const std::string& key, const std::string& value); 161 const std::optional<double>& default_value = std::nullopt,
162 const std::optional<bool>& use_global = std::nullopt);
163 void WriteStringSetting(const std::string& key, const std::string& value,
164 const std::optional<std::string>& default_value = std::nullopt,
165 const std::optional<bool>& use_global = std::nullopt);
166 template <typename T>
167 std::enable_if_t<std::is_integral_v<T>> WriteIntegerSetting(
168 const std::string& key, const T& value,
169 const std::optional<T>& default_value = std::nullopt,
170 const std::optional<bool>& use_global = std::nullopt) {
171 std::optional<std::string> string_default = std::nullopt;
172 if (default_value.has_value()) {
173 string_default = std::make_optional(ToString(default_value.value()));
174 }
175 WritePreparedSetting(key, AdjustOutputString(ToString(value)), string_default, use_global);
176 }
162 177
163 void ReadCategory(Settings::Category category); 178 void ReadCategory(Settings::Category category);
164 void WriteCategory(Settings::Category category); 179 void WriteCategory(Settings::Category category);
@@ -175,8 +190,10 @@ protected:
175 return value_ ? "true" : "false"; 190 return value_ ? "true" : "false";
176 } else if constexpr (std::is_same_v<T, u64>) { 191 } else if constexpr (std::is_same_v<T, u64>) {
177 return std::to_string(static_cast<u64>(value_)); 192 return std::to_string(static_cast<u64>(value_));
178 } else { 193 } else if constexpr (std::is_same_v<T, s64>) {
179 return std::to_string(static_cast<s64>(value_)); 194 return std::to_string(static_cast<s64>(value_));
195 } else {
196 return std::to_string(value_);
180 } 197 }
181 } 198 }
182 199
@@ -197,9 +214,13 @@ protected:
197 const bool global; 214 const bool global;
198 215
199private: 216private:
200 inline static std::array<char, 19> special_characters = {'!', '#', '$', '%', '^', '&', '*', 217 void WritePreparedSetting(const std::string& key, const std::string& adjusted_value,
201 '|', ';', '\'', '\"', ',', '<', '.', 218 const std::optional<std::string>& adjusted_default_value,
202 '>', '?', '`', '~', '='}; 219 const std::optional<bool>& use_global);
220 void WriteString(const std::string& key, const std::string& value);
221
222 inline static std::array<char, 18> special_characters = {
223 '!', '#', '$', '%', '^', '&', '*', '|', ';', '\'', '\"', ',', '<', '>', '?', '`', '~', '='};
203 224
204 struct ConfigArray { 225 struct ConfigArray {
205 std::string name; 226 std::string name;