mail[Wesnoth-commits] r33910 - /trunk/src/gui/widgets/window_builder.cpp


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

Header


Content

Posted by guillaume . melquiond on March 20, 2009 - 08:09:
Author: silene
Date: Fri Mar 20 08:09:05 2009
New Revision: 33910

URL: http://svn.gna.org/viewcvs/wesnoth?rev=33910&view=rev
Log:
Removed config::get_children.

Modified:
    trunk/src/gui/widgets/window_builder.cpp

Modified: trunk/src/gui/widgets/window_builder.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/window_builder.cpp?rev=33910&r1=33909&r2=33910&view=diff
==============================================================================
--- trunk/src/gui/widgets/window_builder.cpp (original)
+++ trunk/src/gui/widgets/window_builder.cpp Fri Mar 20 08:09:05 2009
@@ -322,12 +322,10 @@
 
        DBG_G_P << "Window builder: reading data for window " << id_ << ".\n";
 
-       const config::child_list& cfgs = cfg.get_children("resolution");
-       VALIDATE(!cfgs.empty(), _("No resolution defined."));
-       for(std::vector<config*>::const_iterator itor = cfgs.begin();
-                       itor != cfgs.end(); ++itor) {
-
-               resolutions.push_back(tresolution(**itor));
+       config::const_child_itors cfgs = cfg.child_range("resolution");
+       VALIDATE(cfgs.first != cfgs.second, _("No resolution defined."));
+       foreach (const config &i, cfgs) {
+               resolutions.push_back(tresolution(i));
        }
 
        return id_;
@@ -503,31 +501,27 @@
  */
        log_scope2(gui_parse, "Window builder: parsing a grid");
 
-       const config::child_list& row_cfgs = cfg.get_children("row");
-       for(std::vector<config*>::const_iterator row_itor = row_cfgs.begin();
-                       row_itor != row_cfgs.end(); ++row_itor) {
-
+       foreach (const config &row, cfg.child_range("row"))
+       {
                unsigned col = 0;
 
-               
row_grow_factor.push_back(lexical_cast_default<unsigned>((**row_itor)["grow_factor"]));
-
-               const config::child_list& col_cfgs = 
(**row_itor).get_children("column");
-               for(std::vector<config*>::const_iterator col_itor = 
col_cfgs.begin();
-                               col_itor != col_cfgs.end(); ++col_itor) {
-
-                       flags.push_back(read_flags(**col_itor));
-                       
border_size.push_back(lexical_cast_default<unsigned>((**col_itor)["border_size"]));
+               
row_grow_factor.push_back(lexical_cast_default<unsigned>(row["grow_factor"]));
+
+               foreach (const config &c, row.child_range("column"))
+               {
+                       flags.push_back(read_flags(c));
+                       
border_size.push_back(lexical_cast_default<unsigned>(c["border_size"]));
                        if(rows == 0) {
-                               
col_grow_factor.push_back(lexical_cast_default<unsigned>((**col_itor)["grow_factor"]));
+                               
col_grow_factor.push_back(lexical_cast_default<unsigned>(c["grow_factor"]));
                        }
 
-                       widgets.push_back(create_builder_widget(**col_itor));
+                       widgets.push_back(create_builder_widget(c));
 
                        ++col;
                }
 
                ++rows;
-               if(row_itor == row_cfgs.begin()) {
+               if (rows == 1) {
                        cols = col;
                } else {
                        VALIDATE(col, _("A row must have a column."));
@@ -775,27 +769,23 @@
        VALIDATE(list_builder->rows == 1, _("A 'list_definition' should 
contain one row."));
 
        const config *data = cfg.child("list_data");
-       if(data) {
-
-               const config::child_list& row_cfgs = 
data->get_children("row");
-               for(std::vector<config*>::const_iterator row_itor = 
row_cfgs.begin();
-                               row_itor != row_cfgs.end(); ++row_itor) {
-
-                       unsigned col = 0;
-
-                       const config::child_list& col_cfgs = 
(**row_itor).get_children("column");
-                       for(std::vector<config*>::const_iterator col_itor = 
col_cfgs.begin();
-                                       col_itor != col_cfgs.end(); 
++col_itor) {
-                               list_data.push_back(string_map());
-                               foreach (const config::attribute &i, 
(*col_itor)->attribute_range()) {
-                                       list_data.back()[i.first] = i.second;
-                               }
-                               ++col;
+       if (!data) return;
+
+       foreach (const config &row, data->child_range("row"))
+       {
+               unsigned col = 0;
+
+               foreach (const config &c, row.child_range("column"))
+               {
+                       list_data.push_back(string_map());
+                       foreach (const config::attribute &i, 
c.attribute_range()) {
+                               list_data.back()[i.first] = i.second;
                        }
-
-                       VALIDATE(col == list_builder->cols, _("'list_data' 
must have "
-                               "the same number of columns as the 
'list_definition'."));
-               }
+                       ++col;
+               }
+
+               VALIDATE(col == list_builder->cols, _("'list_data' must have "
+                       "the same number of columns as the 
'list_definition'."));
        }
 }
 
@@ -857,11 +847,10 @@
  * @end_table
  */
        const config* data = cfg.child("data");
-
-       if(data) {
-               foreach(const config* cell, data->get_children("cell")) {
-                       cells_.push_back(tbuilder_gridcell(*cell));
-               }
+       if (!data) return;
+
+       foreach(const config &cell, data->child_range("cell")) {
+               cells_.push_back(tbuilder_gridcell(cell));
        }
 }
 
@@ -1038,13 +1027,10 @@
  * @end_table
  */
        const config* labels = cfg.child("value_labels");
-       if(labels) {
-
-               const config::child_list& value = 
labels->get_children("value");
-               foreach(const config* label, value) {
-
-                       value_labels_.push_back((*label)["label"]);
-               }
+       if (!labels) return;
+
+       foreach (const config &label, labels->child_range("value")) {
+               value_labels_.push_back(label["label"]);
        }
 }
 




Related Messages


Powered by MHonArc, Updated Fri Mar 20 08:20:30 2009