#include <cstdlib> // getenv
-#include "Settings.hh"
+#include "log.hh"
+#include "settings.hh"
-namespace Mf {
+namespace moof {
-Settings::~Settings()
+settings::settings(int argc, char* argv[], const std::string& path)
+{
+ script_.import_base_library();
+ log::import(script_);
+
+ parse_args(argc, argv);
+ load_files(path);
+}
+
+settings::~settings()
{
save();
}
-void Settings::parseArgs(int argc, char* argv[])
+void settings::parse_args(int argc, char* argv[])
{
for (int i = 1; i < argc; ++i)
{
- if (mScript.doString(argv[i]) != Script::SUCCESS)
+ if (script_.do_string(argv[i]) != script::success)
{
std::string str;
- mScript[-1].get(str);
- logWarning << "invalid option: " << argv[i]
+ script_[-1].get(str);
+ log_warning << "invalid option: " << argv[i]
<< ": " << str << std::endl;
- mScript.clearStack();
+ script_.clear_stack();
}
}
}
-void Settings::loadFromFiles(const std::string& path)
+void settings::load_files(const std::string& path)
{
std::vector<std::string> paths;
boost::split(paths, path, boost::is_any_of(":"));
- loadFromFiles(paths);
+ load_files(paths);
}
-void Settings::loadFromFiles(const std::vector<std::string>& path)
+void settings::load_files(const std::vector<std::string>& path)
{
std::vector<std::string> copy(path);
std::vector<std::string>::iterator it;
{
boost::replace_all(*it, "$HOME", home);
- //Mf::logDebug("Copying global settings...");
+ //logDebug("Copying global settings...");
//mUserFile = *it;
- //mGlobals.pushCopy();
- //mScript.set("globals", Script::REGISTRY);
+ //mGlobals.push_copy();
+ //script_.set("globals", script::registry_index);
}
- if (mScript.doFile(*it) != Script::SUCCESS)
+ if (script_.do_file(*it) != script::success)
{
std::string str;
- mScript[-1].get(str);
- logWarning(str);
- mScript.clearStack();
+ script_[-1].get(str);
+ log_warning(str);
+ script_.clear_stack();
}
}
}
-void Settings::clear()
+void settings::clear()
{
- mScript.reset();
+ script_.reset();
}
-void Settings::saveAs(const std::string& path)
+void settings::save_as(const std::string& path)
{
mUserFile = path;
save();
}
-void Settings::save() const
+void settings::save() const
{
// TODO saving settings not yet implemented
}
-} // namepsace Mf
+} // namepsace moof