1
/******************************************************************************
3
* thmlstrongs - SWFilter descendant to hide or show strongs number
10
#include <thmlstrongs.h>
20
const char oName[] = "Strong's Numbers";
21
const char oTip[] = "Toggles Strong's Numbers On and Off if they exist";
23
const SWBuf choices[3] = {"On", "Off", ""};
24
const StringList oValues(&choices[0], &choices[2]);
26
ThMLStrongs::ThMLStrongs() : SWOptionFilter(oName, oTip, &oValues) {
27
setOptionValue("Off");
31
ThMLStrongs::~ThMLStrongs() {
35
char ThMLStrongs::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
36
char token[2048]; // cheese. Fix.
41
bool lastspace = false;
47
unsigned int textStart = 0, textEnd = 0;
54
for (text = ""; *from; from++) {
61
textEnd = text.length();
64
if (*from == '>') { // process tokens
66
if (!strnicmp(token, "sync type=\"Strongs\" ", 20)) { // Strongs
67
if (module->isProcessEntryAttributes()) {
69
for (unsigned int i = 27; 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 (!option) { // if we don't want strongs
89
if ((from[1] == ' ') || (from[1] == ',') || (from[1] == ';') || (from[1] == '.') || (from[1] == '?') || (from[1] == '!') || (from[1] == ')') || (from[1] == '\'') || (from[1] == '\"')) {
93
if (newText) {textStart = text.length(); newText = false; }
97
if (module->isProcessEntryAttributes()) {
98
if (!strncmp(token, "sync type=\"morph\"", 17)) {
99
for (ch = token+17; *ch; ch++) {
100
if (!strncmp(ch, "class=\"", 7)) {
102
for (unsigned int i = 7; ch[i] != '\"' && i < 127; i++)
105
sprintf(wordstr, "%03d", word-1);
106
module->getEntryAttributes()["Word"][wordstr]["MorphClass"] = val;
108
if (!strncmp(ch, "value=\"", 7)) {
110
for (unsigned int i = 7; ch[i] != '\"' && i < 127; i++)
113
sprintf(wordstr, "%03d", word-1);
114
module->getEntryAttributes()["Word"][wordstr]["Morph"] = val;
119
// if not a strongs token, keep token in text
123
if (newText) {textStart = text.length(); newText = false; }
128
token[tokpos++] = *from;
133
lastspace = (*from == ' ');