summaryrefslogtreecommitdiff
path: root/src/modules/filters/gbfheadings.cpp
diff options
context:
space:
mode:
authorRoberto C. Sanchez <roberto@connexer.com>2014-03-29 10:53:49 -0400
committerRoberto C. Sanchez <roberto@connexer.com>2014-03-29 10:53:49 -0400
commit8c8aa6b07e595cfac56838b5964ab3e96051f1b2 (patch)
treeda38e2c1979148dbd3b0c7b87f930746f5ba7f44 /src/modules/filters/gbfheadings.cpp
parent8d3fc864d094eeadc721f8e93436b37a5fab173e (diff)
Imported Upstream version 1.5.7
Diffstat (limited to 'src/modules/filters/gbfheadings.cpp')
-rw-r--r--src/modules/filters/gbfheadings.cpp57
1 files changed, 21 insertions, 36 deletions
diff --git a/src/modules/filters/gbfheadings.cpp b/src/modules/filters/gbfheadings.cpp
index 590e2fa..01a34ca 100644
--- a/src/modules/filters/gbfheadings.cpp
+++ b/src/modules/filters/gbfheadings.cpp
@@ -1,62 +1,47 @@
/******************************************************************************
*
- * gbfheadings - SWFilter decendant to hide or show headings
+ * gbfheadings - SWFilter descendant to hide or show headings
* in a GBF module.
*/
#include <stdlib.h>
-#include <string.h>
#include <gbfheadings.h>
#ifndef __GNUC__
#else
#include <unixstr.h>
#endif
+SWORD_NAMESPACE_START
-const char GBFHeadings::on[] = "On";
-const char GBFHeadings::off[] = "Off";
-const char GBFHeadings::optName[] = "Headings";
-const char GBFHeadings::optTip[] = "Toggles Headings On and Off if they exist";
+const char oName[] = "Headings";
+const char oTip[] = "Toggles Headings On and Off if they exist";
-GBFHeadings::GBFHeadings() {
- option = false;
- options.push_back(on);
- options.push_back(off);
+const SWBuf choices[3] = {"On", "Off", ""};
+const StringList oValues(&choices[0], &choices[2]);
+
+GBFHeadings::GBFHeadings() : SWOptionFilter(oName, oTip, &oValues) {
+ setOptionValue("Off");
}
GBFHeadings::~GBFHeadings() {
}
-void GBFHeadings::setOptionValue(const char *ival)
-{
- option = (!stricmp(ival, on));
-}
-
-const char *GBFHeadings::getOptionValue()
-{
- return (option) ? on:off;
-}
-char GBFHeadings::ProcessText(char *text, int maxlen, const SWKey *key, const SWModule *module)
-{
+char GBFHeadings::processText (SWBuf &text, const SWKey *key, const SWModule *module) {
if (!option) { // if we don't want headings
- char *to, *from, token[2048]; // cheese. Fix.
+ char token[2048]; // cheese. Fix.
int tokpos = 0;
bool intoken = false;
int len;
bool hide = false;
- len = strlen(text) + 1; // shift string to right of buffer
- if (len < maxlen) {
- memmove(&text[maxlen - len], text, len);
- from = &text[maxlen - len];
- }
- else from = text; // -------------------------------
-
- for (to = text; *from; from++) {
+ const char *from;
+ SWBuf orig = text;
+ from = orig.c_str();
+ for (text = ""; *from; from++) {
if (*from == '<') {
intoken = true;
tokpos = 0;
@@ -82,10 +67,10 @@ char GBFHeadings::ProcessText(char *text, int maxlen, const SWKey *key, const SW
}
// if not a heading token, keep token in text
if (!hide) {
- *to++ = '<';
+ text += '<';
for (char *tok = token; *tok; tok++)
- *to++ = *tok;
- *to++ = '>';
+ text += *tok;
+ text += '>';
}
continue;
}
@@ -96,12 +81,12 @@ char GBFHeadings::ProcessText(char *text, int maxlen, const SWKey *key, const SW
}
else {
if (!hide) {
- *to++ = *from;
+ text += *from;
}
}
}
- *to++ = 0;
- *to = 0;
}
return 0;
}
+
+SWORD_NAMESPACE_END