Skip to content

Commit

Permalink
namespace std::
Browse files Browse the repository at this point in the history
  • Loading branch information
teusbenschop committed Apr 18, 2024
1 parent fcaeebb commit 5e38925
Show file tree
Hide file tree
Showing 95 changed files with 158 additions and 164 deletions.
13 changes: 6 additions & 7 deletions checks/settingspairs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@
#include <access/bible.h>
#include <menu/logic.h>
#include <checks/settings.h>
using namespace std;


string checks_settingspairs_url ()
std::string checks_settingspairs_url ()
{
return "checks/settingspairs";
}
Expand All @@ -54,26 +53,26 @@ bool checks_settingspairs_acl ([[maybe_unused]] Webserver_Request& webserver_req
}


string checks_settingspairs (Webserver_Request& webserver_request)
std::string checks_settingspairs (Webserver_Request& webserver_request)
{
string page {};
std::string page {};
Assets_Header header = Assets_Header (translate ("Matching pairs"), webserver_request);
header.add_bread_crumb (menu_logic_settings_menu (), menu_logic_settings_text ());
header.add_bread_crumb (checks_settings_url (), menu_logic_checks_settings_text ());
page = header.run ();
Assets_View view {};


string bible = access_bible::clamp (webserver_request, webserver_request.database_config_user()->getBible ());
const std::string bible = access_bible::clamp (webserver_request, webserver_request.database_config_user()->getBible ());
view.set_variable ("bible", bible);


if (webserver_request.post.count ("pairs")) {
string fragment = webserver_request.post["pairs"];
const std::string fragment = webserver_request.post["pairs"];
std::vector <std::string> errors {};
std::vector <std::string> pairs = filter::strings::explode (fragment, ' ');
bool okay {true};
for (const auto & pair : pairs) {
for (const auto& pair : pairs) {
const size_t length = filter::strings::unicode_string_length (pair);
if (length != 2) {
errors.push_back (translate ("A pair should consist of two characters:") + " " + pair);
Expand Down
11 changes: 5 additions & 6 deletions checks/settingspatterns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@
#include <assets/header.h>
#include <menu/logic.h>
#include <checks/settings.h>
using namespace std;


string checks_settingspatterns_url ()
std::string checks_settingspatterns_url ()
{
return "checks/settingspatterns";
}
Expand All @@ -47,21 +46,21 @@ bool checks_settingspatterns_acl ([[maybe_unused]] Webserver_Request& webserver_
}


string checks_settingspatterns (Webserver_Request& webserver_request)
std::string checks_settingspatterns (Webserver_Request& webserver_request)
{
string page {};
std::string page {};
Assets_Header header = Assets_Header (translate ("Patterns"), webserver_request);
header.add_bread_crumb (menu_logic_settings_menu (), menu_logic_settings_text ());
header.add_bread_crumb (checks_settings_url (), menu_logic_checks_settings_text ());
page = header.run ();
Assets_View view {};


string bible = access_bible::clamp (webserver_request, webserver_request.database_config_user()->getBible ());
const std::string bible = access_bible::clamp (webserver_request, webserver_request.database_config_user()->getBible ());


if (webserver_request.post.count ("patterns")) {
string patterns = webserver_request.post ["patterns"];
const std::string patterns = webserver_request.post ["patterns"];
if (!bible.empty ()) Database_Config_Bible::setCheckingPatterns (bible, patterns);
view.set_variable ("success", translate("The patterns were saved"));
}
Expand Down
9 changes: 4 additions & 5 deletions checks/settingssentences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@
#include <access/bible.h>
#include <menu/logic.h>
#include <checks/settings.h>
using namespace std;


string checks_settingssentences_url ()
std::string checks_settingssentences_url ()
{
return "checks/settingssentences";
}
Expand All @@ -54,17 +53,17 @@ bool checks_settingssentences_acl ([[maybe_unused]] Webserver_Request& webserver
}


string checks_settingssentences (Webserver_Request& webserver_request)
std::string checks_settingssentences (Webserver_Request& webserver_request)
{
string page {};
std::string page {};
Assets_Header header = Assets_Header (translate ("Sentence Structure"), webserver_request);
header.add_bread_crumb (menu_logic_settings_menu (), menu_logic_settings_text ());
header.add_bread_crumb (checks_settings_url (), menu_logic_checks_settings_text ());
page = header.run ();
Assets_View view {};


string bible = access_bible::clamp (webserver_request, webserver_request.database_config_user()->getBible ());
const std::string bible = access_bible::clamp (webserver_request, webserver_request.database_config_user()->getBible ());


if (webserver_request.post.count ("capitals")) {
Expand Down
23 changes: 11 additions & 12 deletions checks/space.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <filter/usfm.h>
#include <database/check.h>
#include <locale/translate.h>
using namespace std;


namespace checks::space {
Expand All @@ -34,7 +33,7 @@ void double_space_usfm (const std::string& bible, int book, int chapter, int ver
if (pos != std::string::npos) {
int start = static_cast<int>(pos) - 10;
if (start < 0) start = 0;
string fragment = data.substr (static_cast <size_t> (start), 20);
const std::string fragment = data.substr (static_cast <size_t> (start), 20);
Database_Check database_check {};
database_check.recordOutput (bible, book, chapter, verse, translate ("Double space:") + " ... " + fragment + " ...");
}
Expand All @@ -46,7 +45,7 @@ void space_before_punctuation (const std::string& bible, int book, int chapter,
Database_Check database_check {};
for (const auto & element : texts) {
const int verse = element.first;
string text = element.second;
const std::string text = element.second;
if (text.find (" ,") != std::string::npos) {
database_check.recordOutput (bible, book, chapter, verse, translate ("Space before a comma"));
}
Expand Down Expand Up @@ -75,26 +74,26 @@ void space_end_verse (const std::string& bible, int book, int chapter, const std
std::vector <int> verses = filter::usfm::get_verse_numbers (usfm);
for (auto verse : verses) {
if (!verse) continue;
string text = filter::usfm::get_verse_text (usfm, verse);
std::vector <std::string> items = filter::usfm::get_markers_and_text (text);
std::string text = filter::usfm::get_verse_text (usfm, verse);
const 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);
}
}
bool hit {false};
if (!text.empty ()) {
string trimmed = filter::strings::trim (text);
const std::string trimmed = filter::strings::trim (text);
if (trimmed.empty ()) hit = true;
char lastchar = text.back ();
const char lastchar = text.back ();
if (lastchar == ' ') hit = true;
}
if (hit) database_check.recordOutput (bible, book, chapter, verse, translate ("Space at the end of the verse"));
}
}


bool transpose_note_space (string & usfm)
bool transpose_note_space (std::string & usfm)
{
// Samples of footnote and cross reference markers that have spacing to be transposed.
// \v 1 Verse\f + \fr 3.1\fk keyword\ft Text.\f* one.
Expand All @@ -103,10 +102,10 @@ bool transpose_note_space (string & usfm)
bool transposed {false};
const size_t pos = usfm.find(" ");
if (pos != std::string::npos) {
std::map <string, std::string> data = {
pair (R"(\fk )", R"( \fk )"),
pair (R"(\ft )", R"( \ft )"),
pair (R"(\xt )", R"( \xt )")
std::map <std::string, std::string> data = {
std::pair (R"(\fk )", R"( \fk )"),
std::pair (R"(\ft )", R"( \ft )"),
std::pair (R"(\xt )", R"( \xt )")
};
for (const auto & search_replace : data) {
int count {0};
Expand Down
15 changes: 7 additions & 8 deletions checks/suppress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@
#include <demo/logic.h>
#include <sendreceive/logic.h>
#include <access/bible.h>
using namespace std;


string checks_suppress_url ()
std::string checks_suppress_url ()
{
return "checks/suppress";
}
Expand All @@ -46,12 +45,12 @@ bool checks_suppress_acl (Webserver_Request& webserver_request)
}


string checks_suppress (Webserver_Request& webserver_request)
std::string checks_suppress (Webserver_Request& webserver_request)
{
Database_Check database_check {};


string page {};
std::string page {};
page = assets_page::header (translate ("Suppressed checking results"), webserver_request);
Assets_View view {};

Expand All @@ -75,16 +74,16 @@ string checks_suppress (Webserver_Request& webserver_request)
}


string block {};
std::string block {};
const std::vector <Database_Check_Hit> suppressions = database_check.getSuppressions ();
for (const auto & suppression : suppressions) {
string bible = suppression.bible;
std::string bible = suppression.bible;
// Only display entries for Bibles the user has write access to.
if (in_array (bible, bibles)) {
int id = suppression.rowid;
bible = filter::strings::escape_special_xml_characters (bible);
string passage = filter_passage_display_inline ({Passage ("", suppression.book, suppression.chapter, filter::strings::convert_to_string (suppression.verse))});
string result = filter::strings::escape_special_xml_characters (suppression.data);
const std::string passage = filter_passage_display_inline ({Passage ("", suppression.book, suppression.chapter, filter::strings::convert_to_string (suppression.verse))});
std::string result = filter::strings::escape_special_xml_characters (suppression.data);
result.insert (0, bible + " " + passage + " ");
block.append (R"(<p style="color:grey;">)");
block.append (R"(<a href="suppress?release=)" + filter::strings::convert_to_string (id) + R"(">)");
Expand Down
Loading

0 comments on commit 5e38925

Please sign in to comment.