// BotConfig.H -*- C++ -*- // Copyright (C) 2004 Clinton Ebadi // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. /* Config Database: map,list> void watcher (key, options, appended?) */ #include #include #include class BotConfig { public: typedef std::string t_value; typedef std::list t_value_list; typedef void (*t_watcher) (std::string key, t_value_list vals, bool appended); typedef std::list t_watcher_list; typedef std::pair t_option_values; typedef std::map t_options_db; private: t_options_db options_db; std::string config_filename; public: BotConfig (std::string); bool read_config (); // true if read successfully bool write_config (); // true if written succesfully // Getters t_option_values get_option_values (std::string key); // Setters void set_option_value (std::string key, t_value_list values, bool append); std::string set_config_file (std::string new_filename); // returns // old // filename bool add_watcher (std::string key, t_watcher new_watcher); // t if key // exists, // f // otherwise bool clear_watchers (std::string key); // t if key exists, f // otherwise // Static Procedures (these are for convinience) t_value_list get_option_value_list (t_option_values v) { return v.first; } t_watcher_list get_option_watcher_list (t_option_values v) { return v.second; } };