From 8b54ac225b834b172ee46371200d8addbde08021 Mon Sep 17 00:00:00 2001 From: Michael Maltese Date: Sun, 9 Jul 2017 16:17:36 -0700 Subject: Merge Core/Config/Config.h into Common/Config/Config.h Allows code in Common to take advantage of the layered config logic. --- Source/Core/Common/Config/Config.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'Source/Core/Common/Config/Config.cpp') diff --git a/Source/Core/Common/Config/Config.cpp b/Source/Core/Common/Config/Config.cpp index 27f0389ea8..285db95f28 100644 --- a/Source/Core/Common/Config/Config.cpp +++ b/Source/Core/Common/Config/Config.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "Common/Assert.h" #include "Common/Config/Config.h" @@ -144,4 +145,34 @@ const std::string& GetLayerName(LayerType layer) }; return layer_to_name.at(layer); } + +bool ConfigLocation::operator==(const ConfigLocation& other) const +{ + return std::tie(system, section, key) == std::tie(other.system, other.section, other.key); +} + +bool ConfigLocation::operator!=(const ConfigLocation& other) const +{ + return !(*this == other); +} + +bool ConfigLocation::operator<(const ConfigLocation& other) const +{ + return std::tie(system, section, key) < std::tie(other.system, other.section, other.key); +} + +LayerType GetActiveLayerForConfig(const ConfigLocation& config) +{ + for (auto layer : SEARCH_ORDER) + { + if (!LayerExists(layer)) + continue; + + if (GetLayer(layer)->Exists(config.system, config.section, config.key)) + return layer; + } + + // If config is not present in any layer, base layer is considered active. + return LayerType::Base; +} } -- cgit v1.2.3