20
20
#include <related/logic.h>
21
21
#include <database/books.h>
22
#pragma GCC diagnostic push
23
#pragma GCC diagnostic ignored "-Weffc++"
22
24
#include <pugixml/pugixml.hpp>
25
#pragma GCC diagnostic pop
23
26
#include <filter/url.h>
24
27
#include <filter/string.h>
25
28
#include <filter/usfm.h>
54
57
string verse = reference.attribute ("verse").value ();
55
58
vector <int> verses;
56
if (usfm_handle_verse_range (verse, verses)) {
59
if (filter::usfm::handle_verse_range (verse, verses)) {
57
60
match = in_array (convert_to_int (input_verse), verses);
59
62
match = (verse == input_verse);
63
66
// Store all related passages.
65
for (xml_node reference : set.children ()) {
66
string bookname = reference.attribute ("book").value ();
67
int book = Database_Books::getIdFromEnglish (bookname);
68
int chapter = convert_to_int (reference.attribute ("chapter").value ());
69
string verse = reference.attribute ("verse").value ();
68
for (xml_node passage_node : set.children ()) {
69
string related_bookname = passage_node.attribute ("book").value ();
70
int related_book = Database_Books::getIdFromEnglish (related_bookname);
71
int related_chapter = convert_to_int (passage_node.attribute ("chapter").value ());
72
string verse = passage_node.attribute ("verse").value ();
70
73
vector <int> verses;
71
if (usfm_handle_verse_range (verse, verses));
74
if (filter::usfm::handle_verse_range (verse, verses));
72
75
else verses.push_back (convert_to_int (verse));
73
for (auto verse : verses) {
74
if (book && chapter) {
75
Passage passage ("", book, chapter, convert_to_string (verse));
76
for (auto related_verse : verses) {
77
if (related_book && related_chapter) {
78
Passage passage ("", related_book, related_chapter, convert_to_string (related_verse));
76
79
int i = filter_passage_to_integer (passage);
77
80
// No duplicate passages to be included.
78
81
if (!in_array (i, passages)) {
100
103
// Get details about the book in the passage.
101
104
// It assumes all input passages refer to the same book.
102
string bookname = Database_Books::getEnglishFromId (input[0].book);
103
string booktype = Database_Books::getType (input[0].book);
105
string bookname = Database_Books::getEnglishFromId (input[0].m_book);
106
string booktype = Database_Books::getType (input[0].m_book);
104
107
bool is_ot = (booktype == "ot");
105
108
bool is_nt = (booktype == "nt");
121
124
// Search for parallel passages.
122
125
for (xml_node passages : parallel_document.children ()) {
123
126
for (xml_node section : passages.children ()) {
124
related_logic_search_related (bookname, input_passage.chapter, input_passage.verse, section, related_passages);
127
related_logic_search_related (bookname, input_passage.m_chapter, input_passage.m_verse, section, related_passages);
127
130
// Search for quotes.
128
131
for (xml_node passages : quotation_document.children ()) {
129
related_logic_search_related (bookname, input_passage.chapter, input_passage.verse, passages, related_passages);
132
related_logic_search_related (bookname, input_passage.m_chapter, input_passage.m_verse, passages, related_passages);