]> Dogcows Code - chaz/yoink/blobdiff - src/moof/settings.hh
the massive refactoring effort
[chaz/yoink] / src / moof / settings.hh
similarity index 53%
rename from src/Moof/Settings.hh
rename to src/moof/settings.hh
index 192e2a764254ba61a4b476a23c51c989422c1db8..4807eeb16d8745ddba02c0b2762172586cc7230f 100644 (file)
@@ -13,7 +13,7 @@
 #define _MOOF_SETTINGS_HH_
 
 /**
- * @file Settings.hh
+ * \file settings.hh
  * Load, store, save program settings.
  */
 
 
 #include <boost/algorithm/string.hpp>
 
-#include <Moof/Log.hh>
-#include <Moof/Script.hh>
+#include <moof/script.hh>
 
 
-namespace Mf {
+namespace moof {
 
 
-class Settings
+class settings
 {
 public:
 
-       Settings(int argc, char* argv[], const std::string& path)
-       {
-               mScript.importBaseLibrary();
-               importLogFunctions(mScript);
+       settings(int argc, char* argv[], const std::string& path);
 
-               parseArgs(argc, argv);
-               loadFromFiles(path);
-       }
+       ~settings();
 
-       ~Settings();
+       void parse_args(int argc, char* argv[]);
 
-       void parseArgs(int argc, char* argv[]);
+       void load_files(const std::string& path);
+       void load_files(const std::vector<std::string>& path);
 
-       void loadFromFiles(const std::string& path);
-       void loadFromFiles(const std::vector<std::string>& path);
 
-       void clear();           // remove all settings
+       /**
+        * Remove all settings.
+        */
+       void clear();
 
-       void saveAs(const std::string& path);
+       void save_as(const std::string& path);
        void save() const;
 
+
+       /**
+        * Get a setting by name.
+        * \param key The name of the setting.
+        * \param value A reference to the variable to store the setting.
+        * \return True if the setting exists, false otherwise.
+        */
        template <class T>
        bool get(const std::string& key, T& value) const;
 
+
 private:
 
-       mutable Script  mScript;
+       mutable script  script_;
 
        std::string             mUserFile;
 };
 
 
 template <class T>
-bool Settings::get(const std::string& key, T& value) const
+bool settings::get(const std::string& key, T& value) const
 {
-       Script::Slot top = mScript[-1];
-       Script::Slot globals = mScript.globals();
+       script::slot top = script_[-1];
+       script::slot globals = script_.globals();
 
        std::vector<std::string> fields;
        boost::split(fields, key, boost::is_any_of("."));
 
-       globals.pushCopy();
+       globals.push_copy();
 
        std::vector<std::string>::iterator it;
        for (it = fields.begin(); it != fields.end(); ++it)
        {
-               if (top.isTable())
+               if (top.is_table())
                {
-                       top.pushField(*it);
+                       top.push_field(*it);
                }
                else
                {
-                       mScript.clearStack();
+                       script_.clear_stack();
                        return false;
                }
        }
 
        bool got = top.get(value);
-       mScript.clearStack();
+       script_.clear_stack();
        return got;
 }
 
 
-} // namepsace Mf
+} // namepsace moof
 
 #endif // _MOOF_SETTINGS_HH_
 
This page took 0.023583 seconds and 4 git commands to generate.