2022-12-04 11:03:45 +00:00
|
|
|
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
|
|
|
|
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
|
|
|
|
2019-12-30 11:22:22 +00:00
|
|
|
#pragma once
|
2022-07-08 14:14:48 +00:00
|
|
|
#include "common/settings_interface.h"
|
2019-12-30 11:22:22 +00:00
|
|
|
|
2020-08-08 18:40:15 +00:00
|
|
|
// being a pain here...
|
2021-06-28 10:16:48 +00:00
|
|
|
#ifdef _WIN32
|
2020-08-08 18:40:15 +00:00
|
|
|
#include "common/windows_headers.h"
|
|
|
|
#endif
|
2019-12-30 11:22:22 +00:00
|
|
|
#include "SimpleIni.h"
|
|
|
|
|
2020-09-13 01:54:51 +00:00
|
|
|
class INISettingsInterface final : public SettingsInterface
|
2019-12-30 11:22:22 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-04-05 12:57:29 +00:00
|
|
|
INISettingsInterface(std::string filename);
|
2020-09-13 01:54:51 +00:00
|
|
|
~INISettingsInterface() override;
|
2019-12-30 11:22:22 +00:00
|
|
|
|
2022-07-08 14:14:48 +00:00
|
|
|
const std::string& GetFileName() const { return m_filename; }
|
|
|
|
|
|
|
|
bool Load();
|
2021-01-30 05:30:33 +00:00
|
|
|
bool Save() override;
|
2020-04-10 14:00:21 +00:00
|
|
|
|
2020-02-28 07:00:09 +00:00
|
|
|
void Clear() override;
|
|
|
|
|
2022-07-08 14:14:48 +00:00
|
|
|
bool GetIntValue(const char* section, const char* key, s32* value) const override;
|
|
|
|
bool GetUIntValue(const char* section, const char* key, u32* value) const override;
|
|
|
|
bool GetFloatValue(const char* section, const char* key, float* value) const override;
|
|
|
|
bool GetDoubleValue(const char* section, const char* key, double* value) const override;
|
|
|
|
bool GetBoolValue(const char* section, const char* key, bool* value) const override;
|
|
|
|
bool GetStringValue(const char* section, const char* key, std::string* value) const override;
|
2019-12-30 11:22:22 +00:00
|
|
|
|
2022-07-08 14:14:48 +00:00
|
|
|
void SetIntValue(const char* section, const char* key, s32 value) override;
|
|
|
|
void SetUIntValue(const char* section, const char* key, u32 value) override;
|
2019-12-30 11:22:22 +00:00
|
|
|
void SetFloatValue(const char* section, const char* key, float value) override;
|
2022-07-08 14:14:48 +00:00
|
|
|
void SetDoubleValue(const char* section, const char* key, double value) override;
|
2019-12-30 11:22:22 +00:00
|
|
|
void SetBoolValue(const char* section, const char* key, bool value) override;
|
|
|
|
void SetStringValue(const char* section, const char* key, const char* value) override;
|
2022-07-08 14:14:48 +00:00
|
|
|
bool ContainsValue(const char* section, const char* key) const override;
|
2019-12-30 11:22:22 +00:00
|
|
|
void DeleteValue(const char* section, const char* key) override;
|
2020-12-20 03:23:33 +00:00
|
|
|
void ClearSection(const char* section) override;
|
2019-12-30 11:22:22 +00:00
|
|
|
|
2022-07-08 14:14:48 +00:00
|
|
|
std::vector<std::string> GetStringList(const char* section, const char* key) const override;
|
2020-07-21 09:49:04 +00:00
|
|
|
void SetStringList(const char* section, const char* key, const std::vector<std::string>& items) override;
|
2019-12-31 02:41:21 +00:00
|
|
|
bool RemoveFromStringList(const char* section, const char* key, const char* item) override;
|
|
|
|
bool AddToStringList(const char* section, const char* key, const char* item) override;
|
|
|
|
|
2023-01-15 04:00:51 +00:00
|
|
|
std::vector<std::pair<std::string, std::string>> GetKeyValueList(const char* section) const override;
|
|
|
|
void SetKeyValueList(const char* section, const std::vector<std::pair<std::string, std::string>>& items) override;
|
|
|
|
|
2022-07-08 14:14:48 +00:00
|
|
|
// default parameter overloads
|
|
|
|
using SettingsInterface::GetBoolValue;
|
|
|
|
using SettingsInterface::GetDoubleValue;
|
|
|
|
using SettingsInterface::GetFloatValue;
|
|
|
|
using SettingsInterface::GetIntValue;
|
|
|
|
using SettingsInterface::GetStringValue;
|
|
|
|
using SettingsInterface::GetUIntValue;
|
|
|
|
|
2019-12-30 11:22:22 +00:00
|
|
|
private:
|
|
|
|
std::string m_filename;
|
|
|
|
CSimpleIniA m_ini;
|
2020-02-15 15:14:42 +00:00
|
|
|
bool m_dirty = false;
|
2019-12-30 11:22:22 +00:00
|
|
|
};
|