diff options
Diffstat (limited to 'src/Common/ConfigManager.cpp')
-rw-r--r-- | src/Common/ConfigManager.cpp | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/Common/ConfigManager.cpp b/src/Common/ConfigManager.cpp index a7270e2..bfb38a0 100644 --- a/src/Common/ConfigManager.cpp +++ b/src/Common/ConfigManager.cpp @@ -18,6 +18,7 @@ */ #include "ConfigManager.h" +#include "ConfigEntry.h" #include "Configurable.h" #include "Logger.h" #include "Util.h" @@ -39,7 +40,7 @@ bool ConfigManager::Compare::operator() (const Configurable *c1, const Configura } -void ConfigManager::handleConfigEntry(const std::vector<std::vector<std::string> > &entry) { +void ConfigManager::handleConfigEntry(const ConfigEntry &entry) { bool handled = false; for(std::set<Configurable*>::iterator c = configurables.begin(); c != configurables.end(); ++c) { @@ -48,13 +49,13 @@ void ConfigManager::handleConfigEntry(const std::vector<std::vector<std::string> } if(!handled) - Logger::logf(Logger::WARNING, "Invalid config option '%s'.", entry.back().front().c_str()); + Logger::logf(Logger::WARNING, "Invalid config option '%s'.", entry[0].getKey().c_str()); } bool ConfigManager::loadFile(const std::string &filename, bool finish) { std::ifstream file(filename.c_str()); - std::vector<std::vector<std::string> > section; - std::vector<std::string> entry; + ConfigEntry entry; + std::vector<std::string> subEntry; std::string line; if(!file.good()) @@ -91,27 +92,27 @@ bool ConfigManager::loadFile(const std::string &filename, bool finish) { if(!line.empty()) { pos = line.find_first_of(" \t"); - entry.clear(); + subEntry.clear(); if(pos == std::string::npos) { - entry.push_back(line); + subEntry.push_back(line); } else { - entry.push_back(line.substr(0, pos)); - entry.push_back(Util::trim(line.substr(pos))); + subEntry.push_back(line.substr(0, pos)); + subEntry.push_back(Util::trim(line.substr(pos))); } - section.push_back(entry); - handleConfigEntry(section); - section.pop_back(); + entry.push(subEntry); + handleConfigEntry(entry); + entry.pop(); } switch(bracket) { case '{': - section.push_back(entry); + entry.push(subEntry); break; case '}': - section.pop_back(); + entry.pop(); } line = nextLine; |