1
/******************************************************************************
3
* gbfstrongs - SWFilter descendant to hide or show strongs number
9
#include <gbfstrongs.h>
19
const char oName[] = "Strong's Numbers";
20
const char oTip[] = "Toggles Strong's Numbers On and Off if they exist";
22
const SWBuf choices[3] = {"On", "Off", ""};
23
const StringList oValues(&choices[0], &choices[2]);
25
GBFStrongs::GBFStrongs() : SWOptionFilter(oName, oTip, &oValues) {
26
setOptionValue("Off");
30
GBFStrongs::~GBFStrongs() {
34
char GBFStrongs::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
35
char token[2048]; // cheese. Fix.
39
bool lastspace = false;
45
unsigned int textStart = 0, textEnd = 0;
53
for (text = ""; *from; from++) {
60
textEnd = text.size();
63
if (*from == '>') { // process tokens
66
if (*token == 'W' && (token[1] == 'G' || token[1] == 'H')) { // Strongs
67
if (module->isProcessEntryAttributes()) {
69
for (unsigned int i = 2; ((token[i]) && (i < 150)); i++)
72
if (atoi((!isdigit(*val))?val+1:val) < 5627) {
73
// normal strongs number
74
sprintf(wordstr, "%03d", word++);
75
module->getEntryAttributes()["Word"][wordstr]["Strongs"] = val;
77
tmp.append(text.c_str()+textStart, (int)(textEnd - textStart));
78
module->getEntryAttributes()["Word"][wordstr]["Text"] = tmp;
83
sprintf(wordstr, "%03d", word-1);
84
module->getEntryAttributes()["Word"][wordstr]["Morph"] = val;
88
if ((from[1] == ' ') || (from[1] == ',') || (from[1] == ';') || (from[1] == '.') || (from[1] == '?') || (from[1] == '!') || (from[1] == ')') || (from[1] == '\'') || (from[1] == '\"')) {
92
if (newText) {textStart = text.size(); newText = false; }
96
// if not a strongs token, keep token in text
100
if (newText) {textStart = text.size(); newText = false; }
105
token[tokpos++] = *from;
110
lastspace = (*from == ' ');