diff options
Diffstat (limited to 'src/Core/ConfigManager.cpp')
-rw-r--r-- | src/Core/ConfigManager.cpp | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/src/Core/ConfigManager.cpp b/src/Core/ConfigManager.cpp index bd20cc5..51d8647 100644 --- a/src/Core/ConfigManager.cpp +++ b/src/Core/ConfigManager.cpp @@ -46,7 +46,7 @@ void ConfigManager::handleConfigEntry(const ConfigEntry &entry) { } if(!handled) - application->logf(Logger::LOG_WARNING, "Invalid config option '%s'.", entry[entry.getSize()-1].getKey().c_str()); + application->logf(Logger::LOG_WARNING, "Invalid config option '%s'.", entry[entry.getSize()-1].getKey().extract().c_str()); } bool ConfigManager::loadFile(const std::string &filename) { @@ -55,30 +55,33 @@ bool ConfigManager::loadFile(const std::string &filename) { std::ifstream file(filename.c_str()); ConfigEntry entry; - std::string line, input; - char delim; - std::vector<std::string> splitLine, lastConfigLine; + UnicodeString line, input; + UChar delim; + std::vector<UnicodeString> splitLine, lastConfigLine; if(!file.good()) return false; - while(!(file.eof() && line.empty() && input.empty())) { - while(input.empty() && !file.eof()) - std::getline(file, input); + while(!(file.eof() && line.isEmpty() && input.isEmpty())) { + while(input.isEmpty() && !file.eof()) { + std::string tmp; + std::getline(file, tmp); + input = tmp.c_str(); + } - if(input.empty()) + if(input.isEmpty()) break; - size_t pos = input.find_first_of("#{}"); - if(pos == std::string::npos) { + boost::int32_t pos = input.findFirstOf("#{}"); + if(pos < 0) { line += input; delim = '\n'; - input.clear(); + input.remove(); } else { line += input.substr(0, pos); delim = input[pos]; - input = input.substr(pos+1); + input.remove(0, pos+1); } if(!Tokenizer::tokenize(line, splitLine)) { @@ -87,8 +90,6 @@ bool ConfigManager::loadFile(const std::string &filename) { } if(!splitLine.empty()) { - pos = line.find_first_of(" \t"); - entry.push(splitLine); handleConfigEntry(entry); entry.pop(); @@ -98,7 +99,7 @@ bool ConfigManager::loadFile(const std::string &filename) { switch(delim) { case '#': - input.clear(); + input.remove(); break; case '{': entry.push(lastConfigLine); @@ -107,7 +108,7 @@ bool ConfigManager::loadFile(const std::string &filename) { entry.pop(); } - line.clear(); + line.remove(); } // TODO Depth check |