Skip to content

Commit

Permalink
State std:: in each case
Browse files Browse the repository at this point in the history
  • Loading branch information
teusbenschop committed Apr 19, 2024
1 parent 5495baa commit 5e2fad3
Show file tree
Hide file tree
Showing 167 changed files with 1,038 additions and 1,042 deletions.
1 change: 0 additions & 1 deletion checks/versification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <database/versifications.h>
#include <database/config/bible.h>
#include <locale/translate.h>
using namespace std;


void checks_versification::books (const std::string& bible, const std::vector <int> & books)
Expand Down
16 changes: 7 additions & 9 deletions checksum/logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <filter/md5.h>
#include <filter/usfm.h>
#include <webserver/request.h>
using namespace std;


// This function reads $data,
Expand All @@ -32,7 +31,7 @@ using namespace std;
// The first line contains the checksum.
// The second line contains the readwrite as 0 or 1.
// The rest contains the $data.
string checksum_logic::send (const std::string& data, bool readwrite)
std::string checksum_logic::send (const std::string& data, bool readwrite)
{
std::string checksum = get (data);
checksum.append ("\n");
Expand All @@ -45,15 +44,15 @@ string checksum_logic::send (const std::string& data, bool readwrite)

// This function gets the checksum for $data, and returns it.
// It calculates the length of 'data' in bytes.
string checksum_logic::get (const std::string& data)
std::string checksum_logic::get (const std::string& data)
{
return filter::strings::convert_to_string (data.length ());
}


// This function gets the checksum for $data, and returns it.
// It calculates the length of vector 'data' in bytes.
string checksum_logic::get (const std::vector <std::string>& data)
std::string checksum_logic::get (const std::vector <std::string>& data)
{
int length = 0;
for (auto & bit : data) length += static_cast<int>(bit.length ());
Expand All @@ -62,7 +61,7 @@ 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)
std::string checksum_logic::get_chapter (Webserver_Request& webserver_request, const std::string& bible, int book, int chapter)
{
std::string usfm = webserver_request.database_bibles()->get_chapter (bible, book, chapter);
std::string checksum = md5 (filter::strings::trim (usfm));
Expand All @@ -71,7 +70,7 @@ string checksum_logic::get_chapter (Webserver_Request& webserver_request, const


// Returns a proper checksum for the USFM in the book.
string checksum_logic::get_book (Webserver_Request& webserver_request, const std::string& bible, int book)
std::string checksum_logic::get_book (Webserver_Request& webserver_request, const std::string& bible, int book)
{
std::vector <int> chapters = webserver_request.database_bibles()->get_chapters (bible, book);
std::vector <std::string> checksums;
Expand All @@ -85,7 +84,7 @@ string checksum_logic::get_book (Webserver_Request& webserver_request, const std


// Returns a proper checksum for the USFM in the $bible.
string checksum_logic::get_bible (Webserver_Request& webserver_request, const std::string& bible)
std::string checksum_logic::get_bible (Webserver_Request& webserver_request, const std::string& bible)
{
std::vector <int> books = webserver_request.database_bibles()->get_books (bible);
std::vector <std::string> checksums;
Expand All @@ -99,7 +98,7 @@ string checksum_logic::get_bible (Webserver_Request& webserver_request, const st


// Returns a proper checksum for the USFM in the array of $bibles.
string checksum_logic::get_bibles (Webserver_Request& webserver_request, const std::vector <std::string> & bibles)
std::string checksum_logic::get_bibles (Webserver_Request& webserver_request, const std::vector <std::string> & bibles)
{
std::vector <std::string> checksums;
for (const auto & bible : bibles) {
Expand All @@ -109,4 +108,3 @@ string checksum_logic::get_bibles (Webserver_Request& webserver_request, const s
checksum = md5 (checksum);
return checksum;
}

35 changes: 17 additions & 18 deletions client/logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include <locale/translate.h>
#include <assets/external.h>
#include <database/logic.h>
using namespace std;


// Returns whether Client mode is enabled.
Expand All @@ -56,7 +55,7 @@ void client_logic_enable_client (bool enable)
// $address is the website.
// $port is the port number.
// $path is the path after the website.
string client_logic_url (const std::string& address, int port, const std::string& path)
std::string client_logic_url (const std::string& address, int port, const std::string& path)
{
return address + ":" + filter::strings::convert_to_string (port) + "/" + path;
}
Expand All @@ -66,7 +65,7 @@ string client_logic_url (const std::string& address, int port, const std::string
// It receives settings from the server and applies them to the client.
// It returns the level of the user.
// It returns an empty string in case of failure or the response from the server.
string client_logic_connection_setup (string user, string hash)
std::string client_logic_connection_setup (std::string user, std::string hash)
{
Database_Users database_users {};

Expand Down Expand Up @@ -118,8 +117,8 @@ string client_logic_connection_setup (string user, string hash)
}


string client_logic_create_note_encode (const std::string& bible, int book, int chapter, int verse,
const std::string& summary, const std::string& contents, bool raw)
std::string client_logic_create_note_encode (const std::string& bible, int book, int chapter, int verse,
const std::string& summary, const std::string& contents, bool raw)
{
std::vector <std::string> data {};
data.push_back (bible);
Expand All @@ -134,8 +133,8 @@ string client_logic_create_note_encode (const std::string& bible, int book, int


void client_logic_create_note_decode (const std::string& data,
string& bible, int& book, int& chapter, int& verse,
string& summary, string& contents, bool& raw)
std::string& bible, int& book, int& chapter, int& verse,
std::string& summary, std::string& contents, bool& raw)
{
std::vector <std::string> lines = filter::strings::explode (data, '\n');
if (!lines.empty ()) {
Expand Down Expand Up @@ -168,7 +167,7 @@ void client_logic_create_note_decode (const std::string& data,

// This provides a html link to Bibledit Cloud / $path.
// It displays the $linktext.
string client_logic_link_to_cloud (string path, string linktext)
std::string client_logic_link_to_cloud (std::string path, std::string linktext)
{
std::string url {};
std::string external {};
Expand All @@ -195,14 +194,14 @@ string client_logic_link_to_cloud (string path, string linktext)
linktext = url;
}

stringstream link {};
std::stringstream link {};
link << "<a href=" << quoted(url) << external << ">" << linktext << "</a>";
return link.str();
}


// Path to the file in the client files area that contains a list of USFM resources on the server.
string client_logic_usfm_resources_path ()
std::string client_logic_usfm_resources_path ()
{
return filter_url_create_root_path ({database_logic_databases (), "client", "usfm_resources.txt"});
}
Expand All @@ -220,14 +219,14 @@ void client_logic_usfm_resources_update ()
}


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


string client_logic_get_username ()
std::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.
Expand All @@ -240,21 +239,21 @@ string client_logic_get_username ()
}


string client_logic_no_cache_resources_path ()
std::string client_logic_no_cache_resources_path ()
{
return filter_url_create_root_path ({database_logic_databases (), "client", "no_cache_resources.txt"});
}


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


void client_logic_no_cache_resource_add (string name)
void client_logic_no_cache_resource_add (std::string name)
{
std::vector <std::string> resources = client_logic_no_cache_resources_get();
if (in_array(name, resources)) return;
Expand All @@ -263,7 +262,7 @@ void client_logic_no_cache_resource_add (string name)
}


void client_logic_no_cache_resource_remove (string name)
void client_logic_no_cache_resource_remove (std::string name)
{
std::vector <std::string> resources = client_logic_no_cache_resources_get();
if (!in_array(name, resources)) return;
Expand All @@ -272,9 +271,9 @@ void client_logic_no_cache_resource_remove (string name)
}


vector <std::string> client_logic_no_cache_resources_get ()
std::vector <std::string> client_logic_no_cache_resources_get ()
{
std::string contents = filter_url_file_get_contents (client_logic_no_cache_resources_path());
vector<string> resources = filter::strings::explode(contents, "\n");
std::vector<std::string> resources = filter::strings::explode(contents, "\n");
return resources;
}
2 changes: 1 addition & 1 deletion compare/compare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
using namespace std;


void compare_compare (string bible, string compare, int jobId)
void compare_compare (std::string bible, std::string compare, int jobId)
{
Database_Logs::log (translate("Comparing Bibles") + " " + bible + " " + translate ("and") + " " + compare, Filter_Roles::consultant ());

Expand Down
14 changes: 7 additions & 7 deletions confirm/worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ m_webserver_request (webserver_request)
// query : The query to be executed on the database if the user confirms the email successfully.
// 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,
std::string initial_subject, string initial_body,
void Confirm_Worker::setup (std::string mailto, std::string username,
std::string initial_subject, std::string initial_body,
std::string query,
std::string subsequent_subject, string subsequent_body)
std::string subsequent_subject, std::string subsequent_body)
{
Database_Confirm database_confirm;
unsigned int confirmation_id = database_confirm.get_new_id ();
Expand All @@ -77,7 +77,7 @@ void Confirm_Worker::setup (string mailto, string username,
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;
std::stringstream output;
document.print (output, "", pugi::format_raw);
initial_body += output.str ();
email_schedule (mailto, initial_subject, initial_body);
Expand All @@ -87,7 +87,7 @@ void Confirm_Worker::setup (string mailto, string username,

// Handles a confirmation email received "from" with "subject" and "body".
// Returns true if the mail was handled, else false.
bool Confirm_Worker::handleEmail ([[maybe_unused]]string from, string subject, string body)
bool Confirm_Worker::handleEmail ([[maybe_unused]]string from, std::string subject, std::string body)
{
// Find out in the confirmation database whether the subject line contains an active ID.
// If not, bail out.
Expand Down Expand Up @@ -115,7 +115,7 @@ bool Confirm_Worker::handleEmail ([[maybe_unused]]string from, string subject, s

// Handles a confirmation link clicked with a confirmation ID.
// Returns true if link was valid, else false.
bool Confirm_Worker::handleLink (string & email)
bool Confirm_Worker::handleLink (std::string & email)
{
// Get the confirmation identifier from the link that was clicked.
std::string web_id = m_webserver_request.query["id"];
Expand Down Expand Up @@ -156,7 +156,7 @@ bool Confirm_Worker::handleLink (string & email)


// Inform the managers about an account change.
void Confirm_Worker::informManagers (string email, string body)
void Confirm_Worker::informManagers (std::string email, std::string body)
{
Database_Users database_users;
std::vector <std::string> users = database_users.get_users ();
Expand Down
2 changes: 1 addition & 1 deletion consistency/index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ string consistency_index (Webserver_Request& webserver_request)
}


stringstream resourceblock;
std::stringstream resourceblock;
std::vector <std::string> resources = webserver_request.database_config_user()->getConsistencyResources ();
for (auto resource : resources) {
resourceblock << resource;
Expand Down
4 changes: 2 additions & 2 deletions consistency/logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,14 @@ string Consistency_Logic::response ()
}


string Consistency_Logic::verseText (string resource, int book, int chapter, int verse)
string Consistency_Logic::verseText (std::string resource, int book, int chapter, int verse)
{
return resource_logic_get_html (m_webserver_request, resource, book, chapter, verse, false);
}


// This function omits the verse text from a line of text from the search results.
string Consistency_Logic::omit_verse_text (string input)
string Consistency_Logic::omit_verse_text (std::string input)
{
// Imagine the following $input:
// 1 Peter 4:17 For the time has come for judgment to begin with the household of God. If it begins first with us, what will happen to those who don’t obey the Good News of God?
Expand Down
4 changes: 2 additions & 2 deletions database/abbottsmith.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void Database_AbbottSmith::optimize ()
}


void Database_AbbottSmith::store (string lemma, string lemma_casefold, string strong, string contents)
void Database_AbbottSmith::store (std::string lemma, std::string lemma_casefold, std::string strong, std::string contents)
{
SqliteDatabase sql = SqliteDatabase (filename ());
sql.add ("PRAGMA temp_store = MEMORY;");
Expand All @@ -80,7 +80,7 @@ void Database_AbbottSmith::store (string lemma, string lemma_casefold, string st
}


string Database_AbbottSmith::get (string lemma, string strong)
string Database_AbbottSmith::get (std::string lemma, std::string strong)
{
std::string contents;
SqliteDatabase sql = SqliteDatabase (filename ());
Expand Down
10 changes: 5 additions & 5 deletions database/bibleactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void Database_BibleActions::optimize ()
}


void Database_BibleActions::record (string bible, int book, int chapter, string usfm)
void Database_BibleActions::record (std::string bible, int book, int chapter, std::string usfm)
{
if (getUsfm (bible, book, chapter).empty ()) {
SqliteDatabase sql (filename ());
Expand All @@ -87,7 +87,7 @@ vector <std::string> Database_BibleActions::getBibles ()
}


vector <int> Database_BibleActions::getBooks (string bible)
vector <int> Database_BibleActions::getBooks (std::string bible)
{
SqliteDatabase sql (filename ());
sql.add ("SELECT DISTINCT book FROM bibleactions WHERE bible =");
Expand All @@ -100,7 +100,7 @@ vector <int> Database_BibleActions::getBooks (string bible)
}


vector <int> Database_BibleActions::getChapters (string bible, int book)
vector <int> Database_BibleActions::getChapters (std::string bible, int book)
{
SqliteDatabase sql (filename ());
sql.add ("SELECT DISTINCT chapter FROM bibleactions WHERE bible =");
Expand All @@ -115,7 +115,7 @@ vector <int> Database_BibleActions::getChapters (string bible, int book)
}


string Database_BibleActions::getUsfm (string bible, int book, int chapter)
string Database_BibleActions::getUsfm (std::string bible, int book, int chapter)
{
SqliteDatabase sql (filename ());
sql.add ("SELECT usfm FROM bibleactions WHERE bible =");
Expand All @@ -134,7 +134,7 @@ string Database_BibleActions::getUsfm (string bible, int book, int chapter)
}


void Database_BibleActions::erase (string bible, int book, int chapter)
void Database_BibleActions::erase (std::string bible, int book, int chapter)
{
SqliteDatabase sql (filename ());
sql.add ("DELETE FROM bibleactions WHERE bible =");
Expand Down
Loading

0 comments on commit 5e2fad3

Please sign in to comment.