Commit 69732ec4 authored by Murray Cumming's avatar Murray Cumming
Browse files

C+11: Use auto for iterator types.

parent 624e6116
......@@ -619,7 +619,7 @@ void Base_DB::get_table_fields_to_show_for_sequence_add_group(const Glib::ustrin
}
else //It's a regular field in the table:
{
type_vec_fields::const_iterator iterFind = find_if_same_name(all_db_fields, field_name);
const auto iterFind = find_if_same_name(all_db_fields, field_name);
//If the field does not exist anymore then we won't try to show it:
if(iterFind != all_db_fields.end() )
......@@ -1151,7 +1151,7 @@ Base_DB::type_list_const_field_items Base_DB::get_calculated_fields(const Glib::
//Does this field's calculation use the field?
const auto fields_triggered = get_calculation_fields(table_name, layoutitem_field_to_examine);
//std::cout << " debug: field_triggered.size()=" << fields_triggered.size() << std::endl;
type_list_const_field_items::const_iterator iterFind = find_if_layout_item_is_equal(fields_triggered, field);
const auto iterFind = find_if_layout_item_is_equal(fields_triggered, field);
if(iterFind != fields_triggered.end())
{
//std::cout << " debug: FOUND: name=" << layoutitem_field_to_examine->get_name() << std::endl;
......
......@@ -75,7 +75,7 @@ bool Base_DB_Table_Data::record_new(bool use_entered_data, const Gnome::Gda::Val
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 = find_if_same_name(fieldsToAdd, item->get_name());
const auto iterFind = find_if_same_name(fieldsToAdd, item->get_name());
if(iterFind == fieldsToAdd.end())
{
std::shared_ptr<LayoutItem_Field> layout_item = std::make_shared<LayoutItem_Field>();
......@@ -99,7 +99,7 @@ bool Base_DB_Table_Data::record_new(bool use_entered_data, const Gnome::Gda::Val
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.
{
type_map_added::const_iterator iterFind = map_added.find(field_name);
const auto iterFind = map_added.find(field_name);
if(iterFind == map_added.end()) //If it was not added already
{
Gnome::Gda::Value value;
......@@ -510,7 +510,7 @@ void Base_DB_Table_Data::refresh_related_fields(const LayoutFieldInRecord& field
//Field contents:
if(result->get_n_rows())
{
type_vecConstLayoutFields::const_iterator iterFields = fieldsToGet.begin();
auto iterFields = fieldsToGet.begin();
const guint cols_count = result->get_n_columns();
if(cols_count <= 0)
......
......@@ -261,7 +261,7 @@ void Dialog_Import_CSV_Progress::on_response(int /* response_id */)
Gnome::Gda::Value Dialog_Import_CSV_Progress::get_entered_field_data(const std::shared_ptr<const LayoutItem_Field>& field) const
{
type_mapValues::const_iterator iter = m_current_row_values.find(field->get_name());
const auto iter = m_current_row_values.find(field->get_name());
if(iter == m_current_row_values.end())
return Gnome::Gda::Value();
......@@ -280,7 +280,7 @@ std::shared_ptr<Field> Dialog_Import_CSV_Progress::get_field_primary_key() const
Gnome::Gda::Value Dialog_Import_CSV_Progress::get_primary_key_value_selected() const
{
type_mapValues::const_iterator iter = m_current_row_values.find(m_field_primary_key->get_name());
const auto iter = m_current_row_values.find(m_field_primary_key->get_name());
if(iter == m_current_row_values.end())
return Gnome::Gda::Value();
......
......@@ -783,8 +783,8 @@ bool ConnectionPool::change_columns(const Glib::ustring& table_name, const type_
//Add or remove any auto-increment rows:
//The new auto-increment row would actually be added automatically,
//but this makes it available even before a record has been added.
type_vec_const_fields::const_iterator iter_old = old_fields.begin();
type_vec_const_fields::const_iterator iter_new = new_fields.begin();
auto iter_old = old_fields.begin();
auto iter_new = new_fields.begin();
while( (iter_old != old_fields.end()) && (iter_new != new_fields.end()) )
{
const std::shared_ptr<const Field> field_old = *iter_old;
......
......@@ -993,7 +993,7 @@ type_vec_fields get_fields_for_table(const Document* document, const Glib::ustri
//Get the field info from the database:
//This is in the document as well, but it _might_ have changed.
type_vec_fields::const_iterator iterFindDatabase =
const auto iterFindDatabase =
find_if_same_name(fieldsDatabase, field_name);
if(iterFindDatabase != fieldsDatabase.end() ) //Ignore fields that don't exist in the database anymore.
......
......@@ -3727,7 +3727,7 @@ bool Document::save_before()
XmlUtils::set_child_text_node(elemField, GLOM_NODE_CALCULATION, field->get_calculation());
Glib::ustring field_type;
Field::type_map_type_names::const_iterator iterTypes = type_names.find( field->get_glom_type() );
const auto iterTypes = type_names.find( field->get_glom_type() );
if(iterTypes != type_names.end())
field_type = iterTypes->second;
......@@ -4040,7 +4040,7 @@ std::shared_ptr<Report> Document::get_report(const Glib::ustring& table_name, co
const std::shared_ptr<const DocumentTableInfo> info = get_table_info(table_name);
if(info)
{
DocumentTableInfo::type_reports::const_iterator iterFindReport = info->m_reports.find(report_name);
const auto iterFindReport = info->m_reports.find(report_name);
if(iterFindReport != info->m_reports.end())
{
return iterFindReport->second;
......@@ -4099,7 +4099,7 @@ std::shared_ptr<PrintLayout> Document::get_print_layout(const Glib::ustring& tab
const std::shared_ptr<const DocumentTableInfo> info = get_table_info(table_name);
if(info)
{
DocumentTableInfo::type_print_layouts::const_iterator iterFindPrintLayout = info->m_print_layouts.find(print_layout_name);
const auto iterFindPrintLayout = info->m_print_layouts.find(print_layout_name);
if(iterFindPrintLayout != info->m_print_layouts.end())
{
return iterFindPrintLayout->second;
......@@ -4205,7 +4205,7 @@ Gnome::Gda::Value Document::get_layout_record_viewed(const Glib::ustring& table_
const std::shared_ptr<const DocumentTableInfo> info = get_table_info(table_name);
if(info)
{
DocumentTableInfo::type_map_layout_primarykeys::const_iterator iterLayoutKeys = info->m_map_current_record.find(layout_name);
const auto iterLayoutKeys = info->m_map_current_record.find(layout_name);
if(iterLayoutKeys != info->m_map_current_record.end())
return iterLayoutKeys->second;
}
......@@ -4669,7 +4669,7 @@ void Document::set_library_module(const Glib::ustring& name, const Glib::ustring
Glib::ustring Document::get_library_module(const Glib::ustring& name) const
{
type_map_library_scripts::const_iterator iter = m_map_library_scripts.find(name);
const auto iter = m_map_library_scripts.find(name);
if(iter != m_map_library_scripts.end())
{
return iter->second;
......
......@@ -448,7 +448,7 @@ Privileges Privs::get_current_privs(const Glib::ustring& table_name)
//Return a cached value if possible.
//(If it is in the cache then it's fairly recent)
type_map_privileges::const_iterator iter = m_privileges_cache.find(table_name);
const auto iter = m_privileges_cache.find(table_name);
if(iter != m_privileges_cache.end())
{
//std::cout << "debug: " << G_STRFUNC << ": Returning cache." << std::endl;
......
......@@ -115,7 +115,7 @@ boost::python::object PyGlomRecord::getitem(const boost::python::object& cppitem
{
const std::string key = boost::python::extract<std::string>(cppitem);
PyGlomRecord::type_map_field_values::const_iterator iterFind = m_map_field_values.find(key);
const auto iterFind = m_map_field_values.find(key);
if(iterFind != m_map_field_values.end())
{
return glom_pygda_value_as_boost_pyobject(iterFind->second);
......
......@@ -63,7 +63,7 @@ boost::python::object PyGlomRelated::getitem(const boost::python::object& cppite
else
{
//If the relationship exists:
PyGlomRelated::type_map_relationships::const_iterator iterFind = m_map_relationships.find(key);
const auto iterFind = m_map_relationships.find(key);
if(iterFind != m_map_relationships.end())
{
//Get the value of the from_key in the parent record.
......@@ -74,7 +74,7 @@ boost::python::object PyGlomRelated::getitem(const boost::python::object& cppite
if(extractor_record.check())
{
PyGlomRecord* record = extractor_record;
PyGlomRecord::type_map_field_values::const_iterator iterFromKey = record->m_map_field_values.find(from_key);
const auto iterFromKey = record->m_map_field_values.find(from_key);
if(iterFromKey != record->m_map_field_values.end())
{
const Gnome::Gda::Value& from_key_value = iterFromKey->second;
......
......@@ -59,7 +59,7 @@ boost::python::object PyGlomRelatedRecord::getitem(const boost::python::object&
{
const std::string field_name = boost::python::extract<std::string>(cppitem);
PyGlomRelatedRecord::type_map_field_values::const_iterator iterFind = m_map_field_values.find(field_name);
const auto iterFind = m_map_field_values.find(field_name);
if(iterFind != m_map_field_values.end())
{
//If the value has already been stored, then just return it again:
......
......@@ -99,7 +99,7 @@ Glib::ustring Utils::trim_whitespace(const Glib::ustring& text)
//Find non-whitespace from back:
Glib::ustring::size_type posBack = Glib::ustring::npos;
pos = 0;
for(Glib::ustring::reverse_iterator iter = result.rbegin(); iter != result.rend(); ++iter)
for(auto iter = result.rbegin(); iter != result.rend(); ++iter)
{
if(!Glib::Unicode::isspace(*iter))
{
......@@ -241,7 +241,7 @@ static void add_to_relationships_list(type_list_relationships& list_relationship
return;
//If this is a related relationship, add the first-level relationship too, so that the related relationship can be defined in terms of it:
type_list_relationships::const_iterator iterFind = find_if_uses_relationship_has_relationship(list_relationships, layout_item, true /* top_level_only */);
auto iterFind = find_if_uses_relationship_has_relationship(list_relationships, layout_item, true /* top_level_only */);
if(iterFind == list_relationships.end()) //If the table is not yet in the list:
{
std::shared_ptr<UsesRelationship> uses_rel = std::make_shared<UsesRelationship>();
......@@ -1486,7 +1486,7 @@ LayoutGroup::type_list_const_items Utils::get_layout_items_plus_primary_key(cons
pk_layout_item->set_hidden();
pk_layout_item->set_full_field_details(field_primary_key);
const LayoutGroup::type_list_const_items::const_iterator iterFind =
const auto iterFind =
find_if_layout_item_field_is_same_field(items, pk_layout_item);
if(iterFind != items.end())
return items; //It is already in the list:
......@@ -1516,7 +1516,7 @@ LayoutGroup::type_list_items Utils::get_layout_items_plus_primary_key(const Layo
pk_layout_item->set_hidden();
pk_layout_item->set_full_field_details(field_primary_key);
const LayoutGroup::type_list_items::const_iterator iterFind =
const auto iterFind =
find_if_layout_item_field_is_same_field(items, pk_layout_item);
if(iterFind != items.end())
return items; //It is already in the list:
......
......@@ -431,7 +431,7 @@ Glib::ustring Box_Data_Calendar_Related::on_calendar_details(guint year, guint m
Glib::Date date(day, datemonth, year);
//Examine the cached data:
type_map_values::const_iterator iter_find = m_map_values.find(date);
const auto iter_find = m_map_values.find(date);
if(iter_find == m_map_values.end())
return Glib::ustring(); //No data was found for this date.
......
......@@ -88,7 +88,7 @@ void ComboAsRadioButtons::set_choices_with_second(const type_list_values_with_se
const auto extra_values = the_pair.second;
if(layout_choice_extra && !extra_values.empty())
{
type_list_values::const_iterator iterValues = extra_values.begin();
auto iterValues = extra_values.begin();
for(const auto& item : extra_fields)
{
if(iterValues != extra_values.end()) {
......
......@@ -173,7 +173,7 @@ void ComboChoicesWithTreeModel::set_choices_with_second(const type_list_values_w
if(layout_choice_extra && !extra_values.empty())
{
guint model_index = 1; //0 is for the main field.
type_list_values::const_iterator iterValues = extra_values.begin();
const auto iterValues = extra_values.begin();
for(const auto& extra_field : extra_fields)
{
if(model_index >= columns_count)
......
......@@ -170,7 +170,7 @@ DbTreeModelRow::DbValue DbTreeModelRow::get_value(DbTreeModel& model, int column
{
fill_values_if_necessary(model, row);
type_vec_values::const_iterator iterFind = m_db_values.find(column);
const auto iterFind = m_db_values.find(column);
if(iterFind != m_db_values.end())
return iterFind->second;
else
......@@ -890,7 +890,7 @@ void DbTreeModel::clear()
bool DbTreeModel::row_was_removed(const type_datamodel_row_index& datamodel_row) const
{
type_map_rows::const_iterator iterFind = m_map_rows.find(datamodel_row);
const auto iterFind = m_map_rows.find(datamodel_row);
if(iterFind != m_map_rows.end())
return iterFind->second.m_removed;
else
......@@ -948,7 +948,7 @@ Gtk::TreeModel::iterator DbTreeModel::get_placeholder_row()
}
}
type_map_rows::const_iterator iter_map = m_map_rows.find(row);
const auto iter_map = m_map_rows.find(row);
if(iter_map != m_map_rows.end())
{
//std::cerr << G_STRFUNC << ": returning row=" << row << std::endl;
......
......@@ -339,7 +339,7 @@ Gnome::Gda::Value DbAddDel::get_value(const Gtk::TreeModel::iterator& iter, cons
type_list_indexes list_indexes = get_data_model_column_index(layout_item);
if(!list_indexes.empty())
{
type_list_indexes::const_iterator iter_begin = list_indexes.begin(); //Just get the first displayed instance of this field->
const auto iter_begin = list_indexes.begin(); //Just get the first displayed instance of this field->
const guint col_real = *iter_begin + get_count_hidden_system_columns();
treerow.get_value(col_real, value);
......
......@@ -640,7 +640,7 @@ std::shared_ptr<LayoutGroup> FlowTableWithFields::get_layout_group()
void FlowTableWithFields::remove_field(const Glib::ustring& id)
{
for(type_listFields::iterator iter = m_listFields.begin(); iter != m_listFields.end(); ++iter)
for(auto iter = m_listFields.begin(); iter != m_listFields.end(); ++iter)
{
Info info = *iter;
if(info.m_field->get_name() == id)
......@@ -710,7 +710,7 @@ void FlowTableWithFields::set_other_field_value(const std::shared_ptr<const Layo
Gnome::Gda::Value FlowTableWithFields::get_field_value(const std::shared_ptr<const LayoutItem_Field>& field) const
{
type_list_const_widgets list_widgets = get_field(field, true);
for(type_list_const_widgets::const_iterator iter = list_widgets.begin();
for(auto iter = list_widgets.begin();
iter != list_widgets.end(); ++iter)
{
const auto datawidget = dynamic_cast<const DataWidget*>(*iter);
......
......@@ -76,7 +76,7 @@ void Box_DB_Table_Definition::init()
Field::type_map_type_names mapFieldTypes = Field::get_usable_type_names();
AddDel::type_vec_strings vecTypes;
for(Field::type_map_type_names ::iterator iter = mapFieldTypes.begin(); iter != mapFieldTypes.end();++iter)
for(auto iter = mapFieldTypes.begin(); iter != mapFieldTypes.end();++iter)
{
const Glib::ustring& name = (*iter).second;
vecTypes.push_back(name);
......@@ -373,7 +373,7 @@ void Box_DB_Table_Definition::on_adddel_changed(const Gtk::TreeModel::iterator&
m_Field_BeingEdited = constfield;
//Get DB field info: (TODO: This might be unnecessary).
type_vec_fields::const_iterator iterFind = find_if_same_name(m_vecFields, strFieldNameBeingEdited);
const auto iterFind = find_if_same_name(m_vecFields, strFieldNameBeingEdited);
if(iterFind == m_vecFields.end()) //If it was not found:
std::cerr << G_STRFUNC << ": field not found: " << strFieldNameBeingEdited << std::endl;
else
......
......@@ -285,7 +285,7 @@ Glib::ustring get_locale_name(const Glib::ustring& locale_id)
Glib::ustring result;
type_map_locales::const_iterator iter = map_locales.find(locale_id);
const auto iter = map_locales.find(locale_id);
if(iter != map_locales.end())
result = iter->second.m_name;
......
......@@ -73,8 +73,8 @@ bool TreeStore_Layout::row_drop_possible_vfunc(const Gtk::TreeModel::Path& dest,
//Get an iterator for the row at this path:
//We must unconst this. This should not be necessary with a future version of gtkmm.
auto unconstThis = const_cast<TreeStore_Layout*>(this); //TODO: Add a const version of get_iter to TreeModel:
const_iterator iter_dragged = unconstThis->get_iter(path_dragged_row);
//const_iterator iter_dragged = get_iter(path_dragged_row);
const auto iter_dragged = unconstThis->get_iter(path_dragged_row);
//const auto iter_dragged = get_iter(path_dragged_row);
if(iter_dragged)
{
......@@ -95,8 +95,8 @@ bool TreeStore_Layout::row_drop_possible_vfunc(const Gtk::TreeModel::Path& dest,
//Get an iterator for the row at the requested parent's path:
//We must unconst this. This should not be necessary with a future version of gtkmm.
auto unconstThis = const_cast<TreeStore_Layout*>(this); //TODO: Add a const version of get_iter to TreeModel:
const_iterator iter_dest_parent = unconstThis->get_iter(dest_parent);
//const_iterator iter_dest_parent = get_iter(dest);
const auto iter_dest_parent = unconstThis->get_iter(dest_parent);
//const auto iter_dest_parent = get_iter(dest);
if(iter_dest_parent)
{
Gtk::TreeModel::Row row_parent = *iter_dest_parent;
......@@ -116,7 +116,7 @@ bool TreeStore_Layout::row_drop_possible_vfunc(const Gtk::TreeModel::Path& dest,
void TreeStore_Layout::fill_sequences()
{
guint sequence = 1;
for(iterator iter_children = children().begin(); iter_children != children().end(); ++iter_children)
for(auto iter_children = children().begin(); iter_children != children().end(); ++iter_children)
{
Gtk::TreeModel::Row row = *iter_children;
row[m_columns.m_col_sequence] = sequence;
......@@ -130,7 +130,7 @@ void TreeStore_Layout::fill_sequences()
void TreeStore_Layout::fill_sequences(const iterator& iter)
{
guint sequence = 1;
for(iterator iter_children = iter->children().begin(); iter_children != iter->children().end(); ++iter_children)
for(auto iter_children = iter->children().begin(); iter_children != iter->children().end(); ++iter_children)
{
Gtk::TreeModel::Row row = *iter_children;
row[m_columns.m_col_sequence] = sequence;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment