Config: Remove recursive layer

This commit is contained in:
MerryMage
2017-10-29 19:17:58 +00:00
parent f612569718
commit c8f970e2b0
13 changed files with 30 additions and 139 deletions

View File

@ -246,51 +246,4 @@ void Section::ClearDirty()
{
m_dirty = false;
}
RecursiveSection::RecursiveSection(LayerType layer, System system, const std::string& name)
: Section(layer, system, name)
{
}
bool RecursiveSection::Exists(const std::string& key) const
{
auto layers_it = Config::GetLayers()->find(LayerType::Meta);
do
{
const Section* layer_section = layers_it->second->GetSection(m_system, m_name);
if (layer_section && layer_section->Exists(key))
{
return true;
}
} while (--layers_it != Config::GetLayers()->end());
return false;
}
bool RecursiveSection::Get(const std::string& key, std::string* value,
const std::string& default_value) const
{
for (auto layer_id : SEARCH_ORDER)
{
auto layers_it = Config::GetLayers()->find(layer_id);
if (layers_it == Config::GetLayers()->end())
continue;
const Section* layer_section = layers_it->second->GetSection(m_system, m_name);
if (layer_section && layer_section->Exists(key))
{
return layer_section->Get(key, value, default_value);
}
}
return Section::Get(key, value, default_value);
}
void RecursiveSection::Set(const std::string& key, const std::string& value)
{
// The RecursiveSection can't set since it is used to recursively get values from the layer
// map.
// It is only a part of the meta layer, and the meta layer isn't allowed to set any values.
_assert_msg_(COMMON, false, "Don't try to set values here!");
}
}