Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/kovzol/bibref
Browse files Browse the repository at this point in the history
  • Loading branch information
kovzol committed Jan 20, 2024
2 parents d0c363c + 11c2568 commit 155d534
Show file tree
Hide file tree
Showing 21 changed files with 1,407 additions and 952 deletions.
19 changes: 19 additions & 0 deletions Doxyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
PROJECT_NAME = bibref
PROJECT_NUMBER = 2023-12-18
PROJECT_BRIEF = A tool to find internal references in the Bible
PROJECT_LOGO = logo-Psalm40-doxygen.png

EXTRACT_ALL = YES
EXTRACT_PRIVATE = YES

# Important: Here the .h files are not listed. Otherwise we get duplications.
FILE_PATTERNS = *.dox *.cpp *.md

# This is important for multiline comments (beginning with "///", for example).
JAVADOC_AUTOBRIEF = YES

# We put the generated output in docs/. Note that html/ in the root folder is used for something different.
HTML_OUTPUT = docs/html
LATEX_OUTPUT = docs/latex

IMAGE_PATH = .
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ BUILD_DIR ?= ./wasm-build

SRCS := book.cpp books.cpp cli.cpp fingerprint.cpp main.cpp psalmsinfo.cpp
OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
DOXS := book.dox books.dox cli.dox fingerprint.dox main.dox psalmsinfo.dox

CPPFLAGS += -I/usr/include/sword -s USE_BOOST_HEADERS=1

Expand All @@ -80,7 +81,15 @@ $(BUILD_DIR)/%.cpp.o: %.cpp
$(MKDIR_P) $(dir $@)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@

.PHONY: clean
documentation: docs/latex/refman.pdf docs/html/index.html

docs/latex/refman.pdf: docs/latex/refman.tex
$(MAKE) -C docs/latex

docs/html/index.html docs/latex/refman.tex: Doxyfile $(SRCS) $(DOXS) README.md logo-Psalm40-doxygen.png
doxygen Doxyfile

.PHONY: clean documentation

clean:
$(RM) -r $(BUILD_DIR)
Expand Down
137 changes: 66 additions & 71 deletions book.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,148 +4,143 @@ using namespace std;

#include "book.h"

Book::Book (string n) {
name = n;
// cerr << "Book " << n << " created" << endl;
}

void Book::setInfo(string n) {
info = n;
void Book::setModuleName(const string& n) {
m_moduleName = n;
}

string Book::getName() {
return name;
return m_name;
}

string Book::getInfo() {
return info;
string Book::getModuleName() {
return m_moduleName;
}

void Book::addVerse(string n, string i, vector<int> t) {
int start = text.length();
void Book::addVerse(const string& n, const string& i, vector<int> t) {
int start = m_text.length();
int length = n.length();
int tokensStart = tokens.size();
int tokensStart = m_tokens.size();
int tokensLength = t.size();
addVerse(start, length, i, tokensStart, tokensLength);
text += n;
tokens.insert(tokens.end(), t.begin(), t.end());
m_text += n;
m_tokens.insert(m_tokens.end(), t.begin(), t.end());
}

void Book::addVerse(int start, int length, string info, int tokensStart, int tokensLength) {
Verse v = {start, length, tokensStart, tokensLength, info};
// cerr << start << " " << length << " " << info << endl;
verses.push_back(v);
m_verses.push_back(v);
}

class InvalidVerseReference: public exception
class InvalidVerseReferenceException: public exception
{
virtual const char* what() const throw()
{
return "Invalid verse reference.";
}
} InvalidVerseReference;
} InvalidVerseReferenceException;

class InvalidPosition: public exception
class InvalidPositionException: public exception
{
virtual const char* what() const throw()
{
return "Invalid position.";
}
} InvalidPosition;
} InvalidPositionException;

string Book::getVerse(string i) {
for (int j=0; j<verses.size(); ++j) {
int match = verses[j].info.compare(i);
for (int j=0; j<m_verses.size(); ++j) {
int match = m_verses[j].m_info.compare(i);
if (match == 0) {
string found = text.substr(verses[j].start,verses[j].length);
string found = m_text.substr(m_verses[j].m_start,m_verses[j].m_length);
return found;
}
}
throw InvalidVerseReference;
throw InvalidVerseReferenceException;
}

vector<int> Book::getVerseTokens(string i) {
for (int j=0; j<verses.size(); ++j) {
int match = verses[j].info.compare(i);
for (int j=0; j<m_verses.size(); ++j) {
int match = m_verses[j].m_info.compare(i);
if (match == 0) {
vector<int> found;
for (int k=0; k<verses[j].tokensLength; k++) {
found.push_back(tokens[verses[j].tokensStart + k]);
for (int k=0; k<m_verses[j].m_tokensLength; k++) {
found.push_back(m_tokens[m_verses[j].m_tokensStart + k]);
}

return found;
}
}
throw InvalidVerseReference;
throw InvalidVerseReferenceException;
}


string Book::getText() {
return text;
return m_text;
}

vector<int> Book::getTokens() {
return tokens;
return m_tokens;
}

void Book::setText(string t) {
text = t;
void Book::setText(const string& t) {
m_text = t;
// cerr << text << endl;
}

void Book::setTokens(vector<int> t) {
tokens = t;
void Book::setTokens(vector<int>& t) {
m_tokens = t;
}

int Book::getVerseStart(string i) {
for (int j=0; j<verses.size(); ++j) {
int match = verses[j].info.compare(i);
for (int j=0; j<m_verses.size(); ++j) {
int match = m_verses[j].m_info.compare(i);
if (match == 0) {
int found = verses[j].start;
int found = m_verses[j].m_start;
return found;
}
}
throw InvalidVerseReference;
throw InvalidVerseReferenceException;
}

int Book::getVerseEnd(string i) {
for (int j=0; j<verses.size(); ++j) {
int match = verses[j].info.compare(i);
for (int j=0; j<m_verses.size(); ++j) {
int match = m_verses[j].m_info.compare(i);
if (match == 0) {
int found = verses[j].start + verses[j].length - 1;
int found = m_verses[j].m_start + m_verses[j].m_length - 1;
return found;
}
}
throw InvalidVerseReference;
throw InvalidVerseReferenceException;
}

int Book::getVerseTokensStart(string i) {
for (int j=0; j<verses.size(); ++j) {
int match = verses[j].info.compare(i);
for (int j=0; j<m_verses.size(); ++j) {
int match = m_verses[j].m_info.compare(i);
if (match == 0) {
int found = verses[j].tokensStart;
int found = m_verses[j].m_tokensStart;
return found;
}
}
throw InvalidVerseReference;
throw InvalidVerseReferenceException;
}

int Book::getVerseTokensEnd(string i) {
for (int j=0; j<verses.size(); ++j) {
int match = verses[j].info.compare(i);
for (int j=0; j<m_verses.size(); ++j) {
int match = m_verses[j].m_info.compare(i);
if (match == 0) {
int found = verses[j].tokensStart + verses[j].tokensLength - 1;
int found = m_verses[j].m_tokensStart + m_verses[j].m_tokensLength - 1;
return found;
}
}
throw InvalidVerseReference;
throw InvalidVerseReferenceException;
}

string Book::getVerseInfoStart(int position) {
for (int j=0; j<verses.size(); ++j) {
if (verses[j].start <= position && verses[j].start + verses[j].length > position) {
int plus = position - verses[j].start;
string retVal = verses[j].info;
for (int j=0; j<m_verses.size(); ++j) {
if (m_verses[j].m_start <= position && m_verses[j].m_start + m_verses[j].m_length > position) {
int plus = position - m_verses[j].m_start;
string retVal = m_verses[j].m_info;
if (plus == 0) {
return retVal;
}
Expand All @@ -155,14 +150,14 @@ string Book::getVerseInfoStart(int position) {
return retVal;
}
}
throw InvalidPosition;
throw InvalidPositionException;
}

string Book::getVerseInfoEnd(int position) {
for (int j=0; j<verses.size(); ++j) {
if (verses[j].start <= position && verses[j].start + verses[j].length > position) {
int minus = verses[j].start + verses[j].length - position - 1;
string retVal = verses[j].info;
for (int j=0; j<m_verses.size(); ++j) {
if (m_verses[j].m_start <= position && m_verses[j].m_start + m_verses[j].m_length > position) {
int minus = m_verses[j].m_start + m_verses[j].m_length - position - 1;
string retVal = m_verses[j].m_info;
if (minus == 0) {
return retVal;
}
Expand All @@ -172,14 +167,14 @@ string Book::getVerseInfoEnd(int position) {
return retVal;
}
}
throw InvalidPosition;
throw InvalidPositionException;
}

string Book::getVerseTokensInfoStart(int position) {
for (int j=0; j<verses.size(); ++j) {
if (verses[j].tokensStart <= position && verses[j].tokensStart + verses[j].tokensLength > position) {
int plus = position - verses[j].tokensStart;
string retVal = verses[j].info;
for (int j=0; j<m_verses.size(); ++j) {
if (m_verses[j].m_tokensStart <= position && m_verses[j].m_tokensStart + m_verses[j].m_tokensLength > position) {
int plus = position - m_verses[j].m_tokensStart;
string retVal = m_verses[j].m_info;
if (plus == 0) {
return retVal;
}
Expand All @@ -189,14 +184,14 @@ string Book::getVerseTokensInfoStart(int position) {
return retVal;
}
}
throw InvalidPosition;
throw InvalidPositionException;
}

string Book::getVerseTokensInfoEnd(int position) {
for (int j=0; j<verses.size(); ++j) {
if (verses[j].tokensStart <= position && verses[j].tokensStart + verses[j].tokensLength > position) {
int minus = verses[j].tokensStart + verses[j].tokensLength - position - 1;
string retVal = verses[j].info;
for (int j=0; j<m_verses.size(); ++j) {
if (m_verses[j].m_tokensStart <= position && m_verses[j].m_tokensStart + m_verses[j].m_tokensLength > position) {
int minus = m_verses[j].m_tokensStart + m_verses[j].m_tokensLength - position - 1;
string retVal = m_verses[j].m_info;
if (minus == 0) {
return retVal;
}
Expand All @@ -206,5 +201,5 @@ string Book::getVerseTokensInfoEnd(int position) {
return retVal;
}
}
throw InvalidPosition;
throw InvalidPositionException;
}
Loading

0 comments on commit 155d534

Please sign in to comment.