#include <boost/algorithm/string.hpp>
-#include "settings.hh"
+#include "Settings.hh"
-namespace dc {
+namespace Mf {
-settings::settings(int argc, char* argv[])
+Settings::Settings(int argc, char* argv[])
{
parseArgs(argc, argv);
}
-void settings::parseArgs(int argc, char* argv[])
+void Settings::parseArgs(int argc, char* argv[])
{
for (int i = 1; i < argc; i++)
{
std::stringstream stream;
stream << stringValue << std::endl;
- deserializer in(stream);
+ Deserializer deserializer(stream);
try
{
- serializable_ptr value(in.deserialize());
- map[key] = value;
+ SerializablePtr value(deserializer.deserialize());
+ map_[key] = value;
}
catch (std::exception e)
{
// it doesn't deserialize to anything we know, so just store it
// as a string
- map[key] = serializable_ptr(new wrapped_string(stringValue));
+ map_[key] = SerializablePtr(new SerializableString(stringValue));
}
}
}
}
-void settings::loadFromFile(const std::string& filePath, bool precedence)
+void Settings::loadFromFile(const std::string& filePath, bool precedence)
{
std::vector<std::string> paths;
boost::split(paths, filePath, boost::is_any_of(":"));
loadFromFiles(paths, precedence);
}
-void settings::loadFromFiles(const std::vector<std::string>& filePaths,
+void Settings::loadFromFiles(const std::vector<std::string>& filePaths,
bool precedence)
{
std::vector<std::string>::const_iterator it;
boost::replace_first(path, "$HOME", home);
}
- deserializer in(*it, true);
+ Deserializer deserializer(*it, true);
std::cout << "Looking for a config file at " << path << std::endl;
try
{
- serializable_ptr obj = in.deserialize();
- std::map<std::string,serializable_ptr> dict;
- if (obj && obj->get(dict))
+ SerializablePtr obj = deserializer.deserialize();
+ std::map<std::string,SerializablePtr> map;
+ if (obj && obj->get(map))
{
if (!precedence)
{
- map.insert(dict.begin(), dict.end());
+ map_.insert(map.begin(), map.end());
}
else
{
- dict.insert(map.begin(), map.end());
- map = dict;
+ map.insert(map_.begin(), map_.end());
+ map_ = map;
}
}
}
- catch (deserializer::exception e)
+ catch (Deserializer::Exception e)
{
std::cerr << "Cannot load settings from " << *it <<
" because an exception was thrown: " << e.what() << std::endl;
}
-} // namepsace dc
+} // namepsace Mf
/** vim: set ts=4 sw=4 tw=80: *************************************************/