Skip to content

Commit

Permalink
State namespace "std::"
Browse files Browse the repository at this point in the history
  • Loading branch information
teusbenschop committed Apr 18, 2024
1 parent 5e38925 commit 5495baa
Show file tree
Hide file tree
Showing 335 changed files with 3,715 additions and 3,716 deletions.
10 changes: 5 additions & 5 deletions bootstrap/bootstrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,22 +251,22 @@ void bootstrap_index (Webserver_Request& webserver_request)
// This can be used for debugging.
/*
if (!webserver_request.post.empty () && config_logic_demo_enabled ()) {
string contents;
std::string contents;
int seconds = filter::date::seconds_since_epoch ();
string rfc822time = filter::date::rfc822 (seconds);
std::string rfc822time = filter::date::rfc822 (seconds);
contents.append (rfc822time + "\n");
contents.append (webserver_request.get + "\n");
string query;
std::string query;
for (auto element : webserver_request.query) {
query.append (element.first + "=" + element.second + " and ");
}
string post;
std::string post;
for (auto element : webserver_request.post) {
post.append (element.first + "=" + element.second + " and ");
}
contents.append ("query: " + query + "\n");
contents.append ("post: " + post + "\n");
string filename;
std::string filename;
filename = filter_url_create_root_path (filter_url_temp_dir (), "http-post-trace.txt");
filter_url_file_put_contents_append (filename, contents);
}
Expand Down
7 changes: 3 additions & 4 deletions checks/verses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include <database/config/bible.h>
#include <styles/logic.h>
#include <locale/translate.h>
using namespace std;


void checks_verses::missing_punctuation_at_end (const std::string& bible, int book, int chapter,
Expand All @@ -40,14 +39,14 @@ void checks_verses::missing_punctuation_at_end (const std::string& bible, int bo
Database_Check database_check {};
for (const auto & element : verses) {
int verse = element.first;
string text = element.second;
std::string text = element.second;
if (verse == 0) continue;
if (text.empty ()) continue;
for (const auto & ignore_text : ignores) {
text = filter::strings::replace (ignore_text, std::string(), text);
}
const size_t text_length = filter::strings::unicode_string_length (text);
const string lastCharacter = filter::strings::unicode_string_substr (text, text_length - 1, 1);
const std::string lastCharacter = filter::strings::unicode_string_substr (text, text_length - 1, 1);
if (in_array (lastCharacter, centermarks)) continue;
if (in_array (lastCharacter, endmarks)) continue;
database_check.recordOutput (bible, book, chapter, verse, translate ("No punctuation at end of verse:") + " " + lastCharacter);
Expand All @@ -61,7 +60,7 @@ void checks_verses::patterns (const std::string& bible, int book, int chapter,
Database_Check database_check {};
for (const auto & element : verses) {
const int verse = element.first;
const string text = element.second;
const std::string text = element.second;
for (const auto & pattern : patterns) {
if (pattern.empty ()) continue;
if (text.find (pattern) != std::string::npos) {
Expand Down
6 changes: 3 additions & 3 deletions checks/versification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ using namespace std;
void checks_versification::books (const std::string& bible, const std::vector <int> & books)
{
Database_Versifications database_versifications {};
string versification = Database_Config_Bible::getVersificationSystem (bible);
std::string versification = Database_Config_Bible::getVersificationSystem (bible);
if (versification.empty ()) versification = filter::strings::english ();
const std::vector <int> standardBooks = database_versifications.getBooks (versification);
const std::vector <int> absentBooks = filter::strings::array_diff (standardBooks, books);
Expand All @@ -47,7 +47,7 @@ void checks_versification::books (const std::string& bible, const std::vector <i
void checks_versification::chapters (const std::string& bible, int book, const std::vector <int> & chapters)
{
Database_Versifications database_versifications {};
string versification = Database_Config_Bible::getVersificationSystem (bible);
std::string versification = Database_Config_Bible::getVersificationSystem (bible);
if (versification.empty ()) versification = filter::strings::english ();
const std::vector <int> standardChapters = database_versifications.getChapters (versification, book, true);
const std::vector <int> absentChapters = filter::strings::array_diff (standardChapters, chapters);
Expand All @@ -66,7 +66,7 @@ void checks_versification::verses (const std::string& bible, int book, int chapt
{
// Get verses in this chapter according to the versification system for the Bible.
Database_Versifications database_versifications {};
string versification = Database_Config_Bible::getVersificationSystem (bible);
std::string versification = Database_Config_Bible::getVersificationSystem (bible);
if (versification.empty ()) versification = filter::strings::english ();
const std::vector <int> standardVerses = database_versifications.getVerses (versification, book, chapter);
// Look for missing and extra verses.
Expand Down
12 changes: 6 additions & 6 deletions checksum/logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ using namespace std;
// The rest contains the $data.
string checksum_logic::send (const std::string& data, bool readwrite)
{
string checksum = get (data);
std::string checksum = get (data);
checksum.append ("\n");
checksum.append (filter::strings::convert_to_string (readwrite));
checksum.append ("\n");
Expand Down Expand Up @@ -64,8 +64,8 @@ string checksum_logic::get (const std::vector <std::string>& data)
// Returns a proper checksum for the USFM in the chapter.
string checksum_logic::get_chapter (Webserver_Request& webserver_request, const std::string& bible, int book, int chapter)
{
string usfm = webserver_request.database_bibles()->get_chapter (bible, book, chapter);
string checksum = md5 (filter::strings::trim (usfm));
std::string usfm = webserver_request.database_bibles()->get_chapter (bible, book, chapter);
std::string checksum = md5 (filter::strings::trim (usfm));
return checksum;
}

Expand All @@ -78,7 +78,7 @@ string checksum_logic::get_book (Webserver_Request& webserver_request, const std
for (auto chapter : chapters) {
checksums.push_back (get_chapter (webserver_request, bible, book, chapter));
}
string checksum = filter::strings::implode (checksums, std::string());
std::string checksum = filter::strings::implode (checksums, std::string());
checksum = md5 (checksum);
return checksum;
}
Expand All @@ -92,7 +92,7 @@ string checksum_logic::get_bible (Webserver_Request& webserver_request, const st
for (auto book : books) {
checksums.push_back (get_book (webserver_request, bible, book));
}
string checksum = filter::strings::implode (checksums, std::string());
std::string checksum = filter::strings::implode (checksums, std::string());
checksum = md5 (checksum);
return checksum;
}
Expand All @@ -105,7 +105,7 @@ string checksum_logic::get_bibles (Webserver_Request& webserver_request, const s
for (const auto & bible : bibles) {
checksums.push_back (get_bible (webserver_request, bible));
}
string checksum = filter::strings::implode (checksums, std::string());
std::string checksum = filter::strings::implode (checksums, std::string());
checksum = md5 (checksum);
return checksum;
}
Expand Down
30 changes: 15 additions & 15 deletions client/logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ string client_logic_connection_setup (string user, string hash)
hash = database_users.get_md5 (user);
}

string encoded_user = filter::strings::bin2hex (user);
std::string encoded_user = filter::strings::bin2hex (user);

string address = Database_Config_General::getServerAddress ();
std::string address = Database_Config_General::getServerAddress ();
int port = Database_Config_General::getServerPort ();

string url = client_logic_url (address, port, sync_setup_url ()) + "?user=" + encoded_user + "&pass=" + hash;
std::string url = client_logic_url (address, port, sync_setup_url ()) + "?user=" + encoded_user + "&pass=" + hash;

string error {};
string response = filter_url_http_get (url, error, true);
std::string error {};
std::string response = filter_url_http_get (url, error, true);
int iresponse = filter::strings::convert_to_int (response);

if ((iresponse >= Filter_Roles::guest ()) && (iresponse <= Filter_Roles::admin ())) {
Expand All @@ -102,7 +102,7 @@ string client_logic_connection_setup (string user, string hash)
// it will give a response code 426 plus text.
// So in such a case clarify the meaning of that to the user.
// https://github.com/bibledit/cloud/issues/829.
string upgrade_required = filter_url_http_response_code_text (426);
std::string upgrade_required = filter_url_http_response_code_text (426);
size_t pos = error.find (upgrade_required);
if (pos != std::string::npos) {
// Since the error code ends without a full stop, add a full stop to it first.
Expand Down Expand Up @@ -170,10 +170,10 @@ void client_logic_create_note_decode (const std::string& data,
// It displays the $linktext.
string client_logic_link_to_cloud (string path, string linktext)
{
string url {};
string external {};
std::string url {};
std::string external {};
if (client_logic_client_enabled ()) {
string address = Database_Config_General::getServerAddress ();
std::string address = Database_Config_General::getServerAddress ();
int port = Database_Config_General::getServerPort ();
url = address + ":" + filter::strings::convert_to_string (port);
if (!path.empty ()) {
Expand Down Expand Up @@ -213,7 +213,7 @@ void client_logic_usfm_resources_update ()
// The Cloud stores the list of USFM resources.
// It is stored in the client files area.
// Clients can access it from there.
string path = client_logic_usfm_resources_path ();
std::string path = client_logic_usfm_resources_path ();
Database_UsfmResources database_usfmresources {};
std::vector <std::string> resources = database_usfmresources.getResources ();
filter_url_file_put_contents (path, filter::strings::implode (resources, "\n"));
Expand All @@ -222,7 +222,7 @@ void client_logic_usfm_resources_update ()

vector <std::string> client_logic_usfm_resources_get ()
{
string contents = filter_url_file_get_contents (client_logic_usfm_resources_path ());
std::string contents = filter_url_file_get_contents (client_logic_usfm_resources_path ());
return filter::strings::explode (contents, '\n');
}

Expand All @@ -232,7 +232,7 @@ string client_logic_get_username ()
// Set the user name to the first one in the database.
// Or if the database has no users, make the user admin.
// That happens when disconnected from the Cloud.
string user = session_admin_credentials ();
std::string user = session_admin_credentials ();
Database_Users database_users;
std::vector <std::string> users = database_users.get_users ();
if (!users.empty()) user = users [0];
Expand All @@ -248,8 +248,8 @@ string client_logic_no_cache_resources_path ()

void client_logic_no_cache_resources_save (vector<string> resources)
{
string contents = filter::strings::implode(resources, "\n");
string path = client_logic_no_cache_resources_path ();
std::string contents = filter::strings::implode(resources, "\n");
std::string path = client_logic_no_cache_resources_path ();
filter_url_file_put_contents(path, contents);
}

Expand All @@ -274,7 +274,7 @@ void client_logic_no_cache_resource_remove (string name)

vector <std::string> client_logic_no_cache_resources_get ()
{
string contents = filter_url_file_get_contents (client_logic_no_cache_resources_path());
std::string contents = filter_url_file_get_contents (client_logic_no_cache_resources_path());
vector<string> resources = filter::strings::explode(contents, "\n");
return resources;
}
10 changes: 5 additions & 5 deletions collaboration/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@ string collaboration_settings (Webserver_Request& webserver_request)
Assets_View view;


string object = webserver_request.query ["object"];
std::string object = webserver_request.query ["object"];
view.set_variable ("object", object);


if (webserver_request.post.count ("url")) {
if (!object.empty ()) {
string url = webserver_request.post["url"];
std::string url = webserver_request.post["url"];
Database_Config_Bible::setRemoteRepositoryUrl (object, url);
string source = webserver_request.post["source"];
string readwrite = webserver_request.post["readwrite"];
std::string source = webserver_request.post["source"];
std::string readwrite = webserver_request.post["readwrite"];
Database_Config_Bible::setReadFromGit (object, readwrite == "sendreceive");
Database_Jobs database_jobs = Database_Jobs ();
int jobId = database_jobs.get_new_id ();
Expand All @@ -77,7 +77,7 @@ string collaboration_settings (Webserver_Request& webserver_request)
return "";
}
}
string url = Database_Config_Bible::getRemoteRepositoryUrl (object);
std::string url = Database_Config_Bible::getRemoteRepositoryUrl (object);
view.set_variable ("url", url);


Expand Down
22 changes: 11 additions & 11 deletions compare/compare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void compare_compare (string bible, string compare, int jobId)
for (auto & book : books) {


string bookName = database::books::get_english_from_id (static_cast<book_id>(book));
std::string bookName = database::books::get_english_from_id (static_cast<book_id>(book));
database_jobs.set_progress (jobId, bookName);


Expand Down Expand Up @@ -143,8 +143,8 @@ void compare_compare (string bible, string compare, int jobId)


// Get source and compare USFM, and skip them if they are equal.
string bible_chapter_usfm = database_bibles.get_chapter (bible, book, chapter);
string compare_chapter_usfm = database_bibles.get_chapter (compare, book, chapter);
std::string bible_chapter_usfm = database_bibles.get_chapter (bible, book, chapter);
std::string compare_chapter_usfm = database_bibles.get_chapter (compare, book, chapter);
if (compare_chapter_usfm == "") {
compare_chapter_usfm = database_usfmresources.getUsfm (compare, book, chapter);
}
Expand All @@ -168,8 +168,8 @@ void compare_compare (string bible, string compare, int jobId)


// Get the USFM of verse of the Bible and comparison USFM, and skip it if both are the same.
string bible_verse_usfm = filter::usfm::get_verse_text (bible_chapter_usfm, verse);
string compare_verse_usfm = filter::usfm::get_verse_text (compare_chapter_usfm, verse);
std::string bible_verse_usfm = filter::usfm::get_verse_text (bible_chapter_usfm, verse);
std::string compare_verse_usfm = filter::usfm::get_verse_text (compare_chapter_usfm, verse);
if (bible_verse_usfm == compare_verse_usfm) continue;

Filter_Text filter_text_bible = Filter_Text (bible);
Expand All @@ -182,16 +182,16 @@ void compare_compare (string bible, string compare, int jobId)
filter_text_compare.add_usfm_code (compare_verse_usfm);
filter_text_bible.run (stylesheet);
filter_text_compare.run (stylesheet);
string bible_html = filter_text_bible.html_text_standard->get_inner_html ();
string compare_html = filter_text_compare.html_text_standard->get_inner_html ();
string bible_text = filter_text_bible.text_text->get ();
string compare_text = filter_text_compare.text_text->get ();
std::string bible_html = filter_text_bible.html_text_standard->get_inner_html ();
std::string compare_html = filter_text_compare.html_text_standard->get_inner_html ();
std::string bible_text = filter_text_bible.text_text->get ();
std::string compare_text = filter_text_compare.text_text->get ();
if (bible_text != compare_text) {
string modification = filter_diff_diff (compare_text, bible_text);
std::string modification = filter_diff_diff (compare_text, bible_text);
result.push_back (filter_passage_display (book, chapter, filter::strings::convert_to_string (verse)) + " " + modification);
new_verses.push_back (filter_passage_display (book, chapter, filter::strings::convert_to_string (verse)) + " " + bible_text);
}
string modification = filter_diff_diff (compare_verse_usfm, bible_verse_usfm);
std::string modification = filter_diff_diff (compare_verse_usfm, bible_verse_usfm);
raw.push_back (filter_passage_display (book, chapter, filter::strings::convert_to_string (verse)) + " " + modification);
}
}
Expand Down
32 changes: 16 additions & 16 deletions confirm/worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,22 @@ m_webserver_request (webserver_request)
// subsequent_subject: The subject of the email to send upon user confirmation.
// subsequent_body : The body of the email to send upon user confirmation.
void Confirm_Worker::setup (string mailto, string username,
string initial_subject, string initial_body,
string query,
string subsequent_subject, string subsequent_body)
std::string initial_subject, string initial_body,
std::string query,
std::string subsequent_subject, string subsequent_body)
{
Database_Confirm database_confirm;
unsigned int confirmation_id = database_confirm.get_new_id ();
pugi::xml_document document;
pugi::xml_node node = document.append_child ("p");
string information;
std::string information;
if (config::logic::default_bibledit_configuration ()) {
information = translate ("Please confirm this request by clicking this following link:");
}
node.text ().set (information.c_str());
node = document.append_child ("p");
string siteUrl = config::logic::site_url (m_webserver_request);
string confirmation_url = filter_url_build_http_query (siteUrl + session_confirm_url (), "id", to_string(confirmation_id));
std::string siteUrl = config::logic::site_url (m_webserver_request);
std::string confirmation_url = filter_url_build_http_query (siteUrl + session_confirm_url (), "id", to_string(confirmation_id));
node.text ().set (confirmation_url.c_str());
stringstream output;
document.print (output, "", pugi::format_raw);
Expand All @@ -97,10 +97,10 @@ bool Confirm_Worker::handleEmail ([[maybe_unused]]string from, string subject, s
return false;
}
// An active ID was found: Execute the associated database query.
string query = database_confirm.get_query (id);
std::string query = database_confirm.get_query (id);
m_webserver_request.database_users()->execute (query);
// Send confirmation mail.
string mailto = database_confirm.get_mail_to (id);
std::string mailto = database_confirm.get_mail_to (id);
subject = database_confirm.get_subject (id);
body = database_confirm.get_body (id);
email_schedule (mailto, subject, body);
Expand All @@ -118,7 +118,7 @@ bool Confirm_Worker::handleEmail ([[maybe_unused]]string from, string subject, s
bool Confirm_Worker::handleLink (string & email)
{
// Get the confirmation identifier from the link that was clicked.
string web_id = m_webserver_request.query["id"];
std::string web_id = m_webserver_request.query["id"];

// If the identifier was not given, the link was not handled successfully.
if (web_id.empty()) return false;
Expand All @@ -132,13 +132,13 @@ bool Confirm_Worker::handleLink (string & email)
}

// An active ID was found: Execute the associated database query.
string query = database_confirm.get_query (id);
std::string query = database_confirm.get_query (id);
m_webserver_request.database_users()->execute (query);

// Send confirmation mail.
string mailto = database_confirm.get_mail_to (id);
string subject = database_confirm.get_subject (id);
string body = database_confirm.get_body (id);
std::string mailto = database_confirm.get_mail_to (id);
std::string subject = database_confirm.get_subject (id);
std::string body = database_confirm.get_body (id);
email_schedule (mailto, subject, body);

// Delete the confirmation record.
Expand All @@ -163,9 +163,9 @@ void Confirm_Worker::informManagers (string email, string body)
for (auto & user : users) {
int level = database_users.get_level (user);
if (level >= Filter_Roles::manager ()) {
string mailto = database_users.get_email (user);
string subject = translate ("User account change");
string newbody = translate ("A user account was changed.");
std::string mailto = database_users.get_email (user);
std::string subject = translate ("User account change");
std::string newbody = translate ("A user account was changed.");
newbody.append (" ");
newbody.append (translate ("Email address:"));
newbody.append (" ");
Expand Down
Loading

0 comments on commit 5495baa

Please sign in to comment.