diff options
author | Zdenek Prikryl <zdeny@dhcp-lab-218.englab.brq.redhat.com> | 2009-04-02 11:39:54 +0200 |
---|---|---|
committer | Zdenek Prikryl <zdeny@dhcp-lab-218.englab.brq.redhat.com> | 2009-04-02 11:39:54 +0200 |
commit | f2658049fa50cb8b9898691263d7147217e78218 (patch) | |
tree | 222412d78d7d4d8e52f5ef3a1d6e93c0479c8097 /lib/Plugins/PluginSettings.h | |
parent | 72a763a187a27c3838e87d7a79aeded7a8933ca9 (diff) | |
download | abrt-f2658049fa50cb8b9898691263d7147217e78218.tar.gz abrt-f2658049fa50cb8b9898691263d7147217e78218.tar.xz abrt-f2658049fa50cb8b9898691263d7147217e78218.zip |
added new interface frof settings
Diffstat (limited to 'lib/Plugins/PluginSettings.h')
-rw-r--r-- | lib/Plugins/PluginSettings.h | 41 |
1 files changed, 4 insertions, 37 deletions
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 <fstream> #include <map> @@ -29,7 +29,7 @@ typedef std::map<std::string, std::string> map_settings_t; typedef std::set<std::string> 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_ */ |