From e1d8490f0654a3da0b900407d80d91d8d0da68c8 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 27 Sep 2009 01:55:44 +0200 Subject: Use libicu to support unicode properly; migrated ConfigManager to UnicodeString --- src/Core/ConfigManager.cpp | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'src/Core/ConfigManager.cpp') 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 splitLine, lastConfigLine; + UnicodeString line, input; + UChar delim; + std::vector 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 -- cgit v1.2.3