1 // BotConfig.H -*- C++ -*-
2 // Copyright (C) 2004,2005 Clinton Ebadi
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 map<key,pair<list<string>,list<watcher>>
21 void watcher (key, options, appended?)
23 NOTE: The key is always UPPERCASE internally. Keys are converted
24 automagically to uppercase by the anything that
35 typedef std::string t_value;
36 typedef std::list<t_value> t_value_list;
38 typedef void (*t_watcher) (std::string key, t_value_list vals, bool appended);
40 typedef std::list<t_watcher> t_watcher_list;
41 typedef std::pair<t_value_list, t_watcher_list> t_option_values;
43 typedef std::map<std::string, t_option_values> t_options_db;
47 t_options_db options_db;
48 std::string config_filename;
51 BotConfig (std::string); // sets config_filename but DOES NOT read config!
53 bool read_config (); // true if read successfully. This also clears the option_db.
54 bool write_config (); // true if written succesfully
57 t_option_values get_option_values (std::string key);
62 void set_option_value (std::string key, t_value_list values,
65 void set_option_value (std::string key, t_value value, bool append);
67 std::string set_config_file (std::string new_filename); // returns
71 bool add_watcher (std::string key, t_watcher new_watcher); // t if key
75 bool clear_watchers (std::string key); // t if key exists, f
78 // Static Procedures (these are for convinience)
79 t_value_list get_option_value_list (t_option_values v)
82 t_watcher_list get_option_watcher_list (t_option_values v)