Skip to content

Commit

Permalink
Make namespace std explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
teusbenschop committed Apr 18, 2024
1 parent dfe88f4 commit 5864fd5
Show file tree
Hide file tree
Showing 243 changed files with 1,187 additions and 1,188 deletions.
99 changes: 49 additions & 50 deletions checks/run.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@
#include <email/send.h>
#include <sendreceive/logic.h>
#include <rss/logic.h>
using namespace std;


void checks_run (string bible)
void checks_run (std::string bible)
{
Webserver_Request webserver_request {};
Database_Check database_check {};
Expand All @@ -67,7 +66,7 @@ void checks_run (string bible)
database_check.truncateOutput (bible);


string stylesheet = Database_Config_Bible::getExportStylesheet (bible);
const std::string stylesheet = Database_Config_Bible::getExportStylesheet (bible);


bool check_double_spaces_usfm = Database_Config_Bible::getCheckDoubleSpacesUsfm (bible);
Expand All @@ -79,33 +78,33 @@ void checks_run (string bible)
Checks_Sentences checks_sentences;
checks_sentences.enter_capitals (Database_Config_Bible::getSentenceStructureCapitals (bible));
checks_sentences.enter_small_letters (Database_Config_Bible::getSentenceStructureSmallLetters (bible));
string end_marks = Database_Config_Bible::getSentenceStructureEndPunctuation (bible);
std::string end_marks = Database_Config_Bible::getSentenceStructureEndPunctuation (bible);
checks_sentences.enter_end_marks (end_marks);
string center_marks = Database_Config_Bible::getSentenceStructureMiddlePunctuation (bible);
std::string center_marks = Database_Config_Bible::getSentenceStructureMiddlePunctuation (bible);
checks_sentences.enter_center_marks (center_marks);
string disregards = Database_Config_Bible::getSentenceStructureDisregards (bible);
std::string disregards = Database_Config_Bible::getSentenceStructureDisregards (bible);
checks_sentences.enter_disregards (disregards);
checks_sentences.enter_names (Database_Config_Bible::getSentenceStructureNames (bible));
vector <string> within_sentence_paragraph_markers = filter::strings::explode (Database_Config_Bible::getSentenceStructureWithinSentenceMarkers (bible), ' ');
std::vector <std::string> within_sentence_paragraph_markers = filter::strings::explode (Database_Config_Bible::getSentenceStructureWithinSentenceMarkers (bible), ' ');
bool check_books_versification = Database_Config_Bible::getCheckBooksVersification (bible);
bool check_chapters_verses_versification = Database_Config_Bible::getCheckChaptesVersesVersification (bible);
bool check_well_formed_usfm = Database_Config_Bible::getCheckWellFormedUsfm (bible);
Checks_Usfm checks_usfm = Checks_Usfm (bible);
bool check_missing_punctuation_end_verse = Database_Config_Bible::getCheckMissingPunctuationEndVerse (bible);
bool check_patterns = Database_Config_Bible::getCheckPatterns (bible);
string s_checking_patterns = Database_Config_Bible::getCheckingPatterns (bible);
vector <string> checking_patterns = filter::strings::explode (s_checking_patterns, '\n');
std::string s_checking_patterns = Database_Config_Bible::getCheckingPatterns (bible);
std::vector <std::string> checking_patterns = filter::strings::explode (s_checking_patterns, '\n');
bool check_matching_pairs = Database_Config_Bible::getCheckMatchingPairs (bible);
vector <pair <string, string> > matching_pairs;
std::vector <std::pair <std::string, std::string> > matching_pairs;
{
string fragment = Database_Config_Bible::getMatchingPairs (bible);
vector <string> pairs = filter::strings::explode (fragment, ' ');
for (auto & pair : pairs) {
const std::string fragment = Database_Config_Bible::getMatchingPairs (bible);
std::vector <std::string> pairs = filter::strings::explode (fragment, ' ');
for (auto& pair : pairs) {
pair = filter::strings::trim (pair);
size_t length = filter::strings::unicode_string_length (pair);
const size_t length = filter::strings::unicode_string_length (pair);
if (length == 2) {
string opener = filter::strings::unicode_string_substr (pair, 0, 1);
string closer = filter::strings::unicode_string_substr (pair, 1, 1);
const std::string opener = filter::strings::unicode_string_substr (pair, 0, 1);
const std::string closer = filter::strings::unicode_string_substr (pair, 1, 1);
matching_pairs.push_back ({opener, closer});
}
}
Expand All @@ -117,33 +116,33 @@ void checks_run (string bible)
bool check_valid_utf8_text = Database_Config_Bible::getCheckValidUTF8Text (bible);


vector <int> books = webserver_request.database_bibles()->get_books (bible);
const std::vector <int> books = webserver_request.database_bibles()->get_books (bible);
if (check_books_versification) checks_versification::books (bible, books);


for (auto book : books) {


vector <int> chapters = webserver_request.database_bibles()->get_chapters (bible, book);
const std::vector <int> chapters = webserver_request.database_bibles()->get_chapters (bible, book);
if (check_chapters_verses_versification) checks_versification::chapters (bible, book, chapters);


for (auto chapter : chapters) {
string chapterUsfm = webserver_request.database_bibles()->get_chapter (bible, book, chapter);
std::string chapterUsfm = webserver_request.database_bibles()->get_chapter (bible, book, chapter);


// Transpose and fix spacing around certain markers in footnotes and cross references.
if (transpose_fix_space_in_notes) {
string old_usfm (chapterUsfm);
bool transposed = checks::space::transpose_note_space (chapterUsfm);
std::string old_usfm (chapterUsfm);
const bool transposed = checks::space::transpose_note_space (chapterUsfm);
if (transposed) {
#ifndef HAVE_CLIENT
int oldID = webserver_request.database_bibles()->get_chapter_id (bible, book, chapter);
const int oldID = webserver_request.database_bibles()->get_chapter_id (bible, book, chapter);
#endif
webserver_request.database_bibles()->store_chapter(bible, book, chapter, chapterUsfm);
#ifndef HAVE_CLIENT
int newID = webserver_request.database_bibles()->get_chapter_id (bible, book, chapter);
string username = "Bibledit";
const int newID = webserver_request.database_bibles()->get_chapter_id (bible, book, chapter);
const std::string username = "Bibledit";
database_modifications.recordUserSave (username, bible, book, chapter, oldID, old_usfm, newID, chapterUsfm);
if (sendreceive_git_repository_linked (bible)) {
Database_Git::store_chapter (username, bible, book, chapter, old_usfm, chapterUsfm);
Expand All @@ -155,18 +154,18 @@ void checks_run (string bible)
}


vector <int> verses = filter::usfm::get_verse_numbers (chapterUsfm);
std::vector <int> verses = filter::usfm::get_verse_numbers (chapterUsfm);
if (check_chapters_verses_versification) checks_versification::verses (bible, book, chapter, verses);


for (auto verse : verses) {
string verseUsfm = filter::usfm::get_verse_text (chapterUsfm, verse);
const std::string verseUsfm = filter::usfm::get_verse_text (chapterUsfm, verse);
if (check_double_spaces_usfm) {
checks::space::double_space_usfm (bible, book, chapter, verse, verseUsfm);
}
if (check_valid_utf8_text) {
if (!filter::strings::unicode_string_is_valid (verseUsfm)) {
string msg = "Invalid UTF-8 Unicode in verse text";
const std::string msg = "Invalid UTF-8 Unicode in verse text";
database_check.recordOutput (bible, book, chapter, verse, msg);
}
}
Expand All @@ -180,9 +179,9 @@ void checks_run (string bible)
filter_text.initializeHeadingsAndTextPerVerse (false);
filter_text.add_usfm_code (chapterUsfm);
filter_text.run (stylesheet);
map <int, string> verses_headings = filter_text.verses_headings;
map <int, string> verses_text = filter_text.getVersesText ();
vector <map <int, string>> verses_paragraphs = filter_text.verses_paragraphs;
std::map <int, std::string> verses_headings = filter_text.verses_headings;
std::map <int, std::string> verses_text = filter_text.getVersesText ();
std::vector <std::map <int, std::string>> verses_paragraphs = filter_text.verses_paragraphs;
if (check_full_stop_in_headings) {
checks_headers::no_punctuation_at_end (bible, book, chapter, verses_headings, center_marks, end_marks);
}
Expand All @@ -199,10 +198,10 @@ void checks_run (string bible)
verses_paragraphs);
}

vector <pair<int, string>> results = checks_sentences.get_results ();
for (auto result : results) {
int verse = result.first;
string msg = result.second;
const std::vector <std::pair<int, std::string>> results = checks_sentences.get_results ();
for (const auto& result : results) {
const int verse = result.first;
const std::string msg = result.second;
database_check.recordOutput (bible, book, chapter, verse, msg);
}
}
Expand All @@ -211,10 +210,10 @@ void checks_run (string bible)
checks_usfm.initialize (book, chapter);
checks_usfm.check (chapterUsfm);
checks_usfm.finalize ();
vector <pair<int, string>> results = checks_usfm.get_results ();
for (auto element : results) {
int verse = element.first;
string msg = element.second;
std::vector <std::pair<int, std::string>> results = checks_usfm.get_results ();
for (const auto& element : results) {
const int verse = element.first;
const std::string msg = element.second;
database_check.recordOutput (bible, book, chapter, verse, msg);
}
}
Expand Down Expand Up @@ -249,13 +248,13 @@ void checks_run (string bible)


// Create an email with the checking results for this bible.
vector <string> emailBody;
vector <Database_Check_Hit> hits = database_check.getHits ();
std::vector <std::string> emailBody;
std::vector <Database_Check_Hit> hits = database_check.getHits ();
for (const auto & hit : hits) {
if (hit.bible == bible) {
string passage = filter_passage_display_inline ({Passage ("", hit.book, hit.chapter, filter::strings::convert_to_string (hit.verse))});
string data = filter::strings::escape_special_xml_characters (hit.data);
string result = "<p>" + passage + " " + data + "</p>";
const std::string passage = filter_passage_display_inline ({Passage ("", hit.book, hit.chapter, filter::strings::convert_to_string (hit.verse))});
const std::string data = filter::strings::escape_special_xml_characters (hit.data);
const std::string result = "<p>" + passage + " " + data + "</p>";
emailBody.push_back (result);
}
}
Expand All @@ -264,22 +263,22 @@ void checks_run (string bible)
// Add a link to the online checking results.
if (!emailBody.empty ()) {
Webserver_Request webserver_request;
string siteUrl = config::logic::site_url (webserver_request);
stringstream body1 {};
const std::string siteUrl = config::logic::site_url (webserver_request);
std::stringstream body1 {};
body1 << "<p><a href=" << quoted (siteUrl + checks_index_url ()) << ">" << translate("Checking results online") << "</a></p>";
emailBody.push_back (body1.str());
stringstream body2 {};
std::stringstream body2 {};
body2 << "<p><a href=" << quoted(siteUrl + checks_settings_url ()) << ">" << translate ("Settings") << "</a></p>";
emailBody.push_back (body2.str());
}


// Send email to users with access to the Bible and a subscription to the notification.
if (!emailBody.empty ()) {
string subject = translate("Bible Checks") + " " + bible;
string body = filter::strings::implode (emailBody, "\n");
vector <string> users = webserver_request.database_users ()->get_users ();
for (auto user : users) {
const std::string subject = translate("Bible Checks") + " " + bible;
const std::string body = filter::strings::implode (emailBody, "\n");
std::vector <std::string> users = webserver_request.database_users ()->get_users ();
for (const auto& user : users) {
if (webserver_request.database_config_user()->getUserBibleChecksNotification (user)) {
if (access_bible::read (webserver_request, bible, user)) {
if (!client_logic_client_enabled ()) {
Expand Down
10 changes: 5 additions & 5 deletions checks/sentences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void Checks_Sentences::enter_names (string names)
{
m_names.clear ();
names = filter::strings::replace ("\n", " ", names);
vector <string> names2 = filter::strings::explode (names, ' ');
std::vector <std::string> names2 = filter::strings::explode (names, ' ');
for (auto name : names2) {
if (!name.empty()) {
// Limit the length to the left of the suffix in the test.
Expand Down Expand Up @@ -87,7 +87,7 @@ void Checks_Sentences::initialize ()
void Checks_Sentences::check (const map <int, string> & texts)
{
vector <int> verse_numbers {};
vector <string> characters {};
std::vector <std::string> characters {};
int iterations {0};
for (const auto & element : texts) {
int verse = element.first;
Expand Down Expand Up @@ -181,9 +181,9 @@ void Checks_Sentences::check_character ()
// The USFM markers that start paragraphs that do not need to start with the correct capitalization.
// Usually such markers are poetic markers like \q1 and so on.
// $verses_paragraphs: The entire paragraphs, with verse number as their keys.
void Checks_Sentences::paragraphs (const vector <string> & paragraph_start_markers,
const vector <string> & within_sentence_paragraph_markers,
const vector <map <int, string>> & verses_paragraphs)
void Checks_Sentences::paragraphs (const std::vector <string> & paragraph_start_markers,
const std::vector <string> & within_sentence_paragraph_markers,
const std::vector <map <int, string>> & verses_paragraphs)
{
// Iterate over the paragraphs.
for (unsigned int p = 0; p < verses_paragraphs.size (); p++) {
Expand Down
2 changes: 1 addition & 1 deletion checks/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ string checks_settings (Webserver_Request& webserver_request)
string bible = webserver_request.query["bible"];
if (bible.empty()) {
Dialog_List dialog_list = Dialog_List ("settings", translate("Select which Bible to manage"), string(), string());
vector <string> bibles = access_bible::bibles (webserver_request);
std::vector <std::string> bibles = access_bible::bibles (webserver_request);
for (const auto & selectable_bible : bibles) {
dialog_list.add_row (selectable_bible, "bible", selectable_bible);
}
Expand Down
4 changes: 2 additions & 2 deletions checks/settingspairs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ string checks_settingspairs (Webserver_Request& webserver_request)

if (webserver_request.post.count ("pairs")) {
string fragment = webserver_request.post["pairs"];
vector <string> errors {};
vector <string> pairs = filter::strings::explode (fragment, ' ');
std::vector <std::string> errors {};
std::vector <std::string> pairs = filter::strings::explode (fragment, ' ');
bool okay {true};
for (const auto & pair : pairs) {
const size_t length = filter::strings::unicode_string_length (pair);
Expand Down
2 changes: 1 addition & 1 deletion checks/space.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void space_end_verse (const std::string& bible, int book, int chapter, const std
for (auto verse : verses) {
if (!verse) continue;
string text = filter::usfm::get_verse_text (usfm, verse);
vector <string> items = filter::usfm::get_markers_and_text (text);
std::vector <std::string> items = filter::usfm::get_markers_and_text (text);
for (const auto & item : items) {
if (filter::usfm::is_usfm_marker (item)) {
text = filter::strings::replace (item, "", text);
Expand Down
6 changes: 3 additions & 3 deletions checks/suppress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ string checks_suppress (Webserver_Request& webserver_request)


// Get the Bibles the user has write-access to.
vector <string> bibles {};
std::vector <std::string> bibles {};
{
vector <string> all_bibles = webserver_request.database_bibles()->get_bibles ();
std::vector <std::string> all_bibles = webserver_request.database_bibles()->get_bibles ();
for (const auto & bible : all_bibles) {
if (access_bible::write (webserver_request, bible)) {
bibles.push_back (bible);
Expand All @@ -76,7 +76,7 @@ string checks_suppress (Webserver_Request& webserver_request)


string block {};
const vector <Database_Check_Hit> suppressions = database_check.getSuppressions ();
const std::vector <Database_Check_Hit> suppressions = database_check.getSuppressions ();
for (const auto & suppression : suppressions) {
string bible = suppression.bible;
// Only display entries for Bibles the user has write access to.
Expand Down
6 changes: 3 additions & 3 deletions checks/usfm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ using namespace std;
Checks_Usfm::Checks_Usfm (const std::string& bible)
{
Database_Styles database_styles {};
string stylesheet = Database_Config_Bible::getExportStylesheet (bible);
const std::string stylesheet = Database_Config_Bible::getExportStylesheet (bible);
markers_stylesheet = database_styles.getMarkers (stylesheet);
for (const auto & marker : markers_stylesheet) {
Database_Styles_Item style = database_styles.getMarkerData (stylesheet, marker);
Expand Down Expand Up @@ -155,7 +155,7 @@ void Checks_Usfm::malformed_verse_number ()
if (usfm_item == "\\v ") {
string code = filter::usfm::peek_text_following_marker (usfm_markers_and_text, usfm_markers_and_text_pointer);
string cleanVerseNumber = filter::usfm::peek_verse_number (code);
vector <string> v_dirtyVerseNumber = filter::strings::explode (code, ' ');
std::vector <std::string> v_dirtyVerseNumber = filter::strings::explode (code, ' ');
string dirtyVerseNumber;
if (!v_dirtyVerseNumber.empty ()) dirtyVerseNumber = v_dirtyVerseNumber [0];
if (cleanVerseNumber != dirtyVerseNumber) {
Expand Down Expand Up @@ -209,7 +209,7 @@ void Checks_Usfm::malformed_id ()
if (item == R"(\id)") {
string code = filter::usfm::peek_text_following_marker (usfm_markers_and_text, usfm_markers_and_text_pointer);
string sid = code.substr (0, 3);
vector <string> vid = filter::strings::explode (code, ' ');
std::vector <std::string> vid = filter::strings::explode (code, ' ');
string id {};
if (!vid.empty ()) id = vid [0];
book_id book = database::books::get_id_from_usfm (id);
Expand Down
8 changes: 4 additions & 4 deletions checks/verses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ void checks_verses::missing_punctuation_at_end (const std::string& bible, int bo
const std::string& center_marks, const std::string& end_marks,
const std::string& disregards)
{
const vector <string> centermarks = filter::strings::explode (center_marks, ' ');
const vector <string> endmarks = filter::strings::explode (end_marks, ' ');
const vector <string> ignores = filter::strings::explode (disregards, ' ');
const std::vector <string> centermarks = filter::strings::explode (center_marks, ' ');
const std::vector <string> endmarks = filter::strings::explode (end_marks, ' ');
const std::vector <string> ignores = filter::strings::explode (disregards, ' ');
Database_Check database_check {};
for (const auto & element : verses) {
int verse = element.first;
Expand All @@ -56,7 +56,7 @@ void checks_verses::missing_punctuation_at_end (const std::string& bible, int bo


void checks_verses::patterns (const std::string& bible, int book, int chapter,
const map <int, string> & verses, const vector <string> & patterns)
const map <int, string> & verses, const std::vector <string> & patterns)
{
Database_Check database_check {};
for (const auto & element : verses) {
Expand Down
Loading

0 comments on commit 5864fd5

Please sign in to comment.