INISettingsInterface: Use case sensitive storage

Need to replace SimpleIni at some point, want to move the settings
interface to use string_views.
This commit is contained in:
Stenzek
2025-11-05 13:13:16 +10:00
parent a22d3a794b
commit f9cab709bd
2 changed files with 10 additions and 8 deletions

View File

@@ -293,9 +293,9 @@ void INISettingsInterface::RemoveSection(const char* section)
void INISettingsInterface::RemoveEmptySections()
{
std::list<CSimpleIniA::Entry> entries;
std::list<IniStorage::Entry> entries;
m_ini.GetAllSections(entries);
for (const CSimpleIniA::Entry& entry : entries)
for (const IniStorage::Entry& entry : entries)
{
if (m_ini.GetSectionSize(entry.pItem) > 0)
continue;
@@ -307,13 +307,13 @@ void INISettingsInterface::RemoveEmptySections()
std::vector<std::string> INISettingsInterface::GetStringList(const char* section, const char* key) const
{
std::list<CSimpleIniA::Entry> entries;
std::list<IniStorage::Entry> entries;
if (!m_ini.GetAllValues(section, key, entries))
return {};
std::vector<std::string> ret;
ret.reserve(entries.size());
for (const CSimpleIniA::Entry& entry : entries)
for (const IniStorage::Entry& entry : entries)
ret.emplace_back(entry.pItem);
return ret;
}
@@ -335,10 +335,10 @@ bool INISettingsInterface::RemoveFromStringList(const char* section, const char*
bool INISettingsInterface::AddToStringList(const char* section, const char* key, const char* item)
{
std::list<CSimpleIniA::Entry> entries;
std::list<IniStorage::Entry> entries;
if (m_ini.GetAllValues(section, key, entries) &&
std::find_if(entries.begin(), entries.end(),
[item](const CSimpleIniA::Entry& e) { return (std::strcmp(e.pItem, item) == 0); }) != entries.end())
[item](const IniStorage::Entry& e) { return (std::strcmp(e.pItem, item) == 0); }) != entries.end())
{
return false;
}
@@ -350,7 +350,7 @@ bool INISettingsInterface::AddToStringList(const char* section, const char* key,
std::vector<std::pair<std::string, std::string>> INISettingsInterface::GetKeyValueList(const char* section) const
{
using Entry = CSimpleIniA::Entry;
using Entry = IniStorage::Entry;
using KVEntry = std::pair<const char*, Entry>;
std::vector<KVEntry> entries;
std::vector<std::pair<std::string, std::string>> output;

View File

@@ -66,7 +66,9 @@ public:
using SettingsInterface::GetUIntValue;
private:
using IniStorage = CSimpleIniCaseA;
std::string m_path;
CSimpleIniA m_ini;
IniStorage m_ini;
bool m_dirty = false;
};