]> Dogcows Code - chaz/yoink/blobdiff - src/Moof/Settings.cc
considerable refactoring
[chaz/yoink] / src / Moof / Settings.cc
index d13302d729234f2f7c6aa5710646dae82cf8a53b..624179ce36998c16efed54b1b75414f97c7d28b7 100644 (file)
@@ -44,9 +44,16 @@ Settings::Settings(int argc, char* argv[])
 }
 
 
+Settings& Settings::getInstance()
+{
+       static Settings settings;
+       return settings;
+}
+
+
 void Settings::parseArgs(int argc, char* argv[])
 {
-       for (int i = 1; i < argc; i++)
+       for (int i = 1; i < argc; ++i)
        {
                char* where = strchr(argv[i], (int)'=');
 
@@ -62,14 +69,14 @@ void Settings::parseArgs(int argc, char* argv[])
 
                        try
                        {
-                               SerializablePtr value(deserializer.deserialize());
+                               SerializableP 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] = SerializablePtr(new SerializableString(stringValue));
+                               map_[key] = SerializableP(new SerializableBasic<Serializable::String>(stringValue));
                        }
                }
        }
@@ -91,7 +98,7 @@ void Settings::loadFromFiles(const std::vector<std::string>& filePaths,
 
        char* home = getenv("HOME");
 
-       for (it = filePaths.begin(); it != filePaths.end(); it++)
+       for (it = filePaths.begin(); it != filePaths.end(); ++it)
        {
                std::string path = *it;
 
@@ -100,13 +107,13 @@ void Settings::loadFromFiles(const std::vector<std::string>& filePaths,
                        boost::replace_first(path, "$HOME", home);
                }
 
-               Deserializer deserializer(*it, true);
-
-               std::cout << "Looking for a config file at " << path << std::endl;
                try
                {
-                       SerializablePtr obj = deserializer.deserialize();
-                       std::map<std::string,SerializablePtr> map;
+                       Deserializer deserializer(*it, true);
+
+                       SerializableP obj = deserializer.deserialize();
+                       Serializable::Map map;
+
                        if (obj && obj->get(map))
                        {
                                if (!precedence)
This page took 0.018579 seconds and 4 git commands to generate.