[glom] C++11: Yet more auto.



commit ae172d68cd89ba62a6c11b66619460dbc3f08672
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Mar 18 21:20:56 2016 +0100

    C++11: Yet more auto.

 glom/base_db.cc                                    |    2 +-
 glom/base_db_table_data.cc                         |    2 +-
 glom/frame_glom.cc                                 |    2 +-
 glom/glom_create_from_example.cc                   |    2 +-
 glom/glom_import_po_all.cc                         |    2 +-
 glom/import_csv/dialog_import_csv.cc               |    6 +++---
 .../connectionpool_backends/postgres_self.cc       |    2 +-
 glom/libglom/db_utils.cc                           |    2 +-
 glom/libglom/file_utils.cc                         |    8 ++++----
 glom/libglom/string_utils.cc                       |    4 ++--
 glom/mode_data/box_data_manyrecords.cc             |    2 +-
 glom/mode_data/db_adddel/db_adddel.cc              |    2 +-
 tests/import/test_parsing.cc                       |    2 +-
 .../python/test_python_execute_func_with_record.cc |    2 +-
 tests/test_document_load.cc                        |    8 ++++----
 tests/test_document_load_and_change.cc             |    2 +-
 tests/test_document_load_image.cc                  |    4 ++--
 tests/test_document_load_translations.cc           |    2 +-
 tests/test_fake_connection.cc                      |    2 +-
 tests/test_utils.cc                                |    2 +-
 tests/translations_po/test_document_export_po.cc   |    2 +-
 tests/translations_po/test_document_import_po.cc   |    4 ++--
 tests/ui/test_imageglom_widget.cc                  |    2 +-
 23 files changed, 34 insertions(+), 34 deletions(-)
---
diff --git a/glom/base_db.cc b/glom/base_db.cc
index 7e39cec..9571e7e 100644
--- a/glom/base_db.cc
+++ b/glom/base_db.cc
@@ -1115,7 +1115,7 @@ bool Base_DB::check_entered_value_for_uniqueness(const Glib::ustring& table_name
 bool Base_DB::check_entered_value_for_uniqueness(const Glib::ustring& table_name, const 
Gtk::TreeModel::iterator& /* row */,  const std::shared_ptr<const LayoutItem_Field>& layout_field, const 
Gnome::Gda::Value& field_value, Gtk::Window* parent_window)
 {
   //Check whether the value meets uniqueness constraints, if any:
-  const std::shared_ptr<const Field>& field = layout_field->get_full_field_details();
+  const auto field = layout_field->get_full_field_details();
   if(field && (field->get_primary_key() || field->get_unique_key()))
   {
     if(!get_field_value_is_unique(table_name, layout_field, field_value))
diff --git a/glom/base_db_table_data.cc b/glom/base_db_table_data.cc
index 5c60bfe..80090d2 100644
--- a/glom/base_db_table_data.cc
+++ b/glom/base_db_table_data.cc
@@ -102,7 +102,7 @@ bool Base_DB_Table_Data::record_new(bool use_entered_data, const Gnome::Gda::Val
       {
         Gnome::Gda::Value value;
 
-        const std::shared_ptr<const Field>& field = layout_item->get_full_field_details();
+        const auto field = layout_item->get_full_field_details();
         if(!field)
           continue;
         
diff --git a/glom/frame_glom.cc b/glom/frame_glom.cc
index f309693..d0069fa 100644
--- a/glom/frame_glom.cc
+++ b/glom/frame_glom.cc
@@ -2264,7 +2264,7 @@ void Frame_Glom::on_menu_report_selected(const Glib::ustring& report_name)
   //TODO: Find a way to get a full locale name from the simplified locale name from 
AppWindow::get_current_locale():
   ReportBuilder report_builder(std::locale("") /* the user's current locale */);
   report_builder.set_document(document);
-  const std::string filepath = 
+  const auto filepath = 
     report_builder.report_build_and_save(found_set, report); //TODO: Use found set's where_clause.
   UiUtils::show_report_in_browser(filepath, get_app_window());
 }
diff --git a/glom/glom_create_from_example.cc b/glom/glom_create_from_example.cc
index 6e340d7..118ac15 100644
--- a/glom/glom_create_from_example.cc
+++ b/glom/glom_create_from_example.cc
@@ -381,7 +381,7 @@ int main(int argc, char* argv[])
       Glib::build_filename(
         group.m_arg_filepath_dir_output,
         group.m_arg_filepath_name_output));
-  const std::string filepath =
+  const auto filepath =
     Glib::build_filename(filepath_dir, group.m_arg_filepath_name_output);
 
   //Make sure that the file does not exist yet:
diff --git a/glom/glom_import_po_all.cc b/glom/glom_import_po_all.cc
index 5c642e9..7f43372 100644
--- a/glom/glom_import_po_all.cc
+++ b/glom/glom_import_po_all.cc
@@ -201,7 +201,7 @@ int main(int argc, char* argv[])
 
     //Check that it has the .po file extension:
     const auto basename = child->get_basename();
-    const std::string locale_id = 
+    const auto locale_id = 
       Glom::Utils::string_remove_suffix(basename, ".po");
     if(locale_id == basename)
       continue;
diff --git a/glom/import_csv/dialog_import_csv.cc b/glom/import_csv/dialog_import_csv.cc
index 2e181fc..d3a006c 100644
--- a/glom/import_csv/dialog_import_csv.cc
+++ b/glom/import_csv/dialog_import_csv.cc
@@ -570,7 +570,7 @@ void Dialog_Import_CSV::field_data_func(Gtk::CellRenderer* renderer, const Gtk::
 
   if(row == -1)
   {
-    std::shared_ptr<Field> field = m_fields[column_number];
+    const auto field = m_fields[column_number];
     if(field)
       text = field->get_name();
     else
@@ -585,7 +585,7 @@ void Dialog_Import_CSV::field_data_func(Gtk::CellRenderer* renderer, const Gtk::
 
     if(column_number < m_fields.size())
     {
-      std::shared_ptr<Field> field = m_fields[column_number];
+      const auto field = m_fields[column_number];
 
       if(row != -1) // && static_cast<unsigned int>(row) < m_parser->get_rows_count())
       {
@@ -648,7 +648,7 @@ void Dialog_Import_CSV::on_field_edited(const Glib::ustring& path, const Glib::u
   {
     if( (elem)[m_field_columns.m_col_field_name] == new_text)
     {
-      std::shared_ptr<Field> field = (elem)[m_field_columns.m_col_field];
+      const std::shared_ptr<Field> field = (elem)[m_field_columns.m_col_field];
       // Check whether another column is already using that field
       auto vec_field_iter = Utils::find(m_fields, field);
       // Reset the old column since two different columns cannot be imported into the same field
diff --git a/glom/libglom/connectionpool_backends/postgres_self.cc 
b/glom/libglom/connectionpool_backends/postgres_self.cc
index 90b353b..934ea64 100644
--- a/glom/libglom/connectionpool_backends/postgres_self.cc
+++ b/glom/libglom/connectionpool_backends/postgres_self.cc
@@ -224,7 +224,7 @@ Backend::InitErrors PostgresSelfHosted::initialize(const SlotProgress& slot_prog
   // from being based on the current environment, because we want the database to be
   // as portable as possible.
   // See http://www.postgresql.org/docs/current/static/app-initdb.html
-  const std::string command_initdb = get_path_to_postgres_executable("initdb") +
+  const auto command_initdb = get_path_to_postgres_executable("initdb") +
     " -D " + Glib::shell_quote(dbdir_data) +
     " -U " + initial_username +
     " --pwfile=" + Glib::shell_quote(temp_pwfile) +
diff --git a/glom/libglom/db_utils.cc b/glom/libglom/db_utils.cc
index 756ae2e..4d1bf96 100644
--- a/glom/libglom/db_utils.cc
+++ b/glom/libglom/db_utils.cc
@@ -2462,7 +2462,7 @@ type_list_values_with_second get_choice_values(const std::shared_ptr<const Docum
     return result;
   }
 
-  const std::string sql_query =
+  const auto sql_query =
           SqlUtils::sqlbuilder_get_full_query(builder);
   //std::cout << "debug: sql_query=" << sql_query << std::endl;
   auto datamodel = connection->get_gda_connection()->statement_execute_select(sql_query);
diff --git a/glom/libglom/file_utils.cc b/glom/libglom/file_utils.cc
index fe21caa..a05bb71 100644
--- a/glom/libglom/file_utils.cc
+++ b/glom/libglom/file_utils.cc
@@ -96,7 +96,7 @@ static Glib::ustring get_directory_child_with_suffix(const Glib::ustring& uri_di
     if(file_type == Gio::FILE_TYPE_REGULAR)
     {
       //Check the filename:
-      const std::string basename = child->get_basename();
+      const auto basename = child->get_basename();
       if(Utils::string_remove_suffix(basename, suffix) != basename)
         return child->get_uri();
     }
@@ -194,7 +194,7 @@ Glib::ustring get_temp_file_uri(const std::string& prefix, const std::string& ex
 {
   try
   {
-    const std::string filepath = get_temp_file_path(prefix, extension);
+    const auto filepath = get_temp_file_path(prefix, extension);
     return Glib::filename_to_uri(filepath);
   }
   catch(const Glib::Error& ex)
@@ -208,7 +208,7 @@ std::string get_temp_directory_path(const std::string& prefix)
 {
   std::string result;
 
-  const std::string pattern = Glib::build_filename(
+  const auto pattern = Glib::build_filename(
           Glib::get_tmp_dir(), prefix + "XXXXXX");
 
   //We must copy the pattern, because mkdtemp() modifies it:
@@ -225,7 +225,7 @@ Glib::ustring get_temp_directory_uri(const std::string& prefix)
 {
   try
   {
-    const std::string filepath = get_temp_directory_path(prefix);
+    const auto filepath = get_temp_directory_path(prefix);
     return Glib::filename_to_uri(filepath);
   }
   catch(const Glib::Error& ex)
diff --git a/glom/libglom/string_utils.cc b/glom/libglom/string_utils.cc
index 31ae130..c9dab18 100644
--- a/glom/libglom/string_utils.cc
+++ b/glom/libglom/string_utils.cc
@@ -93,8 +93,8 @@ Glib::ustring string_replace(const Glib::ustring& src, const Glib::ustring& sear
   std::string result = src;
 
   std::string::size_type pos = 0;
-  const std::string::size_type len_search = search_for.size();
-  const std::string::size_type len_replace = replace_with.size();
+  const auto len_search = search_for.size();
+  const auto len_replace = replace_with.size();
 
   std::string::size_type pos_after_prev = 0;
   while((pos = result.find(search_for, pos_after_prev)) != std::string::npos)
diff --git a/glom/mode_data/box_data_manyrecords.cc b/glom/mode_data/box_data_manyrecords.cc
index 13cd4cc..320c2fc 100644
--- a/glom/mode_data/box_data_manyrecords.cc
+++ b/glom/mode_data/box_data_manyrecords.cc
@@ -84,7 +84,7 @@ void Box_Data_ManyRecords::print_layout()
     //TODO: Find a way to get a full locale name from the simplified locale name from 
AppWindow::get_current_locale():
     ReportBuilder report_builder(std::locale("") /* the user's current locale */);
     report_builder.set_document(document);
-    const std::string filepath = 
+    const auto filepath = 
       report_builder.report_build_and_save(m_found_set, report_temp);
     UiUtils::show_report_in_browser(filepath, get_app_window());
   }
diff --git a/glom/mode_data/db_adddel/db_adddel.cc b/glom/mode_data/db_adddel/db_adddel.cc
index 4abc5a6..1a32654 100644
--- a/glom/mode_data/db_adddel/db_adddel.cc
+++ b/glom/mode_data/db_adddel/db_adddel.cc
@@ -2158,7 +2158,7 @@ void DbAddDel::user_changed(const Gtk::TreeModel::iterator& row, guint col)
       //Update the field in the record (the record with this primary key):
       const auto field_value = get_value(row, layout_field);
       //std::cout << "debug: " << G_STRFUNC << ": field_value = " << field_value.to_string() << std::endl;
-      //const std::shared_ptr<const Field>& field = layout_field->m_field;
+      //const auto field = layout_field->m_field;
       //const Glib::ustring strFieldName = layout_field->get_name();
 
       LayoutFieldInRecord field_in_record(layout_field, m_found_set.m_table_name /* parent */, 
primary_key_field, primary_key_value);
diff --git a/tests/import/test_parsing.cc b/tests/import/test_parsing.cc
index 70b0d9b..32313e5 100644
--- a/tests/import/test_parsing.cc
+++ b/tests/import/test_parsing.cc
@@ -210,7 +210,7 @@ int main()
   // test_import_csv_file
   {
     // filename_to_uri expects absolute filenames
-    const std::string filename =
+    const auto filename =
        Glib::build_filename(GLOM_TESTS_IMPORT_DATA_NOTINSTALLED,
          "albums.csv");
     const auto finished_parsing = ImportTests::run_parser_on_file(&connect_signals, 
Glib::filename_to_uri(filename));
diff --git a/tests/python/test_python_execute_func_with_record.cc 
b/tests/python/test_python_execute_func_with_record.cc
index fee242a..8d37564 100644
--- a/tests/python/test_python_execute_func_with_record.cc
+++ b/tests/python/test_python_execute_func_with_record.cc
@@ -38,7 +38,7 @@ int main()
 
   try
   {
-    const std::string path =
+    const auto path =
        Glib::build_filename(GLOM_DOCDIR_EXAMPLES_NOTINSTALLED,
          "sqlite", "test_sqlite_music", "test_sqlite_music.glom");
     uri = Glib::filename_to_uri(path);
diff --git a/tests/test_document_load.cc b/tests/test_document_load.cc
index b5e5ad2..da4dbcb 100644
--- a/tests/test_document_load.cc
+++ b/tests/test_document_load.cc
@@ -126,7 +126,7 @@ int main()
 
   try
   {
-    const std::string path =
+    const auto path =
        Glib::build_filename(GLOM_DOCDIR_EXAMPLES_NOTINSTALLED,
          "example_film_manager.glom");
     uri = Glib::filename_to_uri(path);
@@ -210,7 +210,7 @@ int main()
   const Glom::Document::type_list_layout_groups groups = 
     document->get_data_layout_groups("details", "scenes");
   g_assert(groups.size() == 3);
-  const std::shared_ptr<const Glom::LayoutGroup> group =
+  const auto group =
     groups[1];
   const Glom::LayoutGroup::type_list_const_items items = 
     group->get_items_recursive();
@@ -267,7 +267,7 @@ int main()
 
 
   //Test print layouts:  
-  const std::vector<Glib::ustring> print_layout_names = 
+  const auto print_layout_names = 
     document->get_print_layout_names("contacts");
   if(print_layout_names.size() != 1)
   {
@@ -301,7 +301,7 @@ int main()
   }
 
 
-  const std::vector<Glib::ustring> report_names = 
+  const auto report_names = 
     document->get_report_names("contacts");
   if(report_names.size() != 2)
   {
diff --git a/tests/test_document_load_and_change.cc b/tests/test_document_load_and_change.cc
index a13138a..4946462 100644
--- a/tests/test_document_load_and_change.cc
+++ b/tests/test_document_load_and_change.cc
@@ -65,7 +65,7 @@ int main()
 
   try
   {
-    const std::string path =
+    const auto path =
       Glib::build_filename(GLOM_DOCDIR_EXAMPLES_NOTINSTALLED,
         "example_smallbusiness.glom");
     uri = Glib::filename_to_uri(path);
diff --git a/tests/test_document_load_image.cc b/tests/test_document_load_image.cc
index db1e1ea..dc3c393 100644
--- a/tests/test_document_load_image.cc
+++ b/tests/test_document_load_image.cc
@@ -37,7 +37,7 @@ int main()
 
   try
   {
-    const std::string path =
+    const auto path =
        Glib::build_filename(GLOM_DOCDIR_EXAMPLES_NOTINSTALLED,
    "example_project_manager.glom");
     uri = Glib::filename_to_uri(path);
@@ -72,7 +72,7 @@ int main()
   const Glom::Document::type_list_layout_groups groups = 
     document->get_data_layout_groups("details", "projects");
   g_assert(groups.size() == 3);
-  const std::shared_ptr<const Glom::LayoutGroup> group =
+  const auto group =
     groups[0];
   g_assert(group);
   g_assert(group->get_name() == "overview");
diff --git a/tests/test_document_load_translations.cc b/tests/test_document_load_translations.cc
index 73b53bf..b37c512 100644
--- a/tests/test_document_load_translations.cc
+++ b/tests/test_document_load_translations.cc
@@ -156,7 +156,7 @@ int main()
 
   try
   {
-    const std::string path =
+    const auto path =
        Glib::build_filename(GLOM_DOCDIR_EXAMPLES_NOTINSTALLED,
          "example_film_manager.glom");
     uri = Glib::filename_to_uri(path);
diff --git a/tests/test_fake_connection.cc b/tests/test_fake_connection.cc
index 9433bd2..541549b 100644
--- a/tests/test_fake_connection.cc
+++ b/tests/test_fake_connection.cc
@@ -37,7 +37,7 @@ int main()
 
   try
   {
-    const std::string path =
+    const auto path =
        Glib::build_filename(GLOM_DOCDIR_EXAMPLES_NOTINSTALLED,
          "example_music_collection.glom");
     uri = Glib::filename_to_uri(path);
diff --git a/tests/test_utils.cc b/tests/test_utils.cc
index abf139e..8f7d04f 100644
--- a/tests/test_utils.cc
+++ b/tests/test_utils.cc
@@ -75,7 +75,7 @@ Gnome::Gda::Value get_value_for_image_from_file(const std::string& filename)
 Gnome::Gda::Value get_value_for_image()
 {
   //Fill a value from a file:
-  const std::string filename =
+  const auto filename =
     Glib::build_filename(GLOM_TESTS_IMAGE_DATA_NOTINSTALLED, "test_image.jpg");
   return get_value_for_image_from_file(filename);
 }
diff --git a/tests/translations_po/test_document_export_po.cc 
b/tests/translations_po/test_document_export_po.cc
index 38e1cf5..f225823 100644
--- a/tests/translations_po/test_document_export_po.cc
+++ b/tests/translations_po/test_document_export_po.cc
@@ -73,7 +73,7 @@ int main()
 
   try
   {
-    const std::string path =
+    const auto path =
        Glib::build_filename(GLOM_DOCDIR_EXAMPLES_NOTINSTALLED,
          "example_film_manager.glom");
     uri = Glib::filename_to_uri(path);
diff --git a/tests/translations_po/test_document_import_po.cc 
b/tests/translations_po/test_document_import_po.cc
index 52bd679..ad90a76 100644
--- a/tests/translations_po/test_document_import_po.cc
+++ b/tests/translations_po/test_document_import_po.cc
@@ -38,7 +38,7 @@ int main()
 
   try
   {
-    const std::string path =
+    const auto path =
        Glib::build_filename(GLOM_DOCDIR_EXAMPLES_NOTINSTALLED,
          "example_film_manager.glom");
     uri = Glib::filename_to_uri(path);
@@ -70,7 +70,7 @@ int main()
   Glib::ustring po_file_uri;
   try
   {
-    const std::string path =
+    const auto path =
       Glib::build_filename(GLOM_TESTS_TRANSLATIONS_PO_DATA_NOTINSTALLED,
         "test.po");
     po_file_uri = Glib::filename_to_uri(path);
diff --git a/tests/ui/test_imageglom_widget.cc b/tests/ui/test_imageglom_widget.cc
index 3c05175..462c414 100644
--- a/tests/ui/test_imageglom_widget.cc
+++ b/tests/ui/test_imageglom_widget.cc
@@ -32,7 +32,7 @@ const std::string IMAGE_FILE_PDF2 = "test_image2.pdf";
 
 auto get_image(const std::string& name)
 {
-  const std::string filename =
+  const auto filename =
     Glib::build_filename(GLOM_TESTS_IMAGE_DATA_NOTINSTALLED, name);
   return get_value_for_image_from_file(filename);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]