[project @ 2005-01-12 06:01:01 by unknown_lamer]
authorunknown_lamer <unknown>
Wed, 12 Jan 2005 06:01:01 +0000 (06:01 +0000)
committerunknown_lamer <unknown>
Wed, 12 Jan 2005 06:01:01 +0000 (06:01 +0000)
BotConfig fully implemented, set_config_value that takes one t_value
instead of a t_value_list has been added for convinience

ChangeLog
source/BotConfig.C
source/BotConfig.H

index 48c763a..42c2c04 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2005-01-12  Clinton Ebadi  <clinton@unknownlamer.org>
 
+       * source/BotConfig.C (read_config): Made to use set_option_value
+       instead of manipulating options_db directly
+
+       * source/BotConfig.H (class BotConfig): Add set_option_value that
+       takes a t_value instead of t_value_list (most uss of
+       set_option_value will be to add a single value so this is very useful)
+
+       * source/BotConfig.C (set_option_value): Implemented
+
        * source/UserList.C: Made to work with new Utils/StringTokenizer names
 
        * source/UserCommands.C: Made to work with new
index 82a8035..2fe386c 100644 (file)
@@ -56,14 +56,11 @@ BotConfig::read_config ()
          continue;
        }
       
-      // This is broken because overwrites existing values
       StringTokenizer st (current_line);
       std::string command = Utils::to_upper (Utils::trim_str(st.next_token('=')));
       StringTokenizer params (Utils::trim_str (st.next_token('=')));
 
-      options_db[command] = t_option_values (t_value_list (), 
-                                            t_watcher_list ());
-      options_db[command].first.push_back (params.rest ());
+      set_option_value (command, params.rest (), true);
     
     }
   return true;
@@ -130,6 +127,7 @@ BotConfig::set_option_value (std::string key, t_value_list values,
                                  bool append)
 {
   t_options_db::iterator cf_iter = options_db.find (key);
+  key = Utils::to_upper (key); // keys are case insensitive
 
   if (cf_iter != options_db.end ())
     {
@@ -151,6 +149,15 @@ BotConfig::set_option_value (std::string key, t_value_list values,
                 run_fun_ (key, values, append));
 }
 
+void
+BotConfig::set_option_value (std::string key, t_value value, bool append)
+{
+  t_value_list value_list = t_value_list ();
+  value_list.push_front (value);
+
+  set_option_value (key, value_list, append);
+}
+
 bool
 BotConfig::add_watcher (std::string key, t_watcher new_watcher)
 {
index a65ca4c..596d9c1 100644 (file)
@@ -61,7 +61,8 @@ public:
   // Setters
   void set_option_value (std::string key, t_value_list values, 
                         bool append);
-  
+  // Convinience proc
+  void set_option_value (std::string key, t_value value, bool append);
 
   std::string set_config_file (std::string new_filename); // returns
                                                          // old