]> Dogcows Code - chaz/yoink/blobdiff - src/Moof/Settings.hh
stream-based logging classes
[chaz/yoink] / src / Moof / Settings.hh
index dc29deb3ad260e772348bd8c40abe7e080a271c4..2a2a9267026e5475ddd5c0a1d11433da19767251 100644 (file)
@@ -49,13 +49,17 @@ namespace Mf {
 class Settings
 {
 public:
+
        Settings() :
-               globals_(script_.getGlobalTable()),
-               top_(script_[-1])
+               mGlobals(mScript.getGlobalTable()),
+               mTop(mScript[-1])
        {
-               importLogScript(script_);
+               mScript.importBaseLibrary();
+               importLogPrintFunction(mScript);
        }
 
+       ~Settings();
+
        // get global instance
        static Settings& getInstance();
 
@@ -64,12 +68,20 @@ public:
        void loadFromFile(const std::string& filePath);
        void loadFromFiles(const std::vector<std::string>& filePaths);
 
+       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);
 
 private:
-       Script                  script_;
-       Script::Value   globals_, top_;
+
+       Script                  mScript;
+       Script::Slot    mGlobals, mTop;
+
+       std::string             mUserFile;
 };
 
 
@@ -79,24 +91,24 @@ bool Settings::get(const std::string& key, T& value)
        std::vector<std::string> fields;
        boost::split(fields, key, boost::is_any_of("."));
 
-       globals_.pushCopy();
+       mGlobals.pushCopy();
 
        std::vector<std::string>::iterator it;
        for (it = fields.begin(); it != fields.end(); ++it)
        {
-               if (top_.isTable())
+               if (mTop.isTable())
                {
-                       top_.pushField(*it);
+                       mTop.pushField(*it);
                }
                else
                {
-                       script_.clear();
+                       mScript.clear();
                        return false;
                }
        }
 
-       bool got = top_.get(value);
-       script_.clear();
+       bool got = mTop.get(value);
+       mScript.clear();
        return got;
 }
 
This page took 0.026178 seconds and 4 git commands to generate.