X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMoof%2FSettings.hh;h=9b3e0cb27146bbc3a1a99c91a8c76f56dad3d8d0;hp=dc29deb3ad260e772348bd8c40abe7e080a271c4;hb=e495074443d9fd7bc16137084cf9de3d031b75c4;hpb=ca0f7bdfba63140dca0bd20586d31980f3938eb2 diff --git a/src/Moof/Settings.hh b/src/Moof/Settings.hh index dc29deb..9b3e0cb 100644 --- a/src/Moof/Settings.hh +++ b/src/Moof/Settings.hh @@ -49,11 +49,13 @@ namespace Mf { class Settings { public: + Settings() : - globals_(script_.getGlobalTable()), - top_(script_[-1]) + mGlobals(mScript.getGlobalTable()), + mTop(mScript[-1]) { - importLogScript(script_); + mScript.importBaseLibrary(); + importLogPrintFunction(mScript); } // get global instance @@ -64,12 +66,15 @@ public: void loadFromFile(const std::string& filePath); void loadFromFiles(const std::vector& filePaths); + void clear(); // remove all settings + template bool get(const std::string& key, T& value); private: - Script script_; - Script::Value globals_, top_; + + Script mScript; + Script::Value mGlobals, mTop; }; @@ -79,24 +84,24 @@ bool Settings::get(const std::string& key, T& value) std::vector fields; boost::split(fields, key, boost::is_any_of(".")); - globals_.pushCopy(); + mGlobals.pushCopy(); std::vector::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; }