From f8024b8aa0adcb9f3d94885d7be0311d35b8a999 Mon Sep 17 00:00:00 2001 From: Zdenek Prikryl Date: Thu, 5 Feb 2009 13:17:58 +0100 Subject: Added save_settings() function --- lib/MiddleWare/Settings.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'lib/MiddleWare/Settings.cpp') diff --git a/lib/MiddleWare/Settings.cpp b/lib/MiddleWare/Settings.cpp index 627bfc6..413820b 100644 --- a/lib/MiddleWare/Settings.cpp +++ b/lib/MiddleWare/Settings.cpp @@ -80,5 +80,20 @@ void load_settings(const std::string& path, map_settings_t& settings) void save_settings(const std::string& path, const map_settings_t& settings) { - //TODO: write this + map_settings_t::const_iterator it; + std::ofstream fOut; + fOut.open(path.c_str()); + if (fOut.is_open()) + { + fOut << "# !DO NOT EDIT THIS FILE BY HAND. IT IS GENERATED BY CRASHCATCHER!" << std::endl; + for (it = settings.begin(); it != settings.end(); it++) + { + fOut << it->first << " = " << it->second << std::endl << std::endl; + } + fOut.close(); + } + else + { + throw std::string("save_settings(): Cannot write configuration file '"+path+"'."); + } } -- cgit