Skip to content

Commit

Permalink
Make pugi namespace explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
teusbenschop committed Apr 14, 2024
1 parent 63234fc commit 02a861a
Show file tree
Hide file tree
Showing 39 changed files with 424 additions and 461 deletions.
40 changes: 20 additions & 20 deletions bb/logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ void bible_logic::merge_irregularity_mail (const std::vector <std::string>& user
// Add some information for the user.
document.append_child ("hr");
document.append_child ("br");
xml_node div_node {};
pugi::xml_node div_node {};
div_node = document.append_child ("div");
// Disabled: https://github.com/bibledit/cloud/issues/401
// div_node.append_attribute ("style") = "font-size: 30%";
Expand Down Expand Up @@ -518,7 +518,7 @@ void bible_logic::merge_irregularity_mail (const std::vector <std::string>& user

// Convert the document to a string.
std::stringstream output {};
document.print (output, "", format_raw);
document.print (output, "", pugi::format_raw);
const std::string html = output.str ();

// Schedule the mail for sending to the user(s).
Expand All @@ -541,8 +541,8 @@ void bible_logic::unsafe_save_mail (std::string subject, const std::string& expl
subject.append (" | " + filter_passage_display (book, chapter, std::string()));

// Create the body of the email.
xml_document document {};
xml_node node {};
pugi::xml_document document {};
pugi::xml_node node {};
node = document.append_child ("h3");
node.text ().set (subject.c_str());

Expand All @@ -559,7 +559,7 @@ void bible_logic::unsafe_save_mail (std::string subject, const std::string& expl

// Convert the document to a string.
std::stringstream output {};
document.print (output, "", format_raw);
document.print (output, "", pugi::format_raw);
const std::string html = output.str ();

// Schedule the mail for sending to the user.
Expand Down Expand Up @@ -607,8 +607,8 @@ void bible_logic::client_receive_merge_mail (const std::string& bible, int book,
subject.append (" | " + filter_passage_display (book, chapter, std::string()));

// Create the body of the email.
xml_document document {};
xml_node node {};
pugi::xml_document document {};
pugi::xml_node node {};
node = document.append_child ("h3");
node.text ().set (subject.c_str());

Expand Down Expand Up @@ -648,7 +648,7 @@ void bible_logic::client_receive_merge_mail (const std::string& bible, int book,

// Convert the document to a string.
std::stringstream output {};
document.print (output, "", format_raw);
document.print (output, "", pugi::format_raw);
const std::string html = output.str ();

// Schedule the mail for sending to the user.
Expand Down Expand Up @@ -683,8 +683,8 @@ void bible_logic::client_mail_pending_bible_updates (const std::string& user)
subject.append (" | " + filter_passage_display (book, chapter, std::string()));

// Create the body of the email.
xml_document document {};
xml_node node {};
pugi::xml_document document {};
pugi::xml_node node {};
node = document.append_child ("h3");
node.text ().set (subject.c_str());

Expand Down Expand Up @@ -712,7 +712,7 @@ void bible_logic::client_mail_pending_bible_updates (const std::string& user)

// Convert the document to a string.
std::stringstream output {};
document.print (output, "", format_raw);
document.print (output, "", pugi::format_raw);
const std::string html = output.str ();

// Schedule the mail for sending to the user.
Expand Down Expand Up @@ -755,8 +755,8 @@ void bible_logic::client_no_write_access_mail (const std::string& bible, int boo
subject.append (" | " + filter_passage_display (book, chapter, ""));

// Create the body of the email.
xml_document document {};
xml_node node {};
pugi::xml_document document {};
pugi::xml_node node {};
node = document.append_child ("h3");
node.text ().set (subject.c_str());

Expand Down Expand Up @@ -787,7 +787,7 @@ void bible_logic::client_no_write_access_mail (const std::string& bible, int boo

// Convert the document to a string.
std::stringstream output {};
document.print (output, "", format_raw);
document.print (output, "", pugi::format_raw);
const std::string html = output.str ();

// Schedule the mail for sending to the user.
Expand Down Expand Up @@ -825,8 +825,8 @@ void bible_logic::recent_save_email (const std::string& bible,
subject.append (" | " + filter_passage_display (book, chapter, ""));

// Create the body of the email.
xml_document document {};
xml_node node {};
pugi::xml_document document {};
pugi::xml_node node {};
node = document.append_child ("h3");
node.text ().set (subject.c_str());

Expand Down Expand Up @@ -877,7 +877,7 @@ void bible_logic::recent_save_email (const std::string& bible,

// Convert the document to a string.
std:: stringstream output {};
document.print (output, "", format_raw);
document.print (output, "", pugi::format_raw);
const std::string html = output.str ();

// Schedule the mail for sending to the user.
Expand All @@ -902,8 +902,8 @@ void bible_logic::optional_merge_irregularity_email (const std::string& bible, i
subject.append (" | " + filter_passage_display (book, chapter, ""));

// Create the body of the email.
xml_document document {};
xml_node node {};
pugi::xml_document document {};
pugi::xml_node node {};
node = document.append_child ("h3");
node.text ().set (subject.c_str());

Expand Down Expand Up @@ -990,7 +990,7 @@ void bible_logic::optional_merge_irregularity_email (const std::string& bible, i

// Convert the document to a string.
std::stringstream output {};
document.print (output, "", format_raw);
document.print (output, "", pugi::format_raw);
const std::string html = output.str ();

// Schedule the mail for sending to the user.
Expand Down
1 change: 0 additions & 1 deletion changes/changes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
#endif
#pragma GCC diagnostic pop
using namespace std;
using namespace pugi;


string changes_changes_url ()
Expand Down
9 changes: 4 additions & 5 deletions changes/logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
#include <filter/string.h>
#include <webserver/request.h>
using namespace std;
using namespace pugi;


void changes_logic_start ()
Expand Down Expand Up @@ -106,23 +105,23 @@ string changes_interlinks (Webserver_Request& webserver_request, string my_url)
#endif

// Generate the links in XML.
xml_document document {};
pugi::xml_document document {};
bool first {true};
for (unsigned int i = 0; i < urls.size (); i++) {
if (!first) {
xml_node node = document.append_child ("span");
pugi::xml_node node = document.append_child ("span");
node.text ().set (" | ");
}
first = false;
xml_node a = document.append_child ("a");
pugi::xml_node a = document.append_child ("a");
string href = "/" + urls[i];
a.append_attribute ("href") = href.c_str();
a.text ().set (labels[i].c_str());
}

// Convert the document to a string.
stringstream output {};
document.print (output, "", format_raw);
document.print (output, "", pugi::format_raw);
return output.str ();
}

Expand Down
7 changes: 3 additions & 4 deletions confirm/worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#endif
#pragma GCC diagnostic pop
using namespace std;
using namespace pugi;


#ifdef HAVE_CLOUD
Expand Down Expand Up @@ -67,8 +66,8 @@ void Confirm_Worker::setup (string mailto, string username,
{
Database_Confirm database_confirm;
unsigned int confirmation_id = database_confirm.get_new_id ();
xml_document document;
xml_node node = document.append_child ("p");
pugi::xml_document document;
pugi::xml_node node = document.append_child ("p");
string information;
if (config::logic::default_bibledit_configuration ()) {
information = translate ("Please confirm this request by clicking this following link:");
Expand All @@ -79,7 +78,7 @@ void Confirm_Worker::setup (string mailto, string username,
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, "", format_raw);
document.print (output, "", pugi::format_raw);
initial_body += output.str ();
email_schedule (mailto, initial_subject, initial_body);
database_confirm.store (confirmation_id, query, mailto, subsequent_subject, subsequent_body, username);
Expand Down
1 change: 0 additions & 1 deletion editone2/load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include <edit/logic.h>
#include <database/config/bible.h>
using namespace std;
using namespace pugi;


string editone2_load_url ()
Expand Down
32 changes: 16 additions & 16 deletions editone2/logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,16 @@ void editone_logic_suffix_html (string editable_last_p_style, string usfm, strin
// <p class="q1"><span class="v">7</span><span /><span>For Yahweh knows the way of the righteous,</span></p><p class="q2"><span>but the way of the wicked shall perish.</span></p>
if (!html.empty ()) {
if (!editable_last_p_style.empty ()) {
xml_document document;
pugi::xml_document document;
html = filter::strings::html2xml (html);
document.load_string (html.c_str(), parse_ws_pcdata_single);
xml_node p_node = document.first_child ();
document.load_string (html.c_str(), pugi::parse_ws_pcdata_single);
pugi::xml_node p_node = document.first_child ();
string p_style = p_node.attribute ("class").value ();
if (p_style.empty ()) {
p_node.append_attribute ("class") = editable_last_p_style.c_str ();
}
stringstream output;
document.print (output, "", format_raw);
document.print (output, "", pugi::format_raw);
html = output.str ();
}
}
Expand Down Expand Up @@ -125,8 +125,8 @@ void editone_logic_move_notes_v2 (string & prefix, string & suffix)
prefix = filter::strings::html2xml (prefix);

// Load the prefix.
xml_document document;
document.load_string (prefix.c_str(), parse_ws_pcdata_single);
pugi::xml_document document;
document.load_string (prefix.c_str(), pugi::parse_ws_pcdata_single);

// The notes separator class.
const char * b_notes_class = "b-notes";
Expand All @@ -135,9 +135,9 @@ void editone_logic_move_notes_v2 (string & prefix, string & suffix)
// - the possible notes separator.
// - any possible subsequent note nodes.
bool within_notes = false;
xml_node prefix_separator_node;
vector <xml_node> prefix_note_nodes;
for (xml_node p_node : document.children ()) {
pugi::xml_node prefix_separator_node;
vector <pugi::xml_node> prefix_note_nodes;
for (pugi::xml_node p_node : document.children ()) {
if (within_notes) {
prefix_note_nodes.push_back (p_node);
}
Expand All @@ -155,9 +155,9 @@ void editone_logic_move_notes_v2 (string & prefix, string & suffix)
// Remove the note node(s) from the prefix.
// Remove the notes separator node from the prefix.
string notes_text;
for (xml_node p_node : prefix_note_nodes) {
for (pugi::xml_node p_node : prefix_note_nodes) {
stringstream ss;
p_node.print (ss, "", format_raw);
p_node.print (ss, "", pugi::format_raw);
string note = ss.str ();
notes_text.append (note);
document.remove_child (p_node);
Expand All @@ -167,19 +167,19 @@ void editone_logic_move_notes_v2 (string & prefix, string & suffix)
// Convert the XML document back to a possibly cleaned prefix without notes.
{
stringstream ss;
document.print (ss, "", format_raw);
document.print (ss, "", pugi::format_raw);
prefix = ss.str ();
}

// Do a html to xml conversion in the suffix to avoid a mismatched tag error.
suffix = filter::strings::html2xml (suffix);

// Load the suffix.
document.load_string (suffix.c_str(), parse_ws_pcdata_single);
document.load_string (suffix.c_str(), pugi::parse_ws_pcdata_single);

// Iterate over the document to find the possible notes separator.
xml_node suffix_separator_node;
for (xml_node p_node : document.children ()) {
pugi::xml_node suffix_separator_node;
for (pugi::xml_node p_node : document.children ()) {
string cls = p_node.attribute ("class").value ();
if (cls == b_notes_class) {
suffix_separator_node = p_node;
Expand All @@ -199,7 +199,7 @@ void editone_logic_move_notes_v2 (string & prefix, string & suffix)
// Convert the DOM to suffix text.
{
stringstream ss;
document.print (ss, "", format_raw);
document.print (ss, "", pugi::format_raw);
suffix = ss.str ();
}
}
Expand Down
32 changes: 16 additions & 16 deletions editor/html2format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void Editor_Html2Format::load (string html)
// See http://pugixml.org/docs/manual.html for more information.
// It is not enough to only parse with parse_ws_pcdata_single, it really needs parse_ws_pcdata.
// This is significant for, for example, the space after verse numbers, among other cases.
xml_parse_result result = document.load_string (xml.c_str(), parse_ws_pcdata);
pugi::xml_parse_result result = document.load_string (xml.c_str(), pugi::parse_ws_pcdata);
// Log parsing errors.
pugixml_utils_error_logger (&result, xml);
}
Expand All @@ -60,46 +60,46 @@ void Editor_Html2Format::run ()
void Editor_Html2Format::process ()
{
// Iterate over the children to retrieve the "p" elements, then process them.
xml_node body = document.first_child ();
for (xml_node node : body.children()) {
pugi::xml_node body = document.first_child ();
for (pugi::xml_node node : body.children()) {
// Process the node.
processNode (node);
}
}


void Editor_Html2Format::processNode (xml_node node)
void Editor_Html2Format::processNode (pugi::xml_node node)
{
switch (node.type ()) {
case node_element:
case pugi::node_element:
{
// Skip a note with class "ql-cursor" because that is an internal Quill node.
// The user didn't insert it.
string classs = node.attribute("class").value();
if (classs == "ql-cursor") break;
// Process node normally.
openElementNode (node);
for (xml_node child : node.children()) {
for (pugi::xml_node child : node.children()) {
processNode (child);
}
closeElementNode (node);
break;
}
case node_pcdata:
case pugi::node_pcdata:
{
// Add the text with the current character format to the containers.
string text = node.text ().get ();
texts.push_back(text);
formats.push_back(current_character_format);
break;
}
case node_null:
case node_document:
case node_cdata:
case node_comment:
case node_pi:
case node_declaration:
case node_doctype:
case pugi::node_null:
case pugi::node_document:
case pugi::node_cdata:
case pugi::node_comment:
case pugi::node_pi:
case pugi::node_declaration:
case pugi::node_doctype:
default:
{
string nodename = node.name ();
Expand All @@ -110,7 +110,7 @@ void Editor_Html2Format::processNode (xml_node node)
}


void Editor_Html2Format::openElementNode (xml_node node)
void Editor_Html2Format::openElementNode (pugi::xml_node node)
{
// The tag and class names of this element node.
string tagName = node.name ();
Expand All @@ -134,7 +134,7 @@ void Editor_Html2Format::openElementNode (xml_node node)
}


void Editor_Html2Format::closeElementNode (xml_node node)
void Editor_Html2Format::closeElementNode (pugi::xml_node node)
{
// The tag and class names of this element node.
string tagName = node.name ();
Expand Down
Loading

0 comments on commit 02a861a

Please sign in to comment.