|
|
|
@ -3,10 +3,9 @@
|
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
|
|
#include <components/debug/debuglog.hpp>
|
|
|
|
|
#include <components/misc/stringops.hpp>
|
|
|
|
|
|
|
|
|
|
#include <boost/filesystem/fstream.hpp>
|
|
|
|
|
#include <boost/algorithm/string.hpp>
|
|
|
|
|
#include <boost/lexical_cast.hpp>
|
|
|
|
|
|
|
|
|
|
void Settings::SettingsFileParser::loadSettingsFile(const std::string& file, CategorySettingValueMap& settings)
|
|
|
|
|
{
|
|
|
|
@ -36,7 +35,7 @@ void Settings::SettingsFileParser::loadSettingsFile(const std::string& file, Cat
|
|
|
|
|
fail("unterminated category");
|
|
|
|
|
|
|
|
|
|
currentCategory = line.substr(i+1, end - (i+1));
|
|
|
|
|
boost::algorithm::trim(currentCategory);
|
|
|
|
|
Misc::StringUtils::trim(currentCategory);
|
|
|
|
|
i = end+1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -51,11 +50,11 @@ void Settings::SettingsFileParser::loadSettingsFile(const std::string& file, Cat
|
|
|
|
|
fail("unterminated setting name");
|
|
|
|
|
|
|
|
|
|
std::string setting = line.substr(i, (settingEnd-i));
|
|
|
|
|
boost::algorithm::trim(setting);
|
|
|
|
|
Misc::StringUtils::trim(setting);
|
|
|
|
|
|
|
|
|
|
size_t valueBegin = settingEnd+1;
|
|
|
|
|
std::string value = line.substr(valueBegin);
|
|
|
|
|
boost::algorithm::trim(value);
|
|
|
|
|
Misc::StringUtils::trim(value);
|
|
|
|
|
|
|
|
|
|
if (settings.insert(std::make_pair(std::make_pair(currentCategory, setting), value)).second == false)
|
|
|
|
|
fail(std::string("duplicate setting: [" + currentCategory + "] " + setting));
|
|
|
|
@ -142,7 +141,7 @@ void Settings::SettingsFileParser::saveSettingsFile(const std::string& file, con
|
|
|
|
|
|
|
|
|
|
// Update the current category.
|
|
|
|
|
currentCategory = line.substr(i+1, end - (i+1));
|
|
|
|
|
boost::algorithm::trim(currentCategory);
|
|
|
|
|
Misc::StringUtils::trim(currentCategory);
|
|
|
|
|
|
|
|
|
|
// Write the (new) current category to the file.
|
|
|
|
|
ostream << "[" << currentCategory << "]" << std::endl;
|
|
|
|
@ -176,12 +175,12 @@ void Settings::SettingsFileParser::saveSettingsFile(const std::string& file, con
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
std::string setting = line.substr(i, (settingEnd-i));
|
|
|
|
|
boost::algorithm::trim(setting);
|
|
|
|
|
Misc::StringUtils::trim(setting);
|
|
|
|
|
|
|
|
|
|
// Get the existing value so we can see if we've changed it.
|
|
|
|
|
size_t valueBegin = settingEnd+1;
|
|
|
|
|
std::string value = line.substr(valueBegin);
|
|
|
|
|
boost::algorithm::trim(value);
|
|
|
|
|
Misc::StringUtils::trim(value);
|
|
|
|
|
|
|
|
|
|
// Construct the setting map key to determine whether the setting has already been
|
|
|
|
|
// written to the file.
|
|
|
|
|