Config: Extract layer search order to header

This commit is contained in:
MerryMage 2017-05-18 13:53:52 +01:00
parent 57264022ce
commit 6151bc1714
2 changed files with 9 additions and 8 deletions

View File

@ -4,6 +4,8 @@
#pragma once #pragma once
#include <array>
namespace Config namespace Config
{ {
enum class LayerType enum class LayerType
@ -29,4 +31,10 @@ enum class System
Debugger, Debugger,
UI, UI,
}; };
constexpr std::array<LayerType, 7> SEARCH_ORDER{{
// Skip the meta layer
LayerType::CurrentRun, LayerType::CommandLine, LayerType::Movie, LayerType::Netplay,
LayerType::LocalGame, LayerType::GlobalGame, LayerType::Base,
}};
} }

View File

@ -2,7 +2,6 @@
// Licensed under GPLv2+ // Licensed under GPLv2+
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <array>
#include <cstddef> #include <cstddef>
#include <map> #include <map>
#include <memory> #include <memory>
@ -254,13 +253,7 @@ bool RecursiveSection::Exists(const std::string& key) const
bool RecursiveSection::Get(const std::string& key, std::string* value, bool RecursiveSection::Get(const std::string& key, std::string* value,
const std::string& default_value) const const std::string& default_value) const
{ {
static constexpr std::array<LayerType, 7> search_order = {{ for (auto layer_id : SEARCH_ORDER)
// Skip the meta layer
LayerType::CurrentRun, LayerType::CommandLine, LayerType::Movie, LayerType::Netplay,
LayerType::LocalGame, LayerType::GlobalGame, LayerType::Base,
}};
for (auto layer_id : search_order)
{ {
auto layers_it = Config::GetLayers()->find(layer_id); auto layers_it = Config::GetLayers()->find(layer_id);
if (layers_it == Config::GetLayers()->end()) if (layers_it == Config::GetLayers()->end())