2024-03-31 05:50:29 +00:00
|
|
|
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
|
2024-09-01 12:08:31 +00:00
|
|
|
// SPDX-License-Identifier: CC-BY-NC-ND-4.0
|
2022-12-04 11:03:45 +00:00
|
|
|
|
2021-07-23 14:02:09 +00:00
|
|
|
#pragma once
|
2022-07-09 04:17:57 +00:00
|
|
|
#include "heterogeneous_containers.h"
|
|
|
|
#include "settings_interface.h"
|
2021-07-23 14:02:09 +00:00
|
|
|
#include <string>
|
|
|
|
|
2022-07-09 04:17:57 +00:00
|
|
|
class MemorySettingsInterface final : public SettingsInterface
|
2021-07-23 14:02:09 +00:00
|
|
|
{
|
|
|
|
public:
|
2023-10-02 11:33:44 +00:00
|
|
|
MemorySettingsInterface();
|
2024-08-24 04:10:25 +00:00
|
|
|
~MemorySettingsInterface() override;
|
2023-10-02 11:33:44 +00:00
|
|
|
|
2024-03-31 05:50:29 +00:00
|
|
|
bool Save(Error* error = nullptr) override;
|
2023-10-02 11:33:44 +00:00
|
|
|
|
|
|
|
void Clear() override;
|
|
|
|
|
2024-04-25 04:02:16 +00:00
|
|
|
bool IsEmpty() override;
|
|
|
|
|
2023-10-02 11:33:44 +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;
|
2024-04-07 10:41:24 +00:00
|
|
|
bool GetStringValue(const char* section, const char* key, SmallStringBase* value) const override;
|
2023-10-02 11:33:44 +00:00
|
|
|
|
|
|
|
void SetIntValue(const char* section, const char* key, s32 value) override;
|
|
|
|
void SetUIntValue(const char* section, const char* key, u32 value) override;
|
|
|
|
void SetFloatValue(const char* section, const char* key, float value) override;
|
|
|
|
void SetDoubleValue(const char* section, const char* key, double value) override;
|
|
|
|
void SetBoolValue(const char* section, const char* key, bool value) override;
|
|
|
|
void SetStringValue(const char* section, const char* key, const char* value) override;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
bool ContainsValue(const char* section, const char* key) const override;
|
|
|
|
void DeleteValue(const char* section, const char* key) override;
|
|
|
|
void ClearSection(const char* section) override;
|
2024-04-25 04:02:16 +00:00
|
|
|
void RemoveSection(const char* section) override;
|
2024-04-25 04:59:27 +00:00
|
|
|
void RemoveEmptySections() override;
|
2023-10-02 11:33:44 +00:00
|
|
|
|
|
|
|
std::vector<std::string> GetStringList(const char* section, const char* key) const override;
|
|
|
|
void SetStringList(const char* section, const char* key, const std::vector<std::string>& items) override;
|
|
|
|
bool RemoveFromStringList(const char* section, const char* key, const char* item) override;
|
|
|
|
bool AddToStringList(const char* section, const char* key, const char* item) override;
|
|
|
|
|
|
|
|
// default parameter overloads
|
|
|
|
using SettingsInterface::GetBoolValue;
|
|
|
|
using SettingsInterface::GetDoubleValue;
|
|
|
|
using SettingsInterface::GetFloatValue;
|
|
|
|
using SettingsInterface::GetIntValue;
|
|
|
|
using SettingsInterface::GetStringValue;
|
|
|
|
using SettingsInterface::GetUIntValue;
|
2021-07-23 14:02:09 +00:00
|
|
|
|
|
|
|
private:
|
2023-10-02 11:33:44 +00:00
|
|
|
using KeyMap = PreferUnorderedStringMultimap<std::string>;
|
|
|
|
using SectionMap = PreferUnorderedStringMap<KeyMap>;
|
2022-07-09 04:17:57 +00:00
|
|
|
|
2023-10-02 11:33:44 +00:00
|
|
|
void SetValue(const char* section, const char* key, std::string value);
|
2022-07-09 04:17:57 +00:00
|
|
|
|
2023-10-02 11:33:44 +00:00
|
|
|
SectionMap m_sections;
|
|
|
|
};
|