Common: Drop fallback path for HeterogeneousContainers
This commit is contained in:
parent
58b4946fb9
commit
391307efaa
|
@ -1,4 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
|
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
|
||||||
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,8 +47,6 @@ struct transparent_string_less
|
||||||
};
|
};
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
// This requires C++20, so fallback to ugly heap allocations if we don't have it.
|
|
||||||
#if __cplusplus >= 202002L
|
|
||||||
template<typename ValueType>
|
template<typename ValueType>
|
||||||
using UnorderedStringMap =
|
using UnorderedStringMap =
|
||||||
std::unordered_map<std::string, ValueType, detail::transparent_string_hash, detail::transparent_string_equal>;
|
std::unordered_map<std::string, ValueType, detail::transparent_string_hash, detail::transparent_string_equal>;
|
||||||
|
@ -60,95 +58,9 @@ using UnorderedStringSet =
|
||||||
using UnorderedStringMultiSet =
|
using UnorderedStringMultiSet =
|
||||||
std::unordered_multiset<std::string, detail::transparent_string_hash, detail::transparent_string_equal>;
|
std::unordered_multiset<std::string, detail::transparent_string_hash, detail::transparent_string_equal>;
|
||||||
|
|
||||||
template<typename KeyType, typename ValueType>
|
|
||||||
ALWAYS_INLINE typename UnorderedStringMap<ValueType>::const_iterator
|
|
||||||
UnorderedStringMapFind(const UnorderedStringMap<ValueType>& map, const KeyType& key)
|
|
||||||
{
|
|
||||||
return map.find(key);
|
|
||||||
}
|
|
||||||
template<typename KeyType, typename ValueType>
|
|
||||||
ALWAYS_INLINE typename UnorderedStringMap<ValueType>::iterator
|
|
||||||
UnorderedStringMapFind(UnorderedStringMap<ValueType>& map, const KeyType& key)
|
|
||||||
{
|
|
||||||
return map.find(key);
|
|
||||||
}
|
|
||||||
template<typename KeyType, typename ValueType>
|
|
||||||
ALWAYS_INLINE typename UnorderedStringMultimap<ValueType>::const_iterator
|
|
||||||
UnorderedStringMultiMapFind(const UnorderedStringMultimap<ValueType>& map, const KeyType& key)
|
|
||||||
{
|
|
||||||
return map.find(key);
|
|
||||||
}
|
|
||||||
template<typename KeyType, typename ValueType>
|
|
||||||
ALWAYS_INLINE std::pair<typename UnorderedStringMultimap<ValueType>::const_iterator,
|
|
||||||
typename UnorderedStringMultimap<ValueType>::const_iterator>
|
|
||||||
UnorderedStringMultiMapEqualRange(const UnorderedStringMultimap<ValueType>& map, const KeyType& key)
|
|
||||||
{
|
|
||||||
return map.equal_range(key);
|
|
||||||
}
|
|
||||||
template<typename KeyType, typename ValueType>
|
|
||||||
ALWAYS_INLINE typename UnorderedStringMultimap<ValueType>::iterator
|
|
||||||
UnorderedStringMultiMapFind(UnorderedStringMultimap<ValueType>& map, const KeyType& key)
|
|
||||||
{
|
|
||||||
return map.find(key);
|
|
||||||
}
|
|
||||||
template<typename KeyType, typename ValueType>
|
|
||||||
ALWAYS_INLINE std::pair<typename UnorderedStringMultimap<ValueType>::iterator,
|
|
||||||
typename UnorderedStringMultimap<ValueType>::iterator>
|
|
||||||
UnorderedStringMultiMapEqualRange(UnorderedStringMultimap<ValueType>& map, const KeyType& key)
|
|
||||||
{
|
|
||||||
return map.equal_range(key);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
template<typename ValueType>
|
|
||||||
using UnorderedStringMap = std::unordered_map<std::string, ValueType>;
|
|
||||||
template<typename ValueType>
|
|
||||||
using UnorderedStringMultimap = std::unordered_multimap<std::string, ValueType>;
|
|
||||||
using UnorderedStringSet = std::unordered_set<std::string>;
|
|
||||||
using UnorderedStringMultiSet = std::unordered_multiset<std::string>;
|
|
||||||
|
|
||||||
template<typename KeyType, typename ValueType>
|
|
||||||
ALWAYS_INLINE typename UnorderedStringMap<ValueType>::const_iterator
|
|
||||||
UnorderedStringMapFind(const UnorderedStringMap<ValueType>& map, const KeyType& key)
|
|
||||||
{
|
|
||||||
return map.find(std::string(key));
|
|
||||||
}
|
|
||||||
template<typename KeyType, typename ValueType>
|
|
||||||
ALWAYS_INLINE typename UnorderedStringMap<ValueType>::iterator
|
|
||||||
UnorderedStringMapFind(UnorderedStringMap<ValueType>& map, const KeyType& key)
|
|
||||||
{
|
|
||||||
return map.find(std::string(key));
|
|
||||||
}
|
|
||||||
template<typename KeyType, typename ValueType>
|
|
||||||
ALWAYS_INLINE typename UnorderedStringMultimap<ValueType>::const_iterator
|
|
||||||
UnorderedStringMultiMapFind(const UnorderedStringMultimap<ValueType>& map, const KeyType& key)
|
|
||||||
{
|
|
||||||
return map.find(std::string(key));
|
|
||||||
}
|
|
||||||
template<typename KeyType, typename ValueType>
|
|
||||||
ALWAYS_INLINE std::pair<typename UnorderedStringMultimap<ValueType>::const_iterator,
|
|
||||||
typename UnorderedStringMultimap<ValueType>::const_iterator>
|
|
||||||
UnorderedStringMultiMapEqualRange(const UnorderedStringMultimap<ValueType>& map, const KeyType& key)
|
|
||||||
{
|
|
||||||
return map.equal_range(std::string(key));
|
|
||||||
}
|
|
||||||
template<typename KeyType, typename ValueType>
|
|
||||||
ALWAYS_INLINE typename UnorderedStringMultimap<ValueType>::iterator
|
|
||||||
UnorderedStringMultiMapFind(UnorderedStringMultimap<ValueType>& map, const KeyType& key)
|
|
||||||
{
|
|
||||||
return map.find(std::string(key));
|
|
||||||
}
|
|
||||||
template<typename KeyType, typename ValueType>
|
|
||||||
ALWAYS_INLINE std::pair<typename UnorderedStringMultimap<ValueType>::iterator,
|
|
||||||
typename UnorderedStringMultimap<ValueType>::iterator>
|
|
||||||
UnorderedStringMultiMapEqualRange(UnorderedStringMultimap<ValueType>& map, const KeyType& key)
|
|
||||||
{
|
|
||||||
return map.equal_range(std::string(key));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template<typename ValueType>
|
template<typename ValueType>
|
||||||
using StringMap = std::map<std::string, ValueType, detail::transparent_string_less>;
|
using StringMap = std::map<std::string, ValueType, detail::transparent_string_less>;
|
||||||
template<typename ValueType>
|
template<typename ValueType>
|
||||||
using StringMultiMap = std::multimap<std::string, ValueType, detail::transparent_string_less>;
|
using StringMultiMap = std::multimap<std::string, ValueType, detail::transparent_string_less>;
|
||||||
using StringSet = std::set<std::string, detail::transparent_string_less>;
|
using StringSet = std::set<std::string, detail::transparent_string_less>;
|
||||||
using StringMultiSet = std::multiset<std::string, detail::transparent_string_less>;
|
using StringMultiSet = std::multiset<std::string, detail::transparent_string_less>;
|
|
@ -21,7 +21,7 @@ void MemorySettingsInterface::Clear()
|
||||||
|
|
||||||
bool MemorySettingsInterface::GetIntValue(const char* section, const char* key, s32* value) const
|
bool MemorySettingsInterface::GetIntValue(const char* section, const char* key, s32* value) const
|
||||||
{
|
{
|
||||||
const auto sit = UnorderedStringMapFind(m_sections, section);
|
const auto sit = m_sections.find(section);
|
||||||
if (sit == m_sections.end())
|
if (sit == m_sections.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -39,11 +39,11 @@ bool MemorySettingsInterface::GetIntValue(const char* section, const char* key,
|
||||||
|
|
||||||
bool MemorySettingsInterface::GetUIntValue(const char* section, const char* key, u32* value) const
|
bool MemorySettingsInterface::GetUIntValue(const char* section, const char* key, u32* value) const
|
||||||
{
|
{
|
||||||
const auto sit = UnorderedStringMapFind(m_sections, section);
|
const auto sit = m_sections.find(section);
|
||||||
if (sit == m_sections.end())
|
if (sit == m_sections.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const auto iter = UnorderedStringMultiMapFind(sit->second, key);
|
const auto iter = sit->second.find(key);
|
||||||
if (iter == sit->second.end())
|
if (iter == sit->second.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -57,11 +57,11 @@ bool MemorySettingsInterface::GetUIntValue(const char* section, const char* key,
|
||||||
|
|
||||||
bool MemorySettingsInterface::GetFloatValue(const char* section, const char* key, float* value) const
|
bool MemorySettingsInterface::GetFloatValue(const char* section, const char* key, float* value) const
|
||||||
{
|
{
|
||||||
const auto sit = UnorderedStringMapFind(m_sections, section);
|
const auto sit = m_sections.find(section);
|
||||||
if (sit == m_sections.end())
|
if (sit == m_sections.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const auto iter = UnorderedStringMultiMapFind(sit->second, key);
|
const auto iter = sit->second.find(key);
|
||||||
if (iter == sit->second.end())
|
if (iter == sit->second.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -75,11 +75,11 @@ bool MemorySettingsInterface::GetFloatValue(const char* section, const char* key
|
||||||
|
|
||||||
bool MemorySettingsInterface::GetDoubleValue(const char* section, const char* key, double* value) const
|
bool MemorySettingsInterface::GetDoubleValue(const char* section, const char* key, double* value) const
|
||||||
{
|
{
|
||||||
const auto sit = UnorderedStringMapFind(m_sections, section);
|
const auto sit = m_sections.find(section);
|
||||||
if (sit == m_sections.end())
|
if (sit == m_sections.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const auto iter = UnorderedStringMultiMapFind(sit->second, key);
|
const auto iter = sit->second.find(key);
|
||||||
if (iter == sit->second.end())
|
if (iter == sit->second.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -93,11 +93,11 @@ bool MemorySettingsInterface::GetDoubleValue(const char* section, const char* ke
|
||||||
|
|
||||||
bool MemorySettingsInterface::GetBoolValue(const char* section, const char* key, bool* value) const
|
bool MemorySettingsInterface::GetBoolValue(const char* section, const char* key, bool* value) const
|
||||||
{
|
{
|
||||||
const auto sit = UnorderedStringMapFind(m_sections, section);
|
const auto sit = m_sections.find(section);
|
||||||
if (sit == m_sections.end())
|
if (sit == m_sections.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const auto iter = UnorderedStringMultiMapFind(sit->second, key);
|
const auto iter = sit->second.find(key);
|
||||||
if (iter == sit->second.end())
|
if (iter == sit->second.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -111,11 +111,11 @@ bool MemorySettingsInterface::GetBoolValue(const char* section, const char* key,
|
||||||
|
|
||||||
bool MemorySettingsInterface::GetStringValue(const char* section, const char* key, std::string* value) const
|
bool MemorySettingsInterface::GetStringValue(const char* section, const char* key, std::string* value) const
|
||||||
{
|
{
|
||||||
const auto sit = UnorderedStringMapFind(m_sections, section);
|
const auto sit = m_sections.find(section);
|
||||||
if (sit == m_sections.end())
|
if (sit == m_sections.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const auto iter = UnorderedStringMultiMapFind(sit->second, key);
|
const auto iter = sit->second.find(key);
|
||||||
if (iter == sit->second.end())
|
if (iter == sit->second.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ void MemorySettingsInterface::SetStringValue(const char* section, const char* ke
|
||||||
std::vector<std::pair<std::string, std::string>> MemorySettingsInterface::GetKeyValueList(const char* section) const
|
std::vector<std::pair<std::string, std::string>> MemorySettingsInterface::GetKeyValueList(const char* section) const
|
||||||
{
|
{
|
||||||
std::vector<std::pair<std::string, std::string>> output;
|
std::vector<std::pair<std::string, std::string>> output;
|
||||||
auto sit = UnorderedStringMapFind(m_sections, section);
|
auto sit = m_sections.find(section);
|
||||||
if (sit != m_sections.end())
|
if (sit != m_sections.end())
|
||||||
{
|
{
|
||||||
for (const auto& it : sit->second)
|
for (const auto& it : sit->second)
|
||||||
|
@ -168,7 +168,7 @@ std::vector<std::pair<std::string, std::string>> MemorySettingsInterface::GetKey
|
||||||
void MemorySettingsInterface::SetKeyValueList(const char* section,
|
void MemorySettingsInterface::SetKeyValueList(const char* section,
|
||||||
const std::vector<std::pair<std::string, std::string>>& items)
|
const std::vector<std::pair<std::string, std::string>>& items)
|
||||||
{
|
{
|
||||||
auto sit = UnorderedStringMapFind(m_sections, section);
|
auto sit = m_sections.find(section);
|
||||||
sit->second.clear();
|
sit->second.clear();
|
||||||
for (const auto& [key, value] : items)
|
for (const auto& [key, value] : items)
|
||||||
sit->second.emplace(key, value);
|
sit->second.emplace(key, value);
|
||||||
|
@ -176,11 +176,11 @@ void MemorySettingsInterface::SetKeyValueList(const char* section,
|
||||||
|
|
||||||
void MemorySettingsInterface::SetValue(const char* section, const char* key, std::string value)
|
void MemorySettingsInterface::SetValue(const char* section, const char* key, std::string value)
|
||||||
{
|
{
|
||||||
auto sit = UnorderedStringMapFind(m_sections, section);
|
auto sit = m_sections.find(section);
|
||||||
if (sit == m_sections.end())
|
if (sit == m_sections.end())
|
||||||
sit = m_sections.emplace(std::make_pair(std::string(section), KeyMap())).first;
|
sit = m_sections.emplace(std::make_pair(std::string(section), KeyMap())).first;
|
||||||
|
|
||||||
const auto range = UnorderedStringMultiMapEqualRange(sit->second, key);
|
const auto range = sit->second.equal_range(key);
|
||||||
if (range.first == sit->second.end())
|
if (range.first == sit->second.end())
|
||||||
{
|
{
|
||||||
sit->second.emplace(std::string(key), std::move(value));
|
sit->second.emplace(std::string(key), std::move(value));
|
||||||
|
@ -203,10 +203,10 @@ std::vector<std::string> MemorySettingsInterface::GetStringList(const char* sect
|
||||||
{
|
{
|
||||||
std::vector<std::string> ret;
|
std::vector<std::string> ret;
|
||||||
|
|
||||||
const auto sit = UnorderedStringMapFind(m_sections, section);
|
const auto sit = m_sections.find(section);
|
||||||
if (sit != m_sections.end())
|
if (sit != m_sections.end())
|
||||||
{
|
{
|
||||||
const auto range = UnorderedStringMultiMapEqualRange(sit->second, key);
|
const auto range = sit->second.equal_range(key);
|
||||||
for (auto iter = range.first; iter != range.second; ++iter)
|
for (auto iter = range.first; iter != range.second; ++iter)
|
||||||
ret.emplace_back(iter->second);
|
ret.emplace_back(iter->second);
|
||||||
}
|
}
|
||||||
|
@ -216,11 +216,11 @@ std::vector<std::string> MemorySettingsInterface::GetStringList(const char* sect
|
||||||
|
|
||||||
void MemorySettingsInterface::SetStringList(const char* section, const char* key, const std::vector<std::string>& items)
|
void MemorySettingsInterface::SetStringList(const char* section, const char* key, const std::vector<std::string>& items)
|
||||||
{
|
{
|
||||||
auto sit = UnorderedStringMapFind(m_sections, section);
|
auto sit = m_sections.find(section);
|
||||||
if (sit == m_sections.end())
|
if (sit == m_sections.end())
|
||||||
sit = m_sections.emplace(std::make_pair(std::string(section), KeyMap())).first;
|
sit = m_sections.emplace(std::make_pair(std::string(section), KeyMap())).first;
|
||||||
|
|
||||||
const auto range = UnorderedStringMultiMapEqualRange(sit->second, key);
|
const auto range = sit->second.equal_range(key);
|
||||||
for (auto iter = range.first; iter != range.second;)
|
for (auto iter = range.first; iter != range.second;)
|
||||||
sit->second.erase(iter++);
|
sit->second.erase(iter++);
|
||||||
|
|
||||||
|
@ -231,11 +231,11 @@ void MemorySettingsInterface::SetStringList(const char* section, const char* key
|
||||||
|
|
||||||
bool MemorySettingsInterface::RemoveFromStringList(const char* section, const char* key, const char* item)
|
bool MemorySettingsInterface::RemoveFromStringList(const char* section, const char* key, const char* item)
|
||||||
{
|
{
|
||||||
auto sit = UnorderedStringMapFind(m_sections, section);
|
auto sit = m_sections.find(section);
|
||||||
if (sit == m_sections.end())
|
if (sit == m_sections.end())
|
||||||
sit = m_sections.emplace(std::make_pair(std::string(section), KeyMap())).first;
|
sit = m_sections.emplace(std::make_pair(std::string(section), KeyMap())).first;
|
||||||
|
|
||||||
const auto range = UnorderedStringMultiMapEqualRange(sit->second, key);
|
const auto range = sit->second.equal_range(key);
|
||||||
bool result = false;
|
bool result = false;
|
||||||
for (auto iter = range.first; iter != range.second;)
|
for (auto iter = range.first; iter != range.second;)
|
||||||
{
|
{
|
||||||
|
@ -255,11 +255,11 @@ bool MemorySettingsInterface::RemoveFromStringList(const char* section, const ch
|
||||||
|
|
||||||
bool MemorySettingsInterface::AddToStringList(const char* section, const char* key, const char* item)
|
bool MemorySettingsInterface::AddToStringList(const char* section, const char* key, const char* item)
|
||||||
{
|
{
|
||||||
auto sit = UnorderedStringMapFind(m_sections, section);
|
auto sit = m_sections.find(section);
|
||||||
if (sit == m_sections.end())
|
if (sit == m_sections.end())
|
||||||
sit = m_sections.emplace(std::make_pair(std::string(section), KeyMap())).first;
|
sit = m_sections.emplace(std::make_pair(std::string(section), KeyMap())).first;
|
||||||
|
|
||||||
const auto range = UnorderedStringMultiMapEqualRange(sit->second, key);
|
const auto range = sit->second.equal_range(key);
|
||||||
for (auto iter = range.first; iter != range.second; ++iter)
|
for (auto iter = range.first; iter != range.second; ++iter)
|
||||||
{
|
{
|
||||||
if (iter->second == item)
|
if (iter->second == item)
|
||||||
|
@ -272,7 +272,7 @@ bool MemorySettingsInterface::AddToStringList(const char* section, const char* k
|
||||||
|
|
||||||
bool MemorySettingsInterface::ContainsValue(const char* section, const char* key) const
|
bool MemorySettingsInterface::ContainsValue(const char* section, const char* key) const
|
||||||
{
|
{
|
||||||
const auto sit = UnorderedStringMapFind(m_sections, section);
|
const auto sit = m_sections.find(section);
|
||||||
if (sit == m_sections.end())
|
if (sit == m_sections.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -281,18 +281,18 @@ bool MemorySettingsInterface::ContainsValue(const char* section, const char* key
|
||||||
|
|
||||||
void MemorySettingsInterface::DeleteValue(const char* section, const char* key)
|
void MemorySettingsInterface::DeleteValue(const char* section, const char* key)
|
||||||
{
|
{
|
||||||
auto sit = UnorderedStringMapFind(m_sections, section);
|
auto sit = m_sections.find(section);
|
||||||
if (sit == m_sections.end())
|
if (sit == m_sections.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const auto range = UnorderedStringMultiMapEqualRange(sit->second, key);
|
const auto range = sit->second.equal_range(key);
|
||||||
for (auto iter = range.first; iter != range.second;)
|
for (auto iter = range.first; iter != range.second;)
|
||||||
sit->second.erase(iter++);
|
sit->second.erase(iter++);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemorySettingsInterface::ClearSection(const char* section)
|
void MemorySettingsInterface::ClearSection(const char* section)
|
||||||
{
|
{
|
||||||
auto sit = UnorderedStringMapFind(m_sections, section);
|
auto sit = m_sections.find(section);
|
||||||
if (sit == m_sections.end())
|
if (sit == m_sections.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -9,52 +9,52 @@
|
||||||
class MemorySettingsInterface final : public SettingsInterface
|
class MemorySettingsInterface final : public SettingsInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MemorySettingsInterface();
|
MemorySettingsInterface();
|
||||||
~MemorySettingsInterface();
|
~MemorySettingsInterface();
|
||||||
|
|
||||||
bool Save() override;
|
bool Save() override;
|
||||||
|
|
||||||
void Clear() override;
|
void Clear() override;
|
||||||
|
|
||||||
bool GetIntValue(const char* section, const char* key, s32* value) const override;
|
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 GetUIntValue(const char* section, const char* key, u32* value) const override;
|
||||||
bool GetFloatValue(const char* section, const char* key, float* 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 GetDoubleValue(const char* section, const char* key, double* value) const override;
|
||||||
bool GetBoolValue(const char* section, const char* key, bool* 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;
|
bool GetStringValue(const char* section, const char* key, std::string* value) const override;
|
||||||
|
|
||||||
void SetIntValue(const char* section, const char* key, s32 value) override;
|
void SetIntValue(const char* section, const char* key, s32 value) override;
|
||||||
void SetUIntValue(const char* section, const char* key, u32 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 SetFloatValue(const char* section, const char* key, float value) override;
|
||||||
void SetDoubleValue(const char* section, const char* key, double 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 SetBoolValue(const char* section, const char* key, bool value) override;
|
||||||
void SetStringValue(const char* section, const char* key, const char* 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;
|
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;
|
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;
|
bool ContainsValue(const char* section, const char* key) const override;
|
||||||
void DeleteValue(const char* section, const char* key) override;
|
void DeleteValue(const char* section, const char* key) override;
|
||||||
void ClearSection(const char* section) override;
|
void ClearSection(const char* section) override;
|
||||||
|
|
||||||
std::vector<std::string> GetStringList(const char* section, const char* key) const override;
|
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;
|
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 RemoveFromStringList(const char* section, const char* key, const char* item) override;
|
||||||
bool AddToStringList(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
|
// default parameter overloads
|
||||||
using SettingsInterface::GetBoolValue;
|
using SettingsInterface::GetBoolValue;
|
||||||
using SettingsInterface::GetDoubleValue;
|
using SettingsInterface::GetDoubleValue;
|
||||||
using SettingsInterface::GetFloatValue;
|
using SettingsInterface::GetFloatValue;
|
||||||
using SettingsInterface::GetIntValue;
|
using SettingsInterface::GetIntValue;
|
||||||
using SettingsInterface::GetStringValue;
|
using SettingsInterface::GetStringValue;
|
||||||
using SettingsInterface::GetUIntValue;
|
using SettingsInterface::GetUIntValue;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using KeyMap = UnorderedStringMultimap<std::string>;
|
using KeyMap = UnorderedStringMultimap<std::string>;
|
||||||
using SectionMap = UnorderedStringMap<KeyMap>;
|
using SectionMap = UnorderedStringMap<KeyMap>;
|
||||||
|
|
||||||
void SetValue(const char* section, const char* key, std::string value);
|
void SetValue(const char* section, const char* key, std::string value);
|
||||||
|
|
||||||
SectionMap m_sections;
|
SectionMap m_sections;
|
||||||
};
|
};
|
|
@ -115,7 +115,7 @@ const GameDatabase::Entry* GameDatabase::GetEntryForId(const std::string_view& c
|
||||||
|
|
||||||
EnsureLoaded();
|
EnsureLoaded();
|
||||||
|
|
||||||
auto iter = UnorderedStringMapFind(s_code_lookup, code);
|
auto iter = s_code_lookup.find(code);
|
||||||
return (iter != s_code_lookup.end()) ? &s_entries[iter->second] : nullptr;
|
return (iter != s_code_lookup.end()) ? &s_entries[iter->second] : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1005,7 +1005,7 @@ bool GameDatabase::ParseJsonCodes(u32 index, const rapidjson::Value& value)
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string_view code(current_code.GetString(), current_code.GetStringLength());
|
const std::string_view code(current_code.GetString(), current_code.GetStringLength());
|
||||||
auto iter = UnorderedStringMapFind(s_code_lookup, code);
|
auto iter = s_code_lookup.find(code);
|
||||||
if (iter != s_code_lookup.end())
|
if (iter != s_code_lookup.end())
|
||||||
{
|
{
|
||||||
Log_WarningPrintf("Duplicate code '%.*s'", static_cast<int>(code.size()), code.data());
|
Log_WarningPrintf("Duplicate code '%.*s'", static_cast<int>(code.size()), code.data());
|
||||||
|
|
|
@ -285,7 +285,7 @@ bool GameList::PopulateEntryFromPath(const std::string& path, Entry* entry)
|
||||||
|
|
||||||
bool GameList::GetGameListEntryFromCache(const std::string& path, Entry* entry)
|
bool GameList::GetGameListEntryFromCache(const std::string& path, Entry* entry)
|
||||||
{
|
{
|
||||||
auto iter = UnorderedStringMapFind(s_cache_map, path);
|
auto iter = s_cache_map.find(path);
|
||||||
if (iter == s_cache_map.end())
|
if (iter == s_cache_map.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -333,7 +333,7 @@ bool GameList::LoadEntriesFromCache(ByteStream* stream)
|
||||||
ge.type = static_cast<EntryType>(type);
|
ge.type = static_cast<EntryType>(type);
|
||||||
ge.compatibility = static_cast<GameDatabase::CompatibilityRating>(compatibility_rating);
|
ge.compatibility = static_cast<GameDatabase::CompatibilityRating>(compatibility_rating);
|
||||||
|
|
||||||
auto iter = UnorderedStringMapFind(s_cache_map, ge.path);
|
auto iter = s_cache_map.find(ge.path);
|
||||||
if (iter != s_cache_map.end())
|
if (iter != s_cache_map.end())
|
||||||
iter->second = std::move(ge);
|
iter->second = std::move(ge);
|
||||||
else
|
else
|
||||||
|
@ -512,7 +512,7 @@ bool GameList::AddFileFromCache(const std::string& path, std::time_t timestamp,
|
||||||
if (!GetGameListEntryFromCache(path, &entry) || entry.last_modified_time != timestamp)
|
if (!GetGameListEntryFromCache(path, &entry) || entry.last_modified_time != timestamp)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto iter = UnorderedStringMapFind(played_time_map, entry.serial);
|
auto iter = played_time_map.find(entry.serial);
|
||||||
if (iter != played_time_map.end())
|
if (iter != played_time_map.end())
|
||||||
{
|
{
|
||||||
entry.last_played_time = iter->second.last_played_time;
|
entry.last_played_time = iter->second.last_played_time;
|
||||||
|
@ -544,7 +544,7 @@ bool GameList::ScanFile(std::string path, std::time_t timestamp, std::unique_loc
|
||||||
Log_WarningPrintf("Failed to write entry '%s' to cache", entry.path.c_str());
|
Log_WarningPrintf("Failed to write entry '%s' to cache", entry.path.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
auto iter = UnorderedStringMapFind(played_time_map, entry.serial);
|
auto iter = played_time_map.find(entry.serial);
|
||||||
if (iter != played_time_map.end())
|
if (iter != played_time_map.end())
|
||||||
{
|
{
|
||||||
entry.last_played_time = iter->second.last_played_time;
|
entry.last_played_time = iter->second.last_played_time;
|
||||||
|
@ -821,7 +821,7 @@ GameList::PlayedTimeMap GameList::LoadPlayedTimeMap(const std::string& path)
|
||||||
if (!ParsePlayedTimeLine(line, serial, entry))
|
if (!ParsePlayedTimeLine(line, serial, entry))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (UnorderedStringMapFind(ret, serial) != ret.end())
|
if (ret.find(serial) != ret.end())
|
||||||
{
|
{
|
||||||
Log_WarningPrintf("Duplicate entry: '%s'", serial.c_str());
|
Log_WarningPrintf("Duplicate entry: '%s'", serial.c_str());
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -44,12 +44,12 @@ std::pair<const char*, u32> Host::LookupTranslationString(const std::string_view
|
||||||
}
|
}
|
||||||
|
|
||||||
s_translation_string_mutex.lock_shared();
|
s_translation_string_mutex.lock_shared();
|
||||||
ctx_it = UnorderedStringMapFind(s_translation_string_map, context);
|
ctx_it = s_translation_string_map.find(context);
|
||||||
|
|
||||||
if (UNLIKELY(ctx_it == s_translation_string_map.end()))
|
if (UNLIKELY(ctx_it == s_translation_string_map.end()))
|
||||||
goto add_string;
|
goto add_string;
|
||||||
|
|
||||||
msg_it = UnorderedStringMapFind(ctx_it->second, msg);
|
msg_it = ctx_it->second.find(msg);
|
||||||
if (UNLIKELY(msg_it == ctx_it->second.end()))
|
if (UNLIKELY(msg_it == ctx_it->second.end()))
|
||||||
goto add_string;
|
goto add_string;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue