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
21 map<key,pair<list<string>,list<watcher>>
22 void watcher (key, options, appended?)
24 NOTE: The key is always UPPERCASE internally. Keys are converted
25 automagically to uppercase.
36 typedef std::string t_value;
37 typedef std::list<t_value> t_value_list;
39 typedef void (*t_watcher)
40 (std::string key, t_value_list vals, bool appended);
42 typedef std::list<t_watcher> t_watcher_list;
43 typedef std::pair<t_value_list, t_watcher_list> t_option_values;
45 typedef std::map<std::string, t_option_values> t_options_db;
49 t_options_db options_db;
50 std::string config_filename;
53 BotConfig (std::string); // sets config_filename but DOES NOT read
56 bool read_config (); // true if read successfully. This also clears
58 bool write_config (); // true if written succesfully
61 t_option_values get_option_values (std::string key);
66 void set_option_value (std::string key, t_value_list values,
69 void set_option_value (std::string key, t_value value, bool append);
71 std::string set_config_file (std::string new_filename); // returns
75 bool add_watcher (std::string key, t_watcher new_watcher); // t if key
79 bool clear_watchers (std::string key); // t if key exists, f
82 // Static Procedures (these are for convinience)
83 t_value_list get_option_value_list (t_option_values v)
86 t_watcher_list get_option_watcher_list (t_option_values v)