Skip to content

Commit

Permalink
Replace user function with call to std library
Browse files Browse the repository at this point in the history
  • Loading branch information
teusbenschop committed Jun 2, 2024
1 parent 459a3a2 commit 2f1271c
Show file tree
Hide file tree
Showing 186 changed files with 7,488 additions and 722 deletions.
16 changes: 8 additions & 8 deletions assets/header.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ bool Assets_Header::display_topbar ()
// Sets the page to refresh after "seconds".
void Assets_Header::refresh (int seconds, const std::string& url)
{
std::string content = filter::strings::convert_to_string (seconds);
std::string content = std::to_string (seconds);
if (!url.empty ()) content.append (";URL=" + url);
std::stringstream ss{};
ss << "<META HTTP-EQUIV=" << std::quoted("refresh") << " CONTENT=" << std::quoted(content) << ">";
Expand Down Expand Up @@ -241,7 +241,7 @@ std::string Assets_Header::run ()
if (!m_fading_menu.empty ()) {
m_view->enable_zone ("fading_menu");
m_view->set_variable ("fadingmenu", m_fading_menu);
std::string delay = filter::strings::convert_to_string (m_webserver_request.database_config_user ()->getWorkspaceMenuFadeoutDelay ()) + "000";
std::string delay = std::to_string (m_webserver_request.database_config_user ()->getWorkspaceMenuFadeoutDelay ()) + "000";
m_view->set_variable ("fadingmenudelay", delay);
m_fading_menu.clear ();
}
Expand All @@ -258,27 +258,27 @@ std::string Assets_Header::run ()
std::vector <std::string> embedded_css {};
int fontsize = m_webserver_request.database_config_user ()->getGeneralFontSize ();
if (fontsize != 100) {
embedded_css.push_back ("body { font-size: " + filter::strings::convert_to_string (fontsize) + "%; }");
embedded_css.push_back ("body { font-size: " + std::to_string (fontsize) + "%; }");
}
fontsize = m_webserver_request.database_config_user ()->getMenuFontSize ();
if (fontsize != 100) {
embedded_css.push_back (".menu-advanced, .menu-basic { font-size: " + filter::strings::convert_to_string (fontsize) + "%; }");
embedded_css.push_back (".menu-advanced, .menu-basic { font-size: " + std::to_string (fontsize) + "%; }");
}
fontsize = m_webserver_request.database_config_user ()->getBibleEditorsFontSize ();
if (fontsize != 100) {
embedded_css.push_back (".bibleeditor { font-size: " + filter::strings::convert_to_string (fontsize) + "% !important; }");
embedded_css.push_back (".bibleeditor { font-size: " + std::to_string (fontsize) + "% !important; }");
}
fontsize = m_webserver_request.database_config_user ()->getResourcesFontSize ();
if (fontsize != 100) {
embedded_css.push_back (".resource { font-size: " + filter::strings::convert_to_string (fontsize) + "% !important; }");
embedded_css.push_back (".resource { font-size: " + std::to_string (fontsize) + "% !important; }");
}
fontsize = m_webserver_request.database_config_user ()->getHebrewFontSize ();
if (fontsize != 100) {
embedded_css.push_back (".hebrew { font-size: " + filter::strings::convert_to_string (fontsize) + "%!important; }");
embedded_css.push_back (".hebrew { font-size: " + std::to_string (fontsize) + "%!important; }");
}
fontsize = m_webserver_request.database_config_user ()->getGreekFontSize ();
if (fontsize != 100) {
embedded_css.push_back (".greek { font-size: " + filter::strings::convert_to_string (fontsize) + "%!important; }");
embedded_css.push_back (".greek { font-size: " + std::to_string (fontsize) + "%!important; }");
}
if (!embedded_css.empty ()) {
m_view->set_variable ("embedded_css", filter::strings::implode (embedded_css, "\n"));
Expand Down
12 changes: 6 additions & 6 deletions bb/book.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ std::string bible_book (Webserver_Request& webserver_request)

// The book.
const int book = filter::strings::convert_to_int (webserver_request.query ["book"]);
view.set_variable ("book", filter::strings::convert_to_string (book));
view.set_variable ("book", std::to_string (book));
const std::string book_name = database::books::get_english_from_id (static_cast<book_id>(book));
view.set_variable ("book_name", filter::strings::escape_special_xml_characters (book_name));

Expand All @@ -88,7 +88,7 @@ std::string bible_book (Webserver_Request& webserver_request)
if (confirm.empty()) {
Dialog_Yes dialog_yes = Dialog_Yes ("book", translate("Would you like to delete this chapter?"));
dialog_yes.add_query ("bible", bible);
dialog_yes.add_query ("book", filter::strings::convert_to_string (book));
dialog_yes.add_query ("book", std::to_string (book));
dialog_yes.add_query ("deletechapter", deletechapter);
page += dialog_yes.run ();
return page;
Expand All @@ -101,7 +101,7 @@ std::string bible_book (Webserver_Request& webserver_request)
if (webserver_request.query.count ("createchapter")) {
Dialog_Entry dialog_entry = Dialog_Entry ("book", translate("Please enter the number for the new chapter"), "", "createchapter", "");
dialog_entry.add_query ("bible", bible);
dialog_entry.add_query ("book", filter::strings::convert_to_string (book));
dialog_entry.add_query ("book", std::to_string (book));
page += dialog_entry.run ();
return page;
}
Expand All @@ -128,11 +128,11 @@ std::string bible_book (Webserver_Request& webserver_request)
chapterblock.append (R"(<a href="chapter?bible=)");
chapterblock.append (bible);
chapterblock.append ("&book=");
chapterblock.append (filter::strings::convert_to_string (book));
chapterblock.append (std::to_string (book));
chapterblock.append ("&chapter=");
chapterblock.append (filter::strings::convert_to_string (chapter));
chapterblock.append (std::to_string (chapter));
chapterblock.append (R"(">)");
chapterblock.append (filter::strings::convert_to_string (chapter));
chapterblock.append (std::to_string (chapter));
chapterblock.append ("</a>\n");
}
view.set_variable ("chapterblock", chapterblock);
Expand Down
2 changes: 1 addition & 1 deletion bb/chapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ std::string bible_chapter (Webserver_Request& webserver_request)

// The book.
const int book = filter::strings::convert_to_int (webserver_request.query ["book"]);
view.set_variable ("book", filter::strings::convert_to_string (book));
view.set_variable ("book", std::to_string (book));
const std::string book_name = database::books::get_english_from_id (static_cast<book_id>(book));
view.set_variable ("book_name", filter::strings::escape_special_xml_characters (book_name));

Expand Down
2 changes: 1 addition & 1 deletion bb/css.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ std::string bible_css (Webserver_Request& webserver_request)
view.set_variable ("mode_btrl", Filter_Css::writingModeBottomTopRightLeft (direction));

const int lineheight = database::config::bible::get_line_height (bible);
view.set_variable ("lineheight", filter::strings::convert_to_string (lineheight));
view.set_variable ("lineheight", std::to_string (lineheight));

float letterspacing = static_cast<float> (database::config::bible::get_letter_spacing (bible));
letterspacing /= 10;
Expand Down
4 changes: 2 additions & 2 deletions bb/import.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ std::string bible_import (Webserver_Request& webserver_request)
filter_url_file_put_contents (datafile, data);
success_message = translate("Import has started.");
view.set_variable ("journal", journal_logic_see_journal_for_progress ());
tasks_logic_queue (IMPORTBIBLE, { datafile, bible, filter::strings::convert_to_string (book), filter::strings::convert_to_string (chapter) });
tasks_logic_queue (IMPORTBIBLE, { datafile, bible, std::to_string (book), std::to_string (chapter) });
} else {
error_message = translate("Please supply valid Unicode UTF-8 text.");
}
Expand All @@ -106,7 +106,7 @@ std::string bible_import (Webserver_Request& webserver_request)
filter_url_file_put_contents (datafile, data);
success_message = translate("Import has started.");
view.set_variable ("journal", journal_logic_see_journal_for_progress ());
tasks_logic_queue (IMPORTBIBLE, { datafile, bible, filter::strings::convert_to_string (book), filter::strings::convert_to_string (chapter) });
tasks_logic_queue (IMPORTBIBLE, { datafile, bible, std::to_string (book), std::to_string (chapter) });
} else {
error_message = translate ("Nothing was uploaded");
}
Expand Down
6 changes: 3 additions & 3 deletions bb/import_run.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void bible_import_usfm (const std::string& data, const std::string& bible, int b
if (book_number > 0) {
bible_logic::store_chapter (bible, book_number, chapter_number, chapter_data);
const std::string book_name = database::books::get_usfm_from_id (static_cast<book_id>(book_number));
Database_Logs::log ("Imported " + book_name + " " + filter::strings::convert_to_string (chapter_number));
Database_Logs::log ("Imported " + book_name + " " + std::to_string (chapter_number));
} else {
Database_Logs::log ("Could not import this data: " + chapter_data.substr (0, 1000));
}
Expand Down Expand Up @@ -225,11 +225,11 @@ void bible_import_text (const std::string& text, const std::string& bible, int b

// If no chapter marker is found, insert it at the top.
if (newtext.find("\\c") == std::string::npos) {
newtext.insert(0, "\\c " + filter::strings::convert_to_string(chapter) + "\n");
newtext.insert(0, "\\c " + std::to_string(chapter) + "\n");
}

// Import the text as USFM.
bible_logic::store_chapter (bible, book, chapter, newtext);
const std::string book_name = database::books::get_usfm_from_id (static_cast<book_id>(book));
Database_Logs::log ("Imported " + book_name + " " + filter::strings::convert_to_string (chapter) + ": " + text);
Database_Logs::log ("Imported " + book_name + " " + std::to_string (chapter) + ": " + text);
}
12 changes: 6 additions & 6 deletions bb/logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,15 @@ void bible_logic::import_resource (std::string bible, std::string resource)
const std::vector <int> chapters = database_versifications.getMaximumChapters (book);
for (const auto chapter : chapters) {

const std::string message = "Importing " + resource + " " + bookName + " chapter " + filter::strings::convert_to_string (chapter);
const std::string message = "Importing " + resource + " " + bookName + " chapter " + std::to_string (chapter);
Database_Logs::log (message, Filter_Roles::translator ());

std::vector <std::string> usfm {};

if (chapter == 0) usfm.push_back ("\\id " + database::books::get_usfm_from_id (static_cast<book_id>(book)));

if (chapter) {
usfm.push_back ("\\c " + filter::strings::convert_to_string (chapter));
usfm.push_back ("\\c " + std::to_string (chapter));
usfm.push_back ("\\p");
}

Expand Down Expand Up @@ -249,7 +249,7 @@ void bible_logic::import_resource (std::string bible, std::string resource)
html = filter::strings::replace ("\n", " ", html);

// Add the verse to the USFM.
usfm.push_back ("\\v " + filter::strings::convert_to_string (verse) + " " + filter::strings::trim (html));
usfm.push_back ("\\v " + std::to_string (verse) + " " + filter::strings::trim (html));
}
bible_logic::store_chapter (bible, book, chapter, filter::strings::implode (usfm, "\n"));
}
Expand Down Expand Up @@ -279,7 +279,7 @@ void bible_logic::log_change (const std::string& bible,
// In particular on low-power devices and on Windows, the time it took was excessive.

const std::string bookname = database::books::get_english_from_id (static_cast<book_id>(book));
const std::string passage = bible + " " + bookname + " " + filter::strings::convert_to_string (chapter);
const std::string passage = bible + " " + bookname + " " + std::to_string (chapter);

const std::string stylesheet = database::config::bible::get_export_stylesheet (bible);

Expand Down Expand Up @@ -310,7 +310,7 @@ void bible_logic::log_change (const std::string& bible,
const std::string new_text = filter_text_new.text_text->get ();
if (old_text != new_text) {
body.push_back (std::string());
body.push_back (filter_passage_display (book, chapter, filter::strings::convert_to_string (verse)));
body.push_back (filter_passage_display (book, chapter, std::to_string (verse)));
body.push_back ("Old: " + old_text);
body.push_back ("New: " + new_text);
}
Expand All @@ -337,7 +337,7 @@ void bible_logic::log_merge (const std::string& user, const std::string& bible,
const std::string& prioritized_change, const std::string& result)
{
const std::string bookname = database::books::get_english_from_id (static_cast<book_id>(book));
const std::string passage = bible + " " + bookname + " " + filter::strings::convert_to_string (chapter);
const std::string passage = bible + " " + bookname + " " + std::to_string (chapter);

std::vector <std::string> body {};

Expand Down
8 changes: 4 additions & 4 deletions bb/order.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ std::string bible_order (Webserver_Request& webserver_request)
book_id::_malachi,
};
std::vector <std::string> v_book_order {};
for (const auto book : interspersed) v_book_order.push_back (filter::strings::convert_to_string (static_cast<int>(book)));
for (const auto book : interspersed) v_book_order.push_back (std::to_string (static_cast<int>(book)));
const std::string s_book_order = filter::strings::implode (v_book_order, " ");
database::config::bible::set_book_order (bible, s_book_order);
}
Expand Down Expand Up @@ -174,7 +174,7 @@ std::string bible_order (Webserver_Request& webserver_request)
book_id::_baruch,
};
std::vector <std::string> v_book_order {};
for (const auto book : interspersed) v_book_order.push_back (filter::strings::convert_to_string (static_cast<int>(book)));
for (const auto book : interspersed) v_book_order.push_back (std::to_string (static_cast<int>(book)));
const std::string s_book_order = filter::strings::implode (v_book_order, " ");
database::config::bible::set_book_order (bible, s_book_order);
}
Expand All @@ -193,7 +193,7 @@ std::string bible_order (Webserver_Request& webserver_request)
const std::vector <int> books = filter_passage_get_ordered_books (bible);
std::vector <std::string> s_books;
for (const auto& book : books)
s_books.push_back (filter::strings::convert_to_string (book));
s_books.push_back (std::to_string (book));
filter::strings::array_move_up_down (s_books, move, !moveup.empty ());
const std::string s_order = filter::strings::implode (s_books, " ");
database::config::bible::set_book_order (bible, s_order);
Expand All @@ -203,7 +203,7 @@ std::string bible_order (Webserver_Request& webserver_request)
for (size_t i = 0; i < books.size (); i++) {
std::string bookname = database::books::get_english_from_id (static_cast<book_id>(books[i]));
bookname = translate (bookname);
view.add_iteration ("order", { std::pair ("offset", filter::strings::convert_to_string (i)), std::pair ("bookname", bookname) } );
view.add_iteration ("order", { std::pair ("offset", std::to_string (i)), std::pair ("bookname", bookname) } );
}

view.set_variable ("uparrow", filter::strings::unicode_black_up_pointing_triangle ());
Expand Down
4 changes: 2 additions & 2 deletions bb/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ std::string bible_settings (Webserver_Request& webserver_request)
if (manager_level) {
a_or_span_node = book_document.append_child("a");
std::string href = filter_url_build_http_query ("book", "bible", bible);
href = filter_url_build_http_query (href, "book", filter::strings::convert_to_string (book));
href = filter_url_build_http_query (href, "book", std::to_string (book));
a_or_span_node.append_attribute("href") = href.c_str();
} else {
a_or_span_node = book_document.append_child("span");
Expand All @@ -223,7 +223,7 @@ std::string bible_settings (Webserver_Request& webserver_request)
std::stringstream bookblock2 {};
book_document.print (bookblock2, "", pugi::format_raw);
view.set_variable ("bookblock", bookblock2.str());
view.set_variable ("book_count", filter::strings::convert_to_string (static_cast<int>(book_ids.size())));
view.set_variable ("book_count", std::to_string (static_cast<int>(book_ids.size())));


// Public feedback.
Expand Down
6 changes: 3 additions & 3 deletions book/create.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ bool book_create (const std::string & bible, const book_id book, const int chapt
const int ch = row.m_chapter;
const int verse = filter::strings::convert_to_int (row.m_verse);
if ((chapter < 0) || (chapter == ch)) {
data = "\\c " + filter::strings::convert_to_string (ch) + "\n";
data = "\\c " + std::to_string (ch) + "\n";
data += "\\p\n";
for (int i = 1; i <= verse; i++) {
data += "\\v " + filter::strings::convert_to_string (i) + "\n";
data += "\\v " + std::to_string (i) + "\n";
}
bible_logic::store_chapter (bible, static_cast<int>(book), ch, data);
chapters_created.push_back (ch);
Expand All @@ -91,7 +91,7 @@ bool book_create (const std::string & bible, const book_id book, const int chapt
std::string created;
for (const auto& chapter_created : chapters_created) {
if (!created.empty ()) created.append (" ");
created.append (filter::strings::convert_to_string (chapter_created));
created.append (std::to_string (chapter_created));
}
feedback.push_back (translate("The following chapters have been created:") + " " + created);
return true;
Expand Down
12 changes: 6 additions & 6 deletions changes/change.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ std::string changes_change (Webserver_Request& webserver_request)

// The identifier of the change notification.
const int id {filter::strings::convert_to_int (webserver_request.query ["get"])};
view.set_variable ("id", filter::strings::convert_to_string (id));
view.set_variable ("id", std::to_string (id));


// Get old text, modification, new text, date.
Expand Down Expand Up @@ -179,28 +179,28 @@ std::string changes_change (Webserver_Request& webserver_request)
std::string href {};
if (live_notes_editor) {
a_node.append_attribute("class") = "opennote";
href = filter::strings::convert_to_string (note);
href = std::to_string (note);
} else {
href = "/notes/note?id=" + filter::strings::convert_to_string (note);
href = "/notes/note?id=" + std::to_string (note);
}
a_node.append_attribute("href") = href.c_str();
a_node.text().set(summary.c_str());
td_node = tr_node.append_child("td");
if (subscription) {
pugi::xml_node a_node2 = td_node.append_child("a");
a_node2.append_attribute("href") = ("unsubscribe" + filter::strings::convert_to_string (note)).c_str();
a_node2.append_attribute("href") = ("unsubscribe" + std::to_string (note)).c_str();
a_node2.text().set(("[" + translate("unsubscribe") + "]").c_str());
}
td_node = tr_node.append_child("td");
if (assignment) {
pugi::xml_node a_node2 = td_node.append_child("a");
a_node2.append_attribute("href") = ("unassign" + filter::strings::convert_to_string (note)).c_str();
a_node2.append_attribute("href") = ("unassign" + std::to_string (note)).c_str();
a_node2.text().set(("[" + translate("I have done my part on it") + "]").c_str());
}
td_node = tr_node.append_child("td");
if (level >= Filter_Roles::manager ()) {
pugi::xml_node a_node2 = td_node.append_child("a");
a_node2.append_attribute("href") = ("delete" + filter::strings::convert_to_string (note)).c_str();
a_node2.append_attribute("href") = ("delete" + std::to_string (note)).c_str();
a_node2.text().set(("[" + translate("mark for deletion") + "]").c_str());
}
}
Expand Down
Loading

0 comments on commit 2f1271c

Please sign in to comment.