aboutsummaryrefslogtreecommitdiff
path: root/src/lib/libbible.cc
diff options
context:
space:
mode:
authorYour Name <you@example.com>2022-04-18 12:02:48 -0400
committerYour Name <you@example.com>2022-04-18 12:02:48 -0400
commitddc05ee8fa60ec240d09d1d71a08f9521a1bd8b2 (patch)
treec54d4ffa92cb171ba23a81b2d9d4c6b5e3b41dd4 /src/lib/libbible.cc
parentf843d4e1af82ac7485e8e9428e7411d88d39450e (diff)
downloadlibbible-69e520c82fdec0a1c6c95b563bb18fa034b74759.tar.gz (sig)
libbible-69e520c82fdec0a1c6c95b563bb18fa034b74759.tar.bz2 (sig)
libbible-69e520c82fdec0a1c6c95b563bb18fa034b74759.zip (sig)
Speed gains when working with multiple modulesv1.0.4
Diffstat (limited to 'src/lib/libbible.cc')
-rw-r--r--src/lib/libbible.cc31
1 files changed, 25 insertions, 6 deletions
diff --git a/src/lib/libbible.cc b/src/lib/libbible.cc
index c7a4c61..c6850f7 100644
--- a/src/lib/libbible.cc
+++ b/src/lib/libbible.cc
@@ -12,8 +12,12 @@ using namespace std;
SWMgr library(new MarkupFilterMgr(FMT_XHTML));
OSISFootnotes filter;
-vector<string> getBooks(SWModule *target) {
+vector<string> getBooksSWModule(SWModule *target) {
vector<string> books;
+ if(target == nullptr) {
+ // Module doesn't exist
+ return books;
+ }
VerseKey *key = (VerseKey *) target->getKey();
for(char t = 1; t <= key->getTestamentMax(); t++) {
key->setTestament(t);
@@ -26,9 +30,9 @@ vector<string> getBooks(SWModule *target) {
}
// Another issue (maybe bug?) Some translations are NT only,
// but still report OT books/chapters.
- if(string(target->renderText()).empty()) {
- continue;
- }
+ //if(string(target->renderText()).empty()) {
+ // continue;
+ //}
books.push_back(key->getBookName());
}
}
@@ -42,11 +46,26 @@ map<string, vector<string>> libbible::getModules() {
for (it = library.getModules().begin(); it != library.getModules().end(); it++) {
string modName = (*it).second->getName();
SWModule *target = library.getModule(modName.c_str());
- mods[modName] = getBooks(target);
+ mods[modName] = getBooksSWModule(target);
}
return mods;
}
+vector<string> libbible::getModuleNames() {
+ library.load();
+ vector<string> mods;
+ ModMap::iterator it;
+ for (it = library.getModules().begin(); it != library.getModules().end(); it++) {
+ mods.push_back((*it).second->getName());
+ }
+ return mods;
+}
+
+vector<string> libbible::getBooks(string modName) {
+ library.load();
+ return getBooksSWModule(library.getModule(modName.c_str()));
+}
+
vector<libbible::passage> libbible::getPassages(string modName, string book) {
vector<libbible::passage> passages;
SWModule *target = library.getModule(modName.c_str());
@@ -91,7 +110,7 @@ libbible::passage libbible::getPassage(string modName, string reference) {
// Bad input
return pass;
}
- vector<string> validBooks = getBooks(target);
+ vector<string> validBooks = getBooksSWModule(target);
//printf("Hey, I'm inferring missing parts!\n");
// Let's use the target to help us
target->setKey(reference.c_str());