From 9fb3ef793901a3e5fdfdd992b3dd49b199065b3d Mon Sep 17 00:00:00 2001 From: Teus Benschop Date: Thu, 18 Apr 2024 17:33:45 +0200 Subject: [PATCH] Make namespace std clearer --- changes/modifications.cpp | 179 +++++++++++++++++++------------------- changes/statistics.cpp | 31 ++++--- checks/french.cpp | 49 +++++------ checks/headers.cpp | 11 ++- checks/logic.cpp | 9 +- checks/pairs.cpp | 49 +++++------ pkgdata/files.txt | 1 + 7 files changed, 162 insertions(+), 167 deletions(-) diff --git a/changes/modifications.cpp b/changes/modifications.cpp index 0f2a303f8..5606e4d1a 100644 --- a/changes/modifications.cpp +++ b/changes/modifications.cpp @@ -42,50 +42,49 @@ #include #include #include -using namespace std; // Internal function declarations. void changes_process_identifiers (Webserver_Request& webserver_request, - const string & user, - const vector & recipients, - const string & bible, + const std::string& user, + const std::vector & recipients, + const std::string& bible, int book, int chapter, - const map > & bibles_per_user, + const std::map > & bibles_per_user, int oldId, int newId, - string & email, - int & change_count, float & time_total, int & time_count); + std::string& email, + int& change_count, float& time_total, int& time_count); // Helper function. // $user: The user whose changes are being processed. // $recipients: The users who opted for receiving online notifications of any contributor. void changes_process_identifiers (Webserver_Request& webserver_request, - const string & user, - const vector & recipients, - const string & bible, + const std::string& user, + const std::vector & recipients, + const std::string& bible, int book, int chapter, - const map > & bibles_per_user, + const std::map > & bibles_per_user, int oldId, int newId, - string & email, - int & change_count, float & time_total, int & time_count) + std::string& email, + int& change_count, float& time_total, int& time_count) { if (oldId != 0) { Database_Modifications database_modifications {}; - string stylesheet = Database_Config_Bible::getExportStylesheet (bible); + const std::string stylesheet = Database_Config_Bible::getExportStylesheet (bible); Database_Modifications_Text old_chapter_text = database_modifications.getUserChapter (user, bible, book, chapter, oldId); - string old_chapter_usfm = old_chapter_text.oldtext; + const std::string old_chapter_usfm = old_chapter_text.oldtext; Database_Modifications_Text new_chapter_text = database_modifications.getUserChapter (user, bible, book, chapter, newId); - string new_chapter_usfm = new_chapter_text.newtext; - vector old_verse_numbers = filter::usfm::get_verse_numbers (old_chapter_usfm); - vector new_verse_numbers = filter::usfm::get_verse_numbers (new_chapter_usfm); - vector verses = old_verse_numbers; + const std::string new_chapter_usfm = new_chapter_text.newtext; + const std::vector old_verse_numbers = filter::usfm::get_verse_numbers (old_chapter_usfm); + const std::vector new_verse_numbers = filter::usfm::get_verse_numbers (new_chapter_usfm); + std::vector verses = old_verse_numbers; verses.insert (verses.end (), new_verse_numbers.begin (), new_verse_numbers.end ()); verses = filter::strings::array_unique (verses); - sort (verses.begin(), verses.end()); - for (auto verse : verses) { - string old_verse_usfm = filter::usfm::get_verse_text (old_chapter_usfm, verse); - string new_verse_usfm = filter::usfm::get_verse_text (new_chapter_usfm, verse); + std::sort (verses.begin(), verses.end()); + for (const auto verse : verses) { + const std::string old_verse_usfm = filter::usfm::get_verse_text (old_chapter_usfm, verse); + const std::string new_verse_usfm = filter::usfm::get_verse_text (new_chapter_usfm, verse); if (old_verse_usfm != new_verse_usfm) { Filter_Text filter_text_old = Filter_Text (bible); Filter_Text filter_text_new = Filter_Text (bible); @@ -97,12 +96,12 @@ void changes_process_identifiers (Webserver_Request& webserver_request, filter_text_new.add_usfm_code (new_verse_usfm); filter_text_old.run (stylesheet); filter_text_new.run (stylesheet); - string old_html = filter_text_old.html_text_standard->get_inner_html (); - string new_html = filter_text_new.html_text_standard->get_inner_html (); - string old_text = filter_text_old.text_text->get (); - string new_text = filter_text_new.text_text->get (); + const std::string old_html = filter_text_old.html_text_standard->get_inner_html (); + const std::string new_html = filter_text_new.html_text_standard->get_inner_html (); + const std::string old_text = filter_text_old.text_text->get (); + const std::string new_text = filter_text_new.text_text->get (); if (old_text != new_text) { - string modification = filter_diff_diff (old_text, new_text); + const std::string modification = filter_diff_diff (old_text, new_text); email += "
"; email += filter_passage_display (book, chapter, filter::strings::convert_to_string (verse)); email += " "; @@ -112,7 +111,7 @@ void changes_process_identifiers (Webserver_Request& webserver_request, database_modifications.recordNotification ({user}, changes_personal_category (), bible, book, chapter, verse, old_html, modification, new_html); } // Go over all the receipients to record the change for them. - for (auto recipient : recipients) { + for (const auto& recipient : recipients) { // The author of this change does not get a notification for it. if (recipient == user) continue; // The recipient may have set which Bibles to get the change notifications for. @@ -120,7 +119,7 @@ void changes_process_identifiers (Webserver_Request& webserver_request, // container [user] = list of bibles. bool receive {true}; try { - const vector & bibles = bibles_per_user.at(recipient); + const std::vector & bibles = bibles_per_user.at(recipient); receive = in_array(bible, bibles); } catch (...) {} if (!receive) continue; @@ -159,10 +158,10 @@ void changes_modifications () // Get the users who will receive the changes entered by the named contributors. - vector recipients_named_contributors; + std::vector recipients_named_contributors; { - vector users = webserver_request.database_users ()->get_users (); - for (const auto & user : users) { + const std::vector users = webserver_request.database_users ()->get_users (); + for (const auto& user : users) { if (webserver_request.database_config_user ()->getContributorChangesNotificationsOnline (user)) { recipients_named_contributors.push_back (user); } @@ -170,7 +169,7 @@ void changes_modifications () } // Storage for the statistics. - map user_change_statistics {}; + std::map user_change_statistics {}; float modification_time_total {0.0f}; int modification_time_count {0}; @@ -178,11 +177,11 @@ void changes_modifications () // will get the change notifications from. // This setting affects the changes made by all users. // Note: A user will always receive notificatons of changes made by that same user. - map > notification_bibles_per_user {}; + std::map > notification_bibles_per_user {}; { - vector users = webserver_request.database_users ()->get_users (); + const std::vector users = webserver_request.database_users ()->get_users (); for (const auto & user : users) { - vector bibles = webserver_request.database_config_user ()->getChangeNotificationsBiblesForUser (user); + const std::vector bibles = webserver_request.database_config_user ()->getChangeNotificationsBiblesForUser (user); notification_bibles_per_user [user] = bibles; } } @@ -194,31 +193,31 @@ void changes_modifications () // This produces the desired order of the notifications in the GUI. // At the same time, produce change statistics per user. - vector users = database_modifications.getUserUsernames (); + std::vector users = database_modifications.getUserUsernames (); if (!users.empty ()) Database_Logs::log ("Change notifications: Per user", Filter_Roles::translator ()); - for (const auto & user : users) { + for (const auto& user : users) { // Total changes made by this user. int change_count {0}; // Go through the Bibles changed by the current user. - vector bibles = database_modifications.getUserBibles (user); - for (const auto & bible : bibles) { + std::vector bibles = database_modifications.getUserBibles (user); + for (const auto& bible : bibles) { // Body of the email to be sent. - string email = "

" + translate("You have entered the changes below in a Bible editor.") + " " + translate ("You may check if it made its way into the Bible text.") + "

"; + std::string email = "

" + translate("You have entered the changes below in a Bible editor.") + " " + translate ("You may check if it made its way into the Bible text.") + "

"; size_t empty_email_length = email.length (); // Go through the books in that Bible. - vector books = database_modifications.getUserBooks (user, bible); + const std::vector books = database_modifications.getUserBooks (user, bible); for (auto book : books) { // Go through the chapters in that book. - vector chapters = database_modifications.getUserChapters (user, bible, book); + const std::vector chapters = database_modifications.getUserChapters (user, bible, book); for (auto chapter : chapters) { // Get the sets of identifiers for that chapter, and set some variables. - vector IdSets = database_modifications.getUserIdentifiers (user, bible, book, chapter); + const std::vector IdSets = database_modifications.getUserIdentifiers (user, bible, book, chapter); int reference_new_id {0}; int new_id {0}; int last_new_id {0}; @@ -255,7 +254,7 @@ void changes_modifications () if (email.length () != empty_email_length) { // Send the user email with the user's personal changes if the user opted to receive it. if (webserver_request.database_config_user()->getUserUserChangesNotification (user)) { - string subject = translate("Changes you entered in") + " " + bible; + const std::string subject = translate("Changes you entered in") + " " + bible; if (!client_logic_client_enabled ()) email_schedule (user, subject, email); } } @@ -276,16 +275,16 @@ void changes_modifications () // Generate the notifications, online and by email, // for the changes in the Bibles entered by anyone // since the previous notifications were generated. - vector bibles = database_modifications.getTeamDiffBibles (); + std::vector bibles = database_modifications.getTeamDiffBibles (); for (const auto & bible : bibles) { - string stylesheet = Database_Config_Bible::getExportStylesheet (bible); + const std::string stylesheet = Database_Config_Bible::getExportStylesheet (bible); - vector changeNotificationUsers; - vector all_users = webserver_request.database_users ()->get_users (); - for (const auto & user : all_users) { + std::vector changeNotificationUsers; + std::vector all_users = webserver_request.database_users ()->get_users (); + for (const auto& user : all_users) { if (access_bible::read (webserver_request, bible, user)) { if (webserver_request.database_config_user()->getUserGenerateChangeNotifications (user)) { // The recipient may have set which Bibles to get the change notifications for. @@ -293,7 +292,7 @@ void changes_modifications () // container [user] = list of bibles. bool receive {true}; try { - const vector & user_bibles = notification_bibles_per_user.at(user); + const std::vector & user_bibles = notification_bibles_per_user.at(user); receive = in_array(bible, user_bibles); } catch (...) {} if (receive) { @@ -310,8 +309,8 @@ void changes_modifications () // The files get stored at http://site.org:/revisions// - int seconds = filter::date::seconds_since_epoch (); - string timepath; + const int seconds = filter::date::seconds_since_epoch (); + std::string timepath; timepath.append (filter::strings::convert_to_string (filter::date::numerical_year (seconds))); timepath.append ("-"); timepath.append (filter::strings::fill (filter::strings::convert_to_string (filter::date::numerical_month (seconds)), 2, '0')); @@ -323,7 +322,7 @@ void changes_modifications () timepath.append (filter::strings::fill (filter::strings::convert_to_string (filter::date::numerical_minute (seconds)), 2, '0')); timepath.append (":"); timepath.append (filter::strings::fill (filter::strings::convert_to_string (filter::date::numerical_second (seconds)), 2, '0')); - string directory = filter_url_create_root_path ({"revisions", bible, timepath}); + const std::string directory = filter_url_create_root_path ({"revisions", bible, timepath}); filter_url_mkdir (directory); @@ -332,38 +331,38 @@ void changes_modifications () // Create online page with changed verses. - string versesoutputfile = filter_url_create_path ({directory, "changed_verses.html"}); + const std::string versesoutputfile = filter_url_create_path ({directory, "changed_verses.html"}); filter_diff_run_file (filter_url_create_path ({directory, "verses_old.txt"}), filter_url_create_path ({directory, "verses_new.txt"}), versesoutputfile); // Storage for body of the email with the changes. - vector email_changes {}; + std::vector email_changes {}; // Generate the online change notifications. - vector books = database_modifications.getTeamDiffBooks (bible); + const std::vector books = database_modifications.getTeamDiffBooks (bible); for (auto book : books) { - vector chapters = database_modifications.getTeamDiffChapters (bible, book); + const std::vector chapters = database_modifications.getTeamDiffChapters (bible, book); for (auto chapter : chapters) { Database_Logs::log ("Change notifications: " + bible + " " + filter_passage_display (book, chapter, ""), Filter_Roles::translator ()); - string old_chapter_usfm = database_modifications.getTeamDiff (bible, book, chapter); - string new_chapter_usfm = webserver_request.database_bibles()->get_chapter (bible, book, chapter); - vector old_verse_numbers = filter::usfm::get_verse_numbers (old_chapter_usfm); - vector new_verse_numbers = filter::usfm::get_verse_numbers (new_chapter_usfm); - vector verses = old_verse_numbers; + const std::string old_chapter_usfm = database_modifications.getTeamDiff (bible, book, chapter); + const std::string new_chapter_usfm = webserver_request.database_bibles()->get_chapter (bible, book, chapter); + const std::vector old_verse_numbers = filter::usfm::get_verse_numbers (old_chapter_usfm); + const std::vector new_verse_numbers = filter::usfm::get_verse_numbers (new_chapter_usfm); + std::vector verses = old_verse_numbers; verses.insert (verses.end (), new_verse_numbers.begin (), new_verse_numbers.end ()); verses = filter::strings::array_unique (verses); - sort (verses.begin (), verses.end()); + std::sort (verses.begin (), verses.end()); for (auto verse : verses) { - string old_verse_usfm = filter::usfm::get_verse_text (old_chapter_usfm, verse); - string new_verse_usfm = filter::usfm::get_verse_text (new_chapter_usfm, verse); + const std::string old_verse_usfm = filter::usfm::get_verse_text (old_chapter_usfm, verse); + const std::string new_verse_usfm = filter::usfm::get_verse_text (new_chapter_usfm, verse); if (old_verse_usfm != new_verse_usfm) { processedChangesCount++; // In case of too many change notifications, processing them would take too much time, so take a few shortcuts. - string old_html = "

" + old_verse_usfm + "

"; - string new_html = "

" + new_verse_usfm + "

"; - string old_text = old_verse_usfm; - string new_text = new_verse_usfm; + std::string old_html = "

" + old_verse_usfm + "

"; + std::string new_html = "

" + new_verse_usfm + "

"; + std::string old_text = old_verse_usfm; + std::string new_text = new_verse_usfm; if (processedChangesCount < 800) { Filter_Text filter_text_old = Filter_Text (bible); Filter_Text filter_text_new = Filter_Text (bible); @@ -380,9 +379,9 @@ void changes_modifications () old_text = filter_text_old.text_text->get (); new_text = filter_text_new.text_text->get (); } - string modification = filter_diff_diff (old_text, new_text); + const std::string modification = filter_diff_diff (old_text, new_text); database_modifications.recordNotification (changeNotificationUsers, changes_bible_category (), bible, book, chapter, verse, old_html, modification, new_html); - string passage = filter_passage_display (book, chapter, filter::strings::convert_to_string (verse)) + ": "; + const std::string passage = filter_passage_display (book, chapter, filter::strings::convert_to_string (verse)) + ": "; if (old_text != new_text) { email_changes.push_back (passage + modification); } else { @@ -409,9 +408,9 @@ void changes_modifications () // then each part should remain well below that maximum size. // The size was reduced even more later on: // https://github.com/bibledit/cloud/issues/727 - vector bodies {}; + std::vector bodies {}; int counter {0}; - string body {}; + std::string body {}; for (const auto & line : email_changes) { body.append ("
"); body.append (line); @@ -425,12 +424,12 @@ void changes_modifications () } if (!body.empty ()) bodies.push_back (body); for (size_t b = 0; b < bodies.size (); b++) { - string subject = translate("Recent changes:") + " " + bible; + std::string subject = translate("Recent changes:") + " " + bible; if (bodies.size () > 1) { subject.append (" (" + filter::strings::convert_to_string (b + 1) + "/" + filter::strings::convert_to_string (bodies.size ()) + ")"); } - vector all_users_2 = webserver_request.database_users ()->get_users (); - for (auto & user : all_users_2) { + const std::vector all_users_2 = webserver_request.database_users ()->get_users (); + for (const auto& user : all_users_2) { if (webserver_request.database_config_user()->getUserBibleChangesNotification (user)) { if (access_bible::read (webserver_request, bible, user)) { if (!client_logic_client_enabled ()) { @@ -450,21 +449,21 @@ void changes_modifications () // Remove expired downloadable revisions. - string directory = filter_url_create_root_path ({"revisions"}); - int now = filter::date::seconds_since_epoch (); + const std::string directory = filter_url_create_root_path ({"revisions"}); + const int now = filter::date::seconds_since_epoch (); bibles = filter_url_scandir (directory); for (const auto & bible : bibles) { - string folder = filter_url_create_path ({directory, bible}); + const std::string folder = filter_url_create_path ({directory, bible}); int time = filter_url_file_modification_time (folder); int days = (now - time) / 86400; if (days > 31) { filter_url_rmdir (folder); } else { - vector revisions = filter_url_scandir (folder); - for (auto & revision : revisions) { - string path = filter_url_create_path ({folder, revision}); - int time2 = filter_url_file_modification_time (path); - int days2 = (now - time2) / 86400; + const std::vector revisions = filter_url_scandir (folder); + for (const auto& revision : revisions) { + const std::string path = filter_url_create_path ({folder, revision}); + const int time2 = filter_url_file_modification_time (path); + const int days2 = (now - time2) / 86400; if (days2 > 31) { filter_url_rmdir (path); Database_Logs::log ("Removing expired downloadable revision notification: " + bible + " " + revision, Filter_Roles::translator ()); @@ -493,11 +492,11 @@ void changes_modifications () // Store the statistics in the database. if (modification_time_count) { // Take average timestamp of all timestamps. - int timestamp = static_cast (round (modification_time_total / static_cast(modification_time_count))); - for (auto & element : user_change_statistics) { + const int timestamp = static_cast (round (modification_time_total / static_cast(modification_time_count))); + for (const auto & element : user_change_statistics) { // Store dated change statistics per user. - string user = element.first; - int count = element.second; + const std::string& user = element.first; + const int count = element.second; Database_Statistics::store_changes (timestamp, user, count); } } diff --git a/changes/statistics.cpp b/changes/statistics.cpp index 8a12e24e9..0837df1f2 100644 --- a/changes/statistics.cpp +++ b/changes/statistics.cpp @@ -28,14 +28,13 @@ #include #include #include -using namespace std; // Internal function declarations. -void changes_statistics_add (Assets_View & view, const string & date, int count); +void changes_statistics_add (Assets_View& view, const std::string& date, int count); -string changes_statistics_url () +std::string changes_statistics_url () { return "changes/statistics"; } @@ -47,10 +46,10 @@ bool changes_statistics_acl (Webserver_Request& webserver_request) } -void changes_statistics_add (Assets_View& view, const string& date, int count) +void changes_statistics_add (Assets_View& view, const std::string& date, int count) { if (count) { - map values; + std::map values; values ["date"] = date; values ["count"] = filter::strings::convert_to_string (count); view.add_iteration ("statistics", values); @@ -58,30 +57,30 @@ void changes_statistics_add (Assets_View& view, const string& date, int count) } -string changes_statistics ([[maybe_unused]] Webserver_Request& webserver_request) +std::string changes_statistics ([[maybe_unused]] Webserver_Request& webserver_request) { #ifdef HAVE_CLIENT - return string(); + return std::string(); #endif #ifdef HAVE_CLOUD - string page {}; + std::string page {}; Assets_Header header = Assets_Header (translate("Change statistics"), webserver_request); page += header.run (); Assets_View view {}; - string everyone = translate ("Everyone"); - string user = webserver_request.query["user"]; + const std::string everyone = translate ("Everyone"); + std::string user = webserver_request.query["user"]; if (user == everyone) user.clear (); - vector > changes = Database_Statistics::get_changes (user); - string last_date {}; + std::vector > changes = Database_Statistics::get_changes (user); + std::string last_date {}; int last_count {0}; - for (const auto & element : changes) { - const string date = locale_logic_date (element.first); + for (const auto& element : changes) { + const std::string date = locale_logic_date (element.first); const int count = element.second; if (date == last_date) { last_count += count; @@ -96,10 +95,10 @@ string changes_statistics ([[maybe_unused]] Webserver_Request& webserver_request } - vector users = Database_Statistics::get_users (); + std::vector users = Database_Statistics::get_users (); users.push_back (everyone); for (size_t i = 0; i < users.size (); i++) { - map values; + std::map values; if (i) values ["divider"] = "|"; values ["user"] = users[i]; view.add_iteration ("users", values); diff --git a/checks/french.cpp b/checks/french.cpp index 22da43310..eaa6a4d78 100644 --- a/checks/french.cpp +++ b/checks/french.cpp @@ -22,24 +22,23 @@ #include #include #include -using namespace std; // In French there is a no-break space after the « and before the » ! ? : ; // The Unicode value for the no-break space is U+00A0. // Another type of non-breaking space will be acceptable too. -void checks_french::space_before_after_punctuation (const string & bible, int book, int chapter, - const map & texts) +void checks_french::space_before_after_punctuation (const std::string& bible, int book, int chapter, + const std::map & texts) { Database_Check database_check {}; - string nbsp = filter::strings::non_breaking_space_u00A0 (); - string nnbsp = filter::strings::narrow_non_breaking_space_u202F (); - vector right_punctuation = { right_guillemet(), "!", "?", ":", ";" }; + const std::string nbsp = filter::strings::non_breaking_space_u00A0 (); + const std::string nnbsp = filter::strings::narrow_non_breaking_space_u202F (); + const std::vector right_punctuation = { right_guillemet(), "!", "?", ":", ";" }; for (const auto & element : texts) { int verse = element.first; { - string text = element.second; + std::string text = element.second; size_t pos = text.find (left_guillemet ()); while (pos != std::string::npos) { text.erase (0, pos + left_guillemet ().size ()); @@ -47,10 +46,10 @@ void checks_french::space_before_after_punctuation (const string & bible, int bo bool nbsp_follows = text.find (nbsp) == 0; bool nnbsp_follows = text.find (nnbsp) == 0; if (space_follows) { - string message = left_guillemet () + " - " + translate ("Should be followed by a no-break space rather than a plain space in French"); + const std::string message = left_guillemet () + " - " + translate ("Should be followed by a no-break space rather than a plain space in French"); database_check.recordOutput (bible, book, chapter, verse, message); } else if (!nbsp_follows && !nnbsp_follows) { - string message = left_guillemet () + " - " + translate ("Should be followed by a no-break space in French"); + const std::string message = left_guillemet () + " - " + translate ("Should be followed by a no-break space in French"); database_check.recordOutput (bible, book, chapter, verse, message); } pos = text.find (left_guillemet ()); @@ -58,20 +57,20 @@ void checks_french::space_before_after_punctuation (const string & bible, int bo } for (const auto & punctuation : right_punctuation) { - string text = element.second; + std::string text = element.second; // The location of this punctuation character. size_t pos = filter::strings::unicode_string_strpos (text, punctuation); while (pos != std::string::npos) { if (pos > 0) { - string preceding_character = filter::strings::unicode_string_substr (text, pos - 1, 1); + const std::string preceding_character = filter::strings::unicode_string_substr (text, pos - 1, 1); if (preceding_character == " ") { - string message = punctuation + " - " + translate ("Should be preceded by a no-break space rather than a plain space in French"); + const std::string message = punctuation + " - " + translate ("Should be preceded by a no-break space rather than a plain space in French"); database_check.recordOutput (bible, book, chapter, verse, message); } else if (preceding_character == nbsp) { /* This is OK. */ } else if (preceding_character == nnbsp) { /* This is OK. */ } else { - string message = punctuation + " - " + translate ("Should be preceded by a no-break space in French"); + const std::string message = punctuation + " - " + translate ("Should be preceded by a no-break space in French"); database_check.recordOutput (bible, book, chapter, verse, message); } } @@ -90,8 +89,8 @@ void checks_french::space_before_after_punctuation (const string & bible, int bo // « This is the text of the citation. // « This is a new paragraph, and it ends the citation ». // This checks on that style. -void checks_french::citation_style (const string & bible, int book, int chapter, - const vector > & verses_paragraphs) +void checks_french::citation_style (const std::string & bible, int book, int chapter, + const std::vector >& verses_paragraphs) { Database_Check database_check {}; @@ -103,7 +102,7 @@ void checks_french::citation_style (const string & bible, int book, int chapter, for (unsigned int paragraph_counter = 0; paragraph_counter < verses_paragraphs.size (); paragraph_counter++) { // Container with verse numbers as the keys, plus the text of the whole paragraph. - const map verses_paragraph = verses_paragraphs [paragraph_counter]; + const std::map verses_paragraph = verses_paragraphs [paragraph_counter]; // Skip empty containers. if (verses_paragraph.empty ()) continue; @@ -114,11 +113,11 @@ void checks_french::citation_style (const string & bible, int book, int chapter, if (paragraph_counter) { if (previous_paragraph_open_citation) { int verse = verses_paragraph.begin()->first; - string text = verses_paragraph.begin()->second; + const std::string text = verses_paragraph.begin()->second; if (!text.empty ()) { - string character = filter::strings::unicode_string_substr (text, 0, 1); + const std::string character = filter::strings::unicode_string_substr (text, 0, 1); if (character != left_guillemet ()) { - string message = translate ("The previous paragraph contains a citation not closed with a » therefore the current paragraph is expected to start with a « to continue that citation in French"); + const std::string message = translate ("The previous paragraph contains a citation not closed with a » therefore the current paragraph is expected to start with a « to continue that citation in French"); database_check.recordOutput (bible, book, chapter, verse, message); } } @@ -127,8 +126,8 @@ void checks_french::citation_style (const string & bible, int book, int chapter, // Count the number of left and right guillements in the paragraph. int last_verse {0}; - string paragraph {}; - for (const auto & element : verses_paragraph) { + std::string paragraph {}; + for (const auto& element : verses_paragraph) { paragraph.append (element.second); last_verse = element.first; } @@ -142,26 +141,26 @@ void checks_french::citation_style (const string & bible, int book, int chapter, // Whether there's too many left guillements. if (opener_count > (closer_count + 1)) { - string message = translate ("The paragraph contains more left guillements than needed"); + const std::string message = translate ("The paragraph contains more left guillements than needed"); database_check.recordOutput (bible, book, chapter, last_verse, message); } // Whether there's too many right guillements. if (closer_count > opener_count) { - string message = translate ("The paragraph contains more right guillements than needed"); + const std::string message = translate ("The paragraph contains more right guillements than needed"); database_check.recordOutput (bible, book, chapter, last_verse, message); } } } -string checks_french::left_guillemet () +std::string checks_french::left_guillemet () { return "«"; } -string checks_french::right_guillemet () +std::string checks_french::right_guillemet () { return "»"; } diff --git a/checks/headers.cpp b/checks/headers.cpp index 24cf15e02..0ecfeb38f 100644 --- a/checks/headers.cpp +++ b/checks/headers.cpp @@ -21,21 +21,20 @@ #include #include #include -using namespace std; -void checks_headers::no_punctuation_at_end (const string & bible, int book, int chapter, - const map & headings, - const string & centermarks, const string & endmarks) +void checks_headers::no_punctuation_at_end (const std::string& bible, int book, int chapter, + const std::map & headings, + const std::string& centermarks, const std::string& endmarks) { Database_Check database_check {}; for (const auto & element : headings) { int verse = element.first; - string heading = element.second; + const std::string heading = element.second; // Full stops often occur in the inspired headings of many Psalms in verse 0. // Skip these. if ((book == 19) && (verse == 0)) continue; - string last_character {}; + std::string last_character {}; if (!heading.empty ()) last_character = heading.substr (heading.size () - 1); bool message {false}; if (centermarks.find (last_character) != std::string::npos) message = true; diff --git a/checks/logic.cpp b/checks/logic.cpp index de4a53805..5e0d0843b 100644 --- a/checks/logic.cpp +++ b/checks/logic.cpp @@ -21,21 +21,20 @@ #include #include #include -using namespace std; void checks_logic_start_all () { Database_Bibles database_bibles {}; - const vector & bibles = database_bibles.get_bibles (); - for (const auto & bible : bibles) { - bool enabled = Database_Config_Bible::getDailyChecksEnabled (bible); + const std::vector & bibles = database_bibles.get_bibles (); + for (const auto& bible : bibles) { + const bool enabled = Database_Config_Bible::getDailyChecksEnabled (bible); if (enabled) checks_logic_start (bible); } } -void checks_logic_start (const string & bible) +void checks_logic_start (const std::string& bible) { tasks_logic_queue (CHECKBIBLE, {bible}); } diff --git a/checks/pairs.cpp b/checks/pairs.cpp index 55654ca72..0d331fc1b 100644 --- a/checks/pairs.cpp +++ b/checks/pairs.cpp @@ -23,28 +23,27 @@ #include #include #include -using namespace std; -void checks_pairs::run (const string & bible, int book, int chapter, - const map & texts, - const vector > & pairs, +void checks_pairs::run (const std::string& bible, int book, int chapter, + const std::map & texts, + const std::vector >& pairs, bool french_citation_style) { // This holds the opener characters of the pairs which were opened in the text. // For example, it may hold the "[". - vector verses {}; - vector opened {}; + std::vector verses {}; + std::vector opened {}; // Containers with the openers and the closers. // If the check on the French citation style is active, // skip the French guillemets. - vector openers {}; - vector closers {}; - for (const auto & element : pairs) { - string opener = element.first; + std::vector openers {}; + std::vector closers {}; + for (const auto& element : pairs) { + const std::string opener = element.first; if (french_citation_style && (opener == checks_french::left_guillemet ())) continue; - string closer = element.second; + const std::string closer = element.second; if (french_citation_style && (opener == checks_french::right_guillemet ())) continue; openers.push_back (opener); closers.push_back (closer); @@ -55,11 +54,11 @@ void checks_pairs::run (const string & bible, int book, int chapter, // Go through the verses with their texts. for (const auto & element : texts) { int verse = element.first; - string text = element.second; + std::string text = element.second; size_t length = filter::strings::unicode_string_length (text); for (size_t pos = 0; pos < length; pos++) { - string character = filter::strings::unicode_string_substr (text, pos, 1); + const std::string character = filter::strings::unicode_string_substr (text, pos, 1); if (in_array (character, openers)) { verses.push_back (verse); @@ -68,7 +67,7 @@ void checks_pairs::run (const string & bible, int book, int chapter, if (in_array (character, closers)) { - string opener = match (character, pairs); + const std::string opener = match (character, pairs); bool mismatch = false; if (opened.empty ()) { mismatch = true; @@ -79,9 +78,9 @@ void checks_pairs::run (const string & bible, int book, int chapter, mismatch = true; } if (mismatch) { - string fragment1 = translate ("Closing character"); - string fragment2 = translate ("without its matching opening character"); - stringstream message; + const std::string fragment1 = translate ("Closing character"); + const std::string fragment2 = translate ("without its matching opening character"); + std::stringstream message {}; message << fragment1 << " " << quoted(character) << " " << fragment2 << " " << quoted(opener); database_check.recordOutput (bible, book, chapter, verse, message.str()); } @@ -92,22 +91,22 @@ void checks_pairs::run (const string & bible, int book, int chapter, // Report unclosed openers. for (size_t i = 0; i < verses.size (); i++) { int verse = verses [i]; - string opener = opened [i]; - string closer = match (opener, pairs); - string fragment1 = translate ("Opening character"); - string fragment2 = translate ("without its matching closing character"); - stringstream message; + const std::string opener = opened [i]; + const std::string closer = match (opener, pairs); + const std::string fragment1 = translate ("Opening character"); + const std::string fragment2 = translate ("without its matching closing character"); + std::stringstream message {}; message << fragment1 << " " << quoted(opener) << " " << fragment2 << " " << quoted(closer); database_check.recordOutput (bible, book, chapter, verse, message.str()); } } -string checks_pairs::match (const string & character, const vector > & pairs) +std::string checks_pairs::match (const std::string & character, const std::vector >& pairs) { - for (auto & element : pairs) { + for (const auto& element : pairs) { if (character == element.first) return element.second; if (character == element.second) return element.first; } - return string(); + return std::string(); } diff --git a/pkgdata/files.txt b/pkgdata/files.txt index 5ad4a4c9c..c95b0ae5a 100644 --- a/pkgdata/files.txt +++ b/pkgdata/files.txt @@ -342,6 +342,7 @@ /jsonxx/LICENSE /ldap /lexicon +/libbibledit.a.yHm3kK /library /livetest /livetest/initialize.sh