]> Dogcows Code - chaz/yoink/blobdiff - src/Moof/Settings.hh
finally fixed broken main loop
[chaz/yoink] / src / Moof / Settings.hh
index 9b3e0cb27146bbc3a1a99c91a8c76f56dad3d8d0..6cd86291b64bb1be6ed959b7b4d61745495c08e6 100644 (file)
@@ -50,14 +50,14 @@ class Settings
 {
 public:
 
-       Settings() :
-               mGlobals(mScript.getGlobalTable()),
-               mTop(mScript[-1])
+       Settings()
        {
                mScript.importBaseLibrary();
-               importLogPrintFunction(mScript);
+               importLogFunctions(mScript);
        }
 
+       ~Settings();
+
        // get global instance
        static Settings& getInstance();
 
@@ -68,30 +68,37 @@ public:
 
        void clear();           // remove all settings
 
+       void saveAs(const std::string& filePath);
+       void save() const;
+
        template <typename T>
-       bool get(const std::string& key, T& value);
+       bool get(const std::string& key, T& value) const;
 
 private:
 
-       Script                  mScript;
-       Script::Value   mGlobals, mTop;
+       mutable Script  mScript;
+
+       std::string             mUserFile;
 };
 
 
 template <typename T>
-bool Settings::get(const std::string& key, T& value)
+bool Settings::get(const std::string& key, T& value) const
 {
+       Script::Slot top = mScript[-1];
+       Script::Slot globals = mScript.getGlobalTable();
+
        std::vector<std::string> fields;
        boost::split(fields, key, boost::is_any_of("."));
 
-       mGlobals.pushCopy();
+       globals.pushCopy();
 
        std::vector<std::string>::iterator it;
        for (it = fields.begin(); it != fields.end(); ++it)
        {
-               if (mTop.isTable())
+               if (top.isTable())
                {
-                       mTop.pushField(*it);
+                       top.pushField(*it);
                }
                else
                {
@@ -100,7 +107,7 @@ bool Settings::get(const std::string& key, T& value)
                }
        }
 
-       bool got = mTop.get(value);
+       bool got = top.get(value);
        mScript.clear();
        return got;
 }
This page took 0.023156 seconds and 4 git commands to generate.