From f2658049fa50cb8b9898691263d7147217e78218 Mon Sep 17 00:00:00 2001 From: Zdenek Prikryl Date: Thu, 2 Apr 2009 11:39:54 +0200 Subject: added new interface frof settings --- lib/Plugins/PluginSettings.h | 41 ++++------------------------------------- 1 file changed, 4 insertions(+), 37 deletions(-) (limited to 'lib/Plugins/PluginSettings.h') diff --git a/lib/Plugins/PluginSettings.h b/lib/Plugins/PluginSettings.h index 31138d05..d331b353 100644 --- a/lib/Plugins/PluginSettings.h +++ b/lib/Plugins/PluginSettings.h @@ -1,5 +1,5 @@ /* - Settings.h - header file for settings functions + PluginSettings.h - header file for plugin settings functions Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com) Copyright (C) 2009 RedHat inc. @@ -19,8 +19,8 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef SETTINGSFUNC_H_ -#define SETTINGSFUNC_H_ +#ifndef PLUGINSETTINGSFUNC_H_ +#define PLUGINSETTINGSFUNC_H_ #include #include @@ -29,7 +29,7 @@ typedef std::map map_settings_t; typedef std::set set_settings_t; -inline void load_settings(const std::string& path, map_settings_t& settings) +inline void plugin_load_settings(const std::string& path, map_settings_t& settings) { std::ifstream fIn; fIn.open(path.c_str()); @@ -84,37 +84,4 @@ inline void load_settings(const std::string& path, map_settings_t& settings) } } -inline void save_settings(const std::string& path, const map_settings_t& settings) -{ - 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 ABRT!" << 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+"'."); - } -} - -inline void parse_settings(const std::string& pLine, set_settings_t& settings) -{ - std::string::size_type ii_old = 0, ii_new = 0; - ii_new = pLine.find(","); - while (ii_new != std::string::npos) - { - settings.insert(pLine.substr(ii_old, ii_new - ii_old)); - ii_old = ii_new + 1; - ii_new = pLine.find(",",ii_old); - } - settings.insert(pLine.substr(ii_old)); -} - #endif /* SETTINGSFUNC_H_ */ -- cgit