summaryrefslogtreecommitdiffstats
path: root/src/Core/ConfigManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Core/ConfigManager.cpp')
-rw-r--r--src/Core/ConfigManager.cpp40
1 files changed, 13 insertions, 27 deletions
diff --git a/src/Core/ConfigManager.cpp b/src/Core/ConfigManager.cpp
index fdbc93f..1cb4aa0 100644
--- a/src/Core/ConfigManager.cpp
+++ b/src/Core/ConfigManager.cpp
@@ -38,28 +38,16 @@ bool ConfigManager::Compare::operator() (const Configurable *c1, const Configura
return c1 < c2;
}
-
-void ConfigManager::handleConfigEntry(const ConfigEntry &entry) {
- bool handled = false;
-
- for(std::set<Configurable*, Compare>::iterator c = configurables.begin(); c != configurables.end(); ++c) {
- if((*c)->handleConfigEntry(entry, handled))
- handled = true;
- }
-
- if(!handled)
- application->logf(Logger::LOG_WARNING, "Invalid config option '%s'.", entry[entry.getSize()-1].getKey().toLocale().c_str());
-}
-
bool ConfigManager::loadFile(const std::string &filename) {
- if(finished)
+ if(configured)
return false;
std::ifstream file(filename.c_str());
- ConfigEntry entry;
+ ConfigEntry *currentEntry = this;
+ ConfigEntry *lastEntry = this;
String line, input;
UChar delim;
- std::vector<String> splitLine, lastConfigLine;
+ std::vector<String> splitLine;
if(!file.good())
return false;
@@ -90,11 +78,9 @@ bool ConfigManager::loadFile(const std::string &filename) {
}
if(!splitLine.empty()) {
- entry.push(splitLine);
- handleConfigEntry(entry);
- entry.pop();
-
- lastConfigLine = splitLine;
+ boost::shared_ptr<ConfigEntry> entry(new ConfigEntry(currentEntry, std::vector<String>(splitLine.begin()+1, splitLine.end())));
+ currentEntry->addChild(splitLine.front(), entry);
+ lastEntry = entry.get();
}
switch(delim) {
@@ -102,10 +88,10 @@ bool ConfigManager::loadFile(const std::string &filename) {
input.remove();
break;
case '{':
- entry.push(lastConfigLine);
+ currentEntry = lastEntry;
break;
case '}':
- entry.pop();
+ lastEntry = currentEntry = currentEntry->getParent();
}
line.remove();
@@ -116,14 +102,14 @@ bool ConfigManager::loadFile(const std::string &filename) {
return true;
}
-void ConfigManager::finish() {
- if(finished)
+void ConfigManager::configure() {
+ if(configured)
return;
for(std::set<Configurable*, Compare>::iterator c = configurables.begin(); c != configurables.end(); ++c)
- (*c)->configFinished();
+ (*c)->configure();
- finished = true;
+ configured = true;
}
}