mail[Wesnoth-commits] r33996 - /trunk/src/config.cpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by guillaume . melquiond on March 21, 2009 - 19:45:
Author: silene
Date: Sat Mar 21 19:45:05 2009
New Revision: 33996

URL: http://svn.gna.org/viewcvs/wesnoth?rev=33996&view=rev
Log:
Cleaned by using config::any_child new fields.

Modified:
    trunk/src/config.cpp

Modified: trunk/src/config.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/config.cpp?rev=33996&r1=33995&r2=33996&view=diff
==============================================================================
--- trunk/src/config.cpp (original)
+++ trunk/src/config.cpp Sat Mar 21 19:45:05 2009
@@ -614,42 +614,37 @@
                }
        }
 
-       const child_list& child_changes = diff.get_children("change_child");
-       child_list::const_iterator i;
-       for(i = child_changes.begin(); i != child_changes.end(); ++i) {
-               const size_t index = 
lexical_cast<size_t>((**i)["index"].str());
-               for(all_children_iterator j = (*i)->ordered_begin(); j != 
(*i)->ordered_end(); ++j) {
-                       const any_child &item = *j;
-
-                       if(item.first->empty()) {
+       foreach (const config &i, diff.child_range("change_child"))
+       {
+               const size_t index = lexical_cast<size_t>(i["index"].str());
+               foreach (const any_child &item, i.all_children_range())
+               {
+                       if (item.key.empty()) {
                                continue;
                        }
 
-                       const child_map::iterator itor = 
children.find(*item.first);
+                       const child_map::iterator itor = 
children.find(item.key);
                        if(itor == children.end() || index >= 
itor->second.size()) {
-                               throw error("error in diff: could not find 
element '" + *item.first + "'");
-                       }
-
-                       itor->second[index]->apply_diff(*item.second);
-               }
-       }
-
-       const child_list& child_inserts = diff.get_children("insert_child");
-       for(i = child_inserts.begin(); i != child_inserts.end(); ++i) {
-               const size_t index = 
lexical_cast<size_t>((**i)["index"].str());
-               for(all_children_iterator j = (*i)->ordered_begin(); j != 
(*i)->ordered_end(); ++j) {
-                       const any_child &item = *j;
-                       add_child_at(*item.first,*item.second,index);
-               }
-       }
-
-       const child_list& child_deletes = diff.get_children("delete_child");
-       for(i = child_deletes.begin(); i != child_deletes.end(); ++i) {
-               const size_t index = 
lexical_cast<size_t>((**i)["index"].str());
-               for(all_children_iterator j = (*i)->ordered_begin(); j != 
(*i)->ordered_end(); ++j) {
-                       const any_child &item = *j;
-
-                       remove_child(*item.first,index);
+                               throw error("error in diff: could not find 
element '" + item.key + "'");
+                       }
+
+                       itor->second[index]->apply_diff(item.cfg);
+               }
+       }
+
+       foreach (const config &i, diff.child_range("insert_child"))
+       {
+               const size_t index = lexical_cast<size_t>(i["index"].str());
+               foreach (const any_child &item, i.all_children_range()) {
+                       add_child_at(item.key, item.cfg, index);
+               }
+       }
+
+       foreach (const config &i, diff.child_range("delete_child"))
+       {
+               const size_t index = lexical_cast<size_t>(i["index"].str());
+               foreach (const any_child &item, i.all_children_range()) {
+                       remove_child(item.key, index);
                }
        }
 }




Related Messages


Powered by MHonArc, Updated Sat Mar 21 20:00:36 2009