diff --git a/Source/Core/Common/Config/Layer.cpp b/Source/Core/Common/Config/Layer.cpp index d4f9e7c633..5a5c4b5f59 100644 --- a/Source/Core/Common/Config/Layer.cpp +++ b/Source/Core/Common/Config/Layer.cpp @@ -98,6 +98,18 @@ void Layer::DeleteAllKeys() } } +Section Layer::GetSection(System system, const std::string& section) +{ + return Section{m_map.lower_bound(ConfigLocation{system, section, ""}), + m_map.lower_bound(ConfigLocation{system, section + '\001', ""})}; +} + +ConstSection Layer::GetSection(System system, const std::string& section) const +{ + return ConstSection{m_map.lower_bound(ConfigLocation{system, section, ""}), + m_map.lower_bound(ConfigLocation{system, section + '\001', ""})}; +} + void Layer::Load() { if (m_loader) diff --git a/Source/Core/Common/Config/Layer.h b/Source/Core/Common/Config/Layer.h index eb2a6bafca..8e56ae308a 100644 --- a/Source/Core/Common/Config/Layer.h +++ b/Source/Core/Common/Config/Layer.h @@ -62,6 +62,30 @@ private: const LayerType m_layer; }; +class Section +{ +public: + using iterator = LayerMap::iterator; + Section(iterator begin_, iterator end_) : m_begin(begin_), m_end(end_) {} + iterator begin() const { return m_begin; } + iterator end() const { return m_end; } +private: + iterator m_begin; + iterator m_end; +}; + +class ConstSection +{ +public: + using iterator = LayerMap::const_iterator; + ConstSection(iterator begin_, iterator end_) : m_begin(begin_), m_end(end_) {} + iterator begin() const { return m_begin; } + iterator end() const { return m_end; } +private: + iterator m_begin; + iterator m_end; +}; + class Layer { public: @@ -106,6 +130,9 @@ public: current_value = new_value; } + Section GetSection(System system, const std::string& section); + ConstSection GetSection(System system, const std::string& section) const; + // Explicit load and save of layers void Load(); void Save();