Commit b2c57958 authored by Murray Cumming's avatar Murray Cumming
Browse files

C++11: Use range-based for loops.

This replaces all for loops that use const_iterator.
This doesn't actually give use a const_iterator, unless the thing
we are iterating is const, but it's worth it for the shorter code.
parent 804110db
......@@ -1624,10 +1624,8 @@ bool AppWindow::recreate_database_from_example(bool& user_cancelled)
//Create each table:
Document::type_listTableInfo tables = pDocument->get_tables();
for(Document::type_listTableInfo::const_iterator iter = tables.begin(); iter != tables.end(); ++iter)
for(const auto& table_info : tables)
{
std::shared_ptr<const TableInfo> table_info = *iter;
//Create SQL to describe all fields in this table:
Glib::ustring sql_fields;
Document::type_vec_fields fields = pDocument->get_table_fields(table_info->get_name());
......@@ -1651,10 +1649,8 @@ bool AppWindow::recreate_database_from_example(bool& user_cancelled)
if(!test)
return false;
for(Document::type_listTableInfo::const_iterator iter = tables.begin(); iter != tables.end(); ++iter)
for(const auto& table_info : tables)
{
std::shared_ptr<const TableInfo> table_info = *iter;
//Add any example data to the table:
pulse_progress_message();
......@@ -1890,9 +1886,8 @@ void AppWindow::fill_menu_tables()
}
const auto tables = document->get_tables();
for(Document::type_listTableInfo::const_iterator iter = tables.begin(); iter != tables.end(); ++iter)
for(const auto& table_info : tables)
{
std::shared_ptr<const TableInfo> table_info = *iter;
if(!table_info->get_hidden())
{
const auto title = Utils::string_escape_underscores(item_get_title_or_name(table_info));
......@@ -1946,9 +1941,9 @@ void AppWindow::fill_menu_reports(const Glib::ustring& table_name)
}
const auto reports = document->get_report_names(table_name);
for(std::vector<Glib::ustring>::const_iterator iter = reports.begin(); iter != reports.end(); ++iter)
for(const auto& item : reports)
{
std::shared_ptr<Report> report = document->get_report(table_name, *iter);
std::shared_ptr<Report> report = document->get_report(table_name, item);
if(report)
{
const auto report_name = report->get_name();
......@@ -1981,9 +1976,8 @@ void AppWindow::enable_menu_print_layouts_details(bool enable)
//TODO: Suggest a simpler get_actions() method?
typedef std::vector<Glib::ustring> type_vec_action_names;
type_vec_action_names actions = m_refNavPrintLayoutsActionGroup->list_actions();
for(type_vec_action_names::const_iterator iter = actions.begin(); iter != actions.end(); ++iter)
for(const auto& name : actions)
{
const Glib::ustring name = *iter;
Glib::RefPtr<Gio::SimpleAction> action =
Glib::RefPtr<Gio::SimpleAction>::cast_dynamic(m_refNavPrintLayoutsActionGroup->lookup_action(name));
if(action)
......@@ -2034,9 +2028,9 @@ void AppWindow::fill_menu_print_layouts(const Glib::ustring& table_name)
// TODO_clientonly: Should this be available in client only mode? We need to
// depend on goocanvas in client only mode then:
#ifndef GLOM_ENABLE_CLIENT_ONLY
for(std::vector<Glib::ustring>::const_iterator iter = tables.begin(); iter != tables.end(); ++iter)
for(const auto& item : tables)
{
std::shared_ptr<PrintLayout> print_layout = document->get_print_layout(table_name, *iter);
std::shared_ptr<PrintLayout> print_layout = document->get_print_layout(table_name, item);
if(print_layout)
{
const auto name = print_layout->get_name();
......@@ -2098,9 +2092,9 @@ void AppWindow::on_menu_file_save_as_example()
//Save all data from all tables into the document:
Document::type_listTableInfo list_table_info = document->get_tables();
for(Document::type_listTableInfo::const_iterator iter = list_table_info.begin(); iter != list_table_info.end(); ++iter)
for(const auto& item : list_table_info)
{
const auto table_name = (*iter)->get_name();
const auto table_name = item->get_name();
//const type_vec_fields vec_fields = document->get_table_fields(table_name);
......
......@@ -732,11 +732,9 @@ Base_DB::type_vecConstLayoutFields Base_DB::get_table_fields_to_show_for_sequenc
}
//Add the rest:
for(type_vec_fields::const_iterator iter = all_fields.begin(); iter != all_fields.end(); ++iter)
for(const auto& field_info : all_fields)
{
std::shared_ptr<Field> field_info = *iter;
if((*iter)->get_name() != primary_key_field_name) //We already added the primary key.
if(field_info->get_name() != primary_key_field_name) //We already added the primary key.
{
std::shared_ptr<LayoutItem_Field> layout_item = std::make_shared<LayoutItem_Field>();
layout_item->set_full_field_details(field_info);
......@@ -756,10 +754,8 @@ Base_DB::type_vecConstLayoutFields Base_DB::get_table_fields_to_show_for_sequenc
type_vec_fields vecFieldsInDocument = pDoc->get_table_fields(table_name);
//We will show the fields that the document says we should:
for(Document::type_list_layout_groups::const_iterator iter = mapGroupSequence.begin(); iter != mapGroupSequence.end(); ++iter)
for(const auto& group : mapGroupSequence)
{
std::shared_ptr<LayoutGroup> group = *iter;
if(true) //!group->get_hidden())
{
//Get the fields:
......@@ -865,10 +861,8 @@ void Base_DB::calculate_field(const LayoutFieldInRecord& field_in_record)
//Calculate dependencies first:
//TODO: Prevent unncessary recalculations?
const auto fields_needed = get_calculation_fields(field_in_record.m_table_name, field_in_record.m_field);
for(type_list_const_field_items::const_iterator iterNeeded = fields_needed.begin(); iterNeeded != fields_needed.end(); ++iterNeeded)
for(const auto& field_item_needed : fields_needed)
{
std::shared_ptr<const LayoutItem_Field> field_item_needed = *iterNeeded;
if(field_item_needed->get_has_relationship_name())
{
//TOOD: Handle related fields? We already handle whole relationships.
......@@ -1158,9 +1152,8 @@ void Base_DB::do_calculations(const LayoutFieldInRecord& field_changed, bool fir
type_list_const_field_items calculated_fields = get_calculated_fields(field_changed.m_table_name, field_changed.m_field);
//std::cout << " debug: calculated_field.size()=" << calculated_fields.size() << std::endl;
for(type_list_const_field_items::const_iterator iter = calculated_fields.begin(); iter != calculated_fields.end(); ++iter)
for(const auto& field : calculated_fields)
{
std::shared_ptr<const LayoutItem_Field> field = *iter;
if(field)
{
//std::cout << "debug: recalcing field: " << field->get_name() << std::endl;
......@@ -1192,9 +1185,8 @@ Base_DB::type_list_const_field_items Base_DB::get_calculated_fields(const Glib::
const auto fields = document->get_table_fields(table_name); //TODO_Performance: Cache this?
//Examine all fields, not just the the shown fields.
//TODO: How do we trigger relcalculation of related fields if necessary?
for(type_vec_fields::const_iterator iter = fields.begin(); iter != fields.end(); ++iter)
for(const auto& field_to_examine : fields)
{
std::shared_ptr<Field> field_to_examine = *iter;
std::shared_ptr<LayoutItem_Field> layoutitem_field_to_examine = std::make_shared<LayoutItem_Field>();
layoutitem_field_to_examine->set_full_field_details(field_to_examine);
......@@ -1272,9 +1264,9 @@ Base_DB::type_list_const_field_items Base_DB::get_calculation_fields(const Glib:
//Check the use of related records too:
const auto relationships_used = field->get_calculation_relationships();
for(Field::type_list_strings::const_iterator iter = relationships_used.begin(); iter != relationships_used.end(); ++iter)
for(const auto& item : relationships_used)
{
std::shared_ptr<Relationship> relationship = document->get_relationship(table_name, *iter);
std::shared_ptr<Relationship> relationship = document->get_relationship(table_name, item);
if(relationship)
{
//If the field uses this relationship then it should be triggered by a change in the key that specifies which record the relationship points to:
......@@ -1305,20 +1297,20 @@ void Base_DB::do_lookups(const LayoutFieldInRecord& field_in_record, const Gtk::
const auto strFieldName = field_in_record.m_field->get_name();
const auto lookups = document->get_lookup_fields(field_in_record.m_table_name, strFieldName);
//std::cout << "debug: " << G_STRFUNC << ": lookups size=" << lookups.size() << std::endl;
for(Document::type_list_lookups::const_iterator iter = lookups.begin(); iter != lookups.end(); ++iter)
for(const auto& the_pair : lookups)
{
std::shared_ptr<const LayoutItem_Field> layout_item = iter->first;
std::shared_ptr<const LayoutItem_Field> layout_item = the_pair.first;
//std::cout << "debug: " << G_STRFUNC << ": item=" << layout_item->get_name() << std::endl;
std::shared_ptr<const Relationship> relationship = iter->second;
std::shared_ptr<const Relationship> relationship = the_pair.second;
const std::shared_ptr<const Field> field_lookup = layout_item->get_full_field_details();
if(field_lookup)
{
std::shared_ptr<const Field> field_source = DbUtils::get_fields_for_table_one_field(document, relationship->get_to_table(), field_lookup->get_lookup_field());
if(field_source)
{
const auto value = DbUtils::get_lookup_value(document, field_in_record.m_table_name, iter->second /* relationship */, field_source /* the field to look in to get the value */, field_value /* Value of to and from fields */);
const auto value = DbUtils::get_lookup_value(document, field_in_record.m_table_name, the_pair.second /* relationship */, field_source /* the field to look in to get the value */, field_value /* Value of to and from fields */);
const auto value_converted = Conversions::convert_value(value, layout_item->get_glom_type());
......@@ -1544,9 +1536,8 @@ bool Base_DB::disable_user(const Glib::ustring& user)
return false;
type_vec_strings vecGroups = Privs::get_groups_of_user(user);
for(type_vec_strings::const_iterator iter = vecGroups.begin(); iter != vecGroups.end(); ++iter)
for(const auto& group : vecGroups)
{
const Glib::ustring group = *iter;
DbUtils::remove_user_from_group(user, group);
}
......
......@@ -80,14 +80,14 @@ bool Base_DB_Table_Data::record_new(bool use_entered_data, const Gnome::Gda::Val
//Add values for all fields, not just the shown ones:
//For instance, we must always add the primary key, and fields with default/calculated/lookup/auto-incremented values:
for(type_vec_fields::const_iterator iter = m_TableFields.begin(); iter != m_TableFields.end(); ++iter)
for(const auto& item : m_TableFields)
{
//TODO: Search for the non-related field with the name, not just the field with the name:
type_vecConstLayoutFields::const_iterator iterFind = std::find_if(fieldsToAdd.begin(), fieldsToAdd.end(), predicate_FieldHasName<LayoutItem_Field>((*iter)->get_name()));
type_vecConstLayoutFields::const_iterator iterFind = std::find_if(fieldsToAdd.begin(), fieldsToAdd.end(), predicate_FieldHasName<LayoutItem_Field>(item->get_name()));
if(iterFind == fieldsToAdd.end())
{
std::shared_ptr<LayoutItem_Field> layout_item = std::make_shared<LayoutItem_Field>();
layout_item->set_full_field_details(*iter);
layout_item->set_full_field_details(item);
fieldsToAdd.push_back(layout_item);
}
......@@ -102,9 +102,8 @@ bool Base_DB_Table_Data::record_new(bool use_entered_data, const Gnome::Gda::Val
type_map_added map_added;
Glib::RefPtr<Gnome::Gda::Set> params = Gnome::Gda::Set::create();
for(type_vecConstLayoutFields::const_iterator iter = fieldsToAdd.begin(); iter != fieldsToAdd.end(); ++iter)
for(const auto& layout_item : fieldsToAdd)
{
std::shared_ptr<const LayoutItem_Field> layout_item = *iter;
const Glib::ustring field_name = layout_item->get_name();
if(!layout_item->get_has_relationship_name()) //TODO: Allow people to add a related record also by entering new data in a related field of the related record.
{
......@@ -204,10 +203,8 @@ bool Base_DB_Table_Data::record_new(bool use_entered_data, const Gnome::Gda::Val
set_primary_key_value(row, primary_key_value); //Needed by Box_Data_List::on_adddel_user_changed().
//Update any lookups, related fields, or calculations:
for(type_vecConstLayoutFields::const_iterator iter = fieldsToAdd.begin(); iter != fieldsToAdd.end(); ++iter)
for(const auto& layout_item : fieldsToAdd)
{
std::shared_ptr<const LayoutItem_Field> layout_item = *iter;
//TODO_Performance: We just set this with set_entered_field_data() above. Maybe we could just remember it.
const auto field_value = get_entered_field_data(layout_item);
......@@ -472,9 +469,8 @@ Base_DB_Table_Data::type_vecConstLayoutFields Base_DB_Table_Data::get_related_fi
if(document)
{
const auto field_name = field->get_name(); //At the moment, relationships can not be based on related fields on the from side.
for(type_vecConstLayoutFields::const_iterator iter = m_FieldsShown.begin(); iter != m_FieldsShown.end(); ++iter)
for(const auto& layout_field : m_FieldsShown)
{
const std::shared_ptr<const LayoutItem_Field> layout_field = *iter;
//Examine each field that looks up its data from a relationship:
if(layout_field->get_has_relationship_name())
{
......
......@@ -104,9 +104,9 @@ bool Box_Reports::fill_from_database()
if(document)
{
listTableReports = document->get_report_names(m_table_name);
for(std::vector<Glib::ustring>::const_iterator iter = listTableReports.begin(); iter != listTableReports.end(); ++iter)
for(const auto& item : listTableReports)
{
std::shared_ptr<Report> report = document->get_report(m_table_name, *iter);
std::shared_ptr<Report> report = document->get_report(m_table_name, item);
if(report)
{
Gtk::TreeModel::iterator row = m_AddDel.add_item(report->get_name());
......
......@@ -82,11 +82,11 @@ private:
{
if(name == "glom_document") //See document_glom.cc for the #defines.
{
for(AttributeList::const_iterator iter = attributes.begin(); iter != attributes.end(); ++ iter)
for(const auto& item : attributes)
{
if(iter->name == "database_title")
if(item.name == "database_title")
{
m_title = iter->value;
m_title = item.value;
// Stop parsing here because we have what we need:
xmlStopParser(context_);
......@@ -170,9 +170,8 @@ Dialog_ExistingOrNew::Dialog_ExistingOrNew(BaseObjectType* cobject, const Glib::
// Add recently used files
typedef std::vector< Glib::RefPtr<Gtk::RecentInfo> > type_vec_infos;
type_vec_infos infos = Gtk::RecentManager::get_default()->get_items();
for(type_vec_infos::const_iterator iter = infos.begin(); iter != infos.end(); ++ iter)
for(const auto& info : infos)
{
Glib::RefPtr<Gtk::RecentInfo> info = *iter;
if(info->get_mime_type() == "application/x-glom")
{
Gtk::TreeModel::iterator iter = m_existing_model->append(m_iter_existing_recent->children());
......@@ -264,14 +263,11 @@ bool Dialog_ExistingOrNew::list_examples()
try
{
typedef std::vector<std::string> type_vec_strings;
const auto examples = Gio::Resource::enumerate_children_global(examples_dir);
bool example_found = false;
for(type_vec_strings::const_iterator iter = examples.begin(); iter != examples.end(); ++iter)
for(const auto& example_name : examples)
{
const std::string example_name = *iter;
const auto full_path = Glib::build_filename(examples_dir, example_name);
const auto title = get_title_from_example(full_path);
if(!title.empty())
......
......@@ -1442,9 +1442,8 @@ void Frame_Glom::update_table_in_document_from_database()
//and add to, or update Document's list of fields:
type_vec_fields fieldsDocument = pDoc->get_table_fields(m_table_name);
for(Base_DB::type_vec_fields::const_iterator iter = fieldsDatabase.begin(); iter != fieldsDatabase.end(); ++iter)
for(const auto& field_database : fieldsDatabase)
{
std::shared_ptr<Field> field_database = *iter;
if(field_database)
{
//Is the field already in the document?
......@@ -1490,10 +1489,8 @@ void Frame_Glom::update_table_in_document_from_database()
if(!fieldsDatabase.empty()) //Do not do this if getting the fields from the database failed completely, probably due to permissions.
{
type_vec_fields fieldsActual;
for(type_vec_fields::const_iterator iter = fieldsDocument.begin(); iter != fieldsDocument.end(); ++iter)
for(const auto& field : fieldsDocument)
{
std::shared_ptr<Field> field = *iter;
//Check whether it's in the database:
type_vec_fields::iterator iterFindDatabase = std::find_if( fieldsDatabase.begin(), fieldsDatabase.end(), predicate_FieldHasName<Field>( field->get_name() ) );
if(iterFindDatabase != fieldsDatabase.end()) //If it was found
......
......@@ -104,9 +104,8 @@ Dialog_Import_CSV::Dialog_Import_CSV(BaseObjectType* cobject, const Glib::RefPtr
m_encoding_model->append();
const FileEncodings::type_list_encodings list_encodings = FileEncodings::get_list_of_encodings();
for(FileEncodings::type_list_encodings::const_iterator encodings_iter = list_encodings.begin(); encodings_iter != list_encodings.end(); ++encodings_iter)
for(const auto& encoding : list_encodings)
{
const FileEncodings::Encoding encoding = *encodings_iter;
if(encoding.get_name().empty())
continue;
......@@ -201,9 +200,8 @@ void Dialog_Import_CSV::import(const Glib::ustring& uri, const Glib::ustring& in
(*tree_iter)[m_field_columns.m_col_field_name] = _("<None>");
const Document::type_vec_fields fields(document->get_table_fields(into_table));
for(Document::type_vec_fields::const_iterator iter = fields.begin(); iter != fields.end(); ++ iter)
for (const auto& field : fields)
{
std::shared_ptr<Field> field = *iter;
if(!field)
continue;
......@@ -213,8 +211,8 @@ void Dialog_Import_CSV::import(const Glib::ustring& uri, const Glib::ustring& in
if(!field->get_primary_key() || !field->get_auto_increment())
{
Gtk::TreeModel::iterator tree_iter = m_field_model->append();
(*tree_iter)[m_field_columns.m_col_field] = *iter;
(*tree_iter)[m_field_columns.m_col_field_name] = (*iter)->get_name();
(*tree_iter)[m_field_columns.m_col_field] = field;
(*tree_iter)[m_field_columns.m_col_field_name] = field->get_name();
}
}
......
......@@ -180,9 +180,7 @@ bool Dialog_Import_CSV_Progress::on_idle_import()
// Update the current row values map:
guint col_index = 0;
for(CsvParser::type_row_strings::const_iterator iter = row.begin();
iter != row.end();
++iter)
for(const auto& str : row)
{
std::shared_ptr<const Field> field = m_data_source->get_field_for_column(col_index++);
if(field)
......@@ -190,7 +188,7 @@ bool Dialog_Import_CSV_Progress::on_idle_import()
// We always assume exported data is in standard CSV format, since
// we export it this way.
bool success = false;
Gnome::Gda::Value value = field->from_file_format(*iter, success);
Gnome::Gda::Value value = field->from_file_format(str, success);
if(success)
{
......@@ -212,7 +210,7 @@ bool Dialog_Import_CSV_Progress::on_idle_import()
}
else
{
const Glib::ustring message(Glib::ustring::compose(_("Warning: Importing row %1: The value for field %2, \"%3\" could not be converted to the field's type. The value will not be imported.\n"), m_current_row + 1, field->get_name(), *iter));
const Glib::ustring message(Glib::ustring::compose(_("Warning: Importing row %1: The value for field %2, \"%3\" could not be converted to the field's type. The value will not be imported.\n"), m_current_row + 1, field->get_name(), str));
add_text(message);
}
}
......
......@@ -265,11 +265,8 @@ Glib::ustring PostgresSelfHosted::get_postgresql_utils_version(const SlotProgres
//std::cout << "DEBUG: vec.size() == " << vec.size() << std::endl;
// We get, for instance, "\n" and 8.4.1" and "\n".
for(type_vec_strings::const_iterator iter = vec.begin();
iter != vec.end();
++iter)
for(const auto& str : vec)
{
const auto str = *iter;
if(!str.empty())
return str; //Found.
}
......@@ -308,13 +305,10 @@ float PostgresSelfHosted::get_postgresql_utils_version_as_number(const SlotProgr
//We need to loop over the numbers because we get some "" items that we want to ignore:
guint count = 0; //We want 2 numbers.
for(type_vec_strings::const_iterator iter = vec.begin();
iter != vec.end();
++iter)
for(const auto& str : vec)
{
//std::cout << "regex item: START" << *iter << "END" << std::endl;
const auto str = *iter;
if(str.empty())
continue;
......
......@@ -293,11 +293,10 @@ bool Sqlite::recreate_table(const Glib::RefPtr<Gnome::Gda::Connection>& connecti
}
}
for(type_vec_const_fields::const_iterator iter = fields_added.begin(); iter != fields_added.end(); ++ iter)
for(const auto& field : fields_added)
{
// Add new fields to the table. Fields that have changed have already
// been handled above.
const std::shared_ptr<const Field>& field = *iter;
auto removed_iter = std::find(fields_removed.begin(), fields_removed.end(), field->get_name());
if(removed_iter == fields_removed.end())
{
......
......@@ -187,9 +187,9 @@ Glib::ustring FieldTypes::get_string_name_for_gdavaluetype(GType field_type) con
std::cerr << G_STRFUNC << ": returning unknowntype for field_type=" << field_type << " (" << g_type_name(field_type) << ")" << std::endl;
std::cerr << G_STRFUNC << ": possible types are: " << std::endl;
for(type_mapGdaTypesToSchemaStrings::const_iterator iter = m_mapGdaTypesToSchemaStrings.begin(); iter != m_mapGdaTypesToSchemaStrings.end(); ++iter)
for(const auto& item : m_mapGdaTypesToSchemaStrings)
{
std::cerr << G_STRFUNC << ": gdatype=" << iter->first << " (" << g_type_name(iter->first) << "), sqltype=" << iter->second << std::endl;
std::cerr << G_STRFUNC << ": gdatype=" << item.first << " (" << g_type_name(item.first) << "), sqltype=" << item.second << std::endl;
}
return "unknowntype";
......
......@@ -208,9 +208,8 @@ void Formatting::set_choices_custom(const type_list_values& choices)
Glib::ustring Formatting::get_custom_choice_original_for_translated_text(const Glib::ustring& text, const Glib::ustring& locale) const
{
for(Formatting::type_list_values::const_iterator iter = m_choices_custom_list.begin(); iter != m_choices_custom_list.end(); ++iter)
for(const auto& value : m_choices_custom_list)
{
const std::shared_ptr<const ChoiceValue> value = *iter;
if(!value)
continue;
......@@ -223,9 +222,8 @@ Glib::ustring Formatting::get_custom_choice_original_for_translated_text(const G
Glib::ustring Formatting::get_custom_choice_translated(const Glib::ustring& original_text, const Glib::ustring& locale) const
{
for(Formatting::type_list_values::const_iterator iter = m_choices_custom_list.begin(); iter != m_choices_custom_list.end(); ++iter)
for(const auto& value : m_choices_custom_list)
{
const std::shared_ptr<const ChoiceValue> value = *iter;
if(!value)
continue;
......
......@@ -39,10 +39,10 @@ LayoutGroup::LayoutGroup(const LayoutGroup& src)
m_border_width(src.m_border_width)
{
//Deep copy of the items map:
for(type_list_items::const_iterator iter = src.m_list_items.begin(); iter != src.m_list_items.end(); ++iter)
for(const auto& item : m_list_items)
{
if(*iter)
m_list_items.push_back( glom_sharedptr_clone(*iter) );
if(item)
m_list_items.push_back( glom_sharedptr_clone(item) );
}
}
......@@ -75,10 +75,10 @@ LayoutGroup& LayoutGroup::operator=(const LayoutGroup& src)
//Deep copy of the items map:
remove_all_items();
for(type_list_items::const_iterator iter = src.m_list_items.begin(); iter != src.m_list_items.end(); ++iter)
for(const auto& item : m_list_items)
{
if(*iter)
m_list_items.push_back( glom_sharedptr_clone(*iter) );
if(item)
m_list_items.push_back( glom_sharedptr_clone(item) );
}
}
......@@ -87,9 +87,8 @@ LayoutGroup& LayoutGroup::operator=(const LayoutGroup& src)
bool LayoutGroup::has_field(const Glib::ustring& parent_table_name, const Glib::ustring& table_name, const Glib::ustring& field_name) const
{
for(type_list_items::const_iterator iter = m_list_items.begin(); iter != m_list_items.end(); ++iter)
for(const auto& item : m_list_items)
{
auto item = *iter;
auto field_item = std::dynamic_pointer_cast<LayoutItem_Field>(item);
if(field_item)
{
......@@ -116,9 +115,8 @@ bool LayoutGroup::has_field(const Glib::ustring& parent_table_name, const Glib::
bool LayoutGroup::has_any_fields() const
{
for(type_list_items::const_iterator iter = m_list_items.begin(); iter != m_list_items.end(); ++iter)
for(const auto& item : m_list_items)
{
auto item = *iter;
auto field_item = std::dynamic_pointer_cast<LayoutItem_Field>(item);
if(field_item)
{
......@@ -175,9 +173,9 @@ LayoutGroup::type_list_const_items LayoutGroup::get_items() const
//TODO_Performance: Surely we should not need to copy the structure just to constize it?
type_list_const_items result;
for(type_list_items::const_iterator iter = m_list_items.begin(); iter != m_list_items.end(); ++iter)
for(const auto& item : m_list_items)
{
result.push_back(*iter);
result.push_back(item);
}
return result;
......@@ -187,10 +185,8 @@ LayoutGroup::type_list_const_items LayoutGroup::get_items_recursive() const
{
type_list_const_items result;
for(type_list_items::const_iterator iter = m_list_items.begin(); iter != m_list_items.end(); ++iter)
{
const std::shared_ptr<const LayoutItem> item = *iter;
for(const auto& item : m_list_items)
{
std::shared_ptr<const LayoutGroup> group = std::dynamic_pointer_cast<const LayoutGroup>(item);
if(group)
{
......@@ -208,10 +204,8 @@ LayoutGroup::type_list_items LayoutGroup::get_items_recursive()
{
type_list_items result;
for(type_list_items::const_iterator iter = m_list_items.begin(); iter != m_list_items.end(); ++iter)
{
const auto item = *iter;
for(const auto& item : m_list_items)
{
auto group = std::dynamic_pointer_cast<LayoutGroup>(item);
if(group)
{
......@@ -229,10 +223,8 @@ LayoutGroup::type_list_const_items LayoutGroup::get_items_recursive_with_groups(
{
type_list_const_items result;
for(type_list_items::const_iterator iter = m_list_items.begin(); iter != m_list_items.end(); ++iter)
{
const std::shared_ptr<const LayoutItem> item = *iter;
for(const auto& item : m_list_items)
{
//Add the item itself:
result.push_back(item);
......@@ -440,14 +432,14 @@ void LayoutGroup::debug(guint level) const
std::cout << "LayoutGroup::debug() level =" << level << std::endl;