X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMoof%2FSettings.hh;h=192e2a764254ba61a4b476a23c51c989422c1db8;hp=f7503dd7b8d1f34806b5ccce86a185ababdb3065;hb=4107dd30ca1a4c7d1a5cd6c0999b9afb5adff779;hpb=837bae9f2bf7b25e1d3d2625eeaf39c1d2f48827 diff --git a/src/Moof/Settings.hh b/src/Moof/Settings.hh index f7503dd..192e2a7 100644 --- a/src/Moof/Settings.hh +++ b/src/Moof/Settings.hh @@ -33,10 +33,13 @@ class Settings { public: - Settings() + Settings(int argc, char* argv[], const std::string& path) { mScript.importBaseLibrary(); importLogFunctions(mScript); + + parseArgs(argc, argv); + loadFromFiles(path); } ~Settings(); @@ -51,7 +54,7 @@ public: void saveAs(const std::string& path); void save() const; - template + template bool get(const std::string& key, T& value) const; private: @@ -62,11 +65,11 @@ private: }; -template +template bool Settings::get(const std::string& key, T& value) const { Script::Slot top = mScript[-1]; - Script::Slot globals = mScript.getGlobalTable(); + Script::Slot globals = mScript.globals(); std::vector fields; boost::split(fields, key, boost::is_any_of(".")); @@ -82,20 +85,17 @@ bool Settings::get(const std::string& key, T& value) const } else { - mScript.clear(); + mScript.clearStack(); return false; } } bool got = top.get(value); - mScript.clear(); + mScript.clearStack(); return got; } -extern Settings settings; - - } // namepsace Mf #endif // _MOOF_SETTINGS_HH_