The SWORD Project  1.9.0.svnversion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GBFRedLetterWords Class Reference

#include <gbfredletterwords.h>

+ Inheritance diagram for GBFRedLetterWords:
+ Collaboration diagram for GBFRedLetterWords:

Public Member Functions

 GBFRedLetterWords ()
 
virtual const char * getHeader () const
 
virtual const char * getOptionName ()
 
virtual const char * getOptionTip ()
 
virtual const char * getOptionValue ()
 
virtual StringList getOptionValues ()
 
bool isBoolean ()
 
virtual char processText (SWBuf &text, const SWKey *key=0, const SWModule *module=0)
 
virtual void setOptionValue (const char *ival)
 
virtual ~GBFRedLetterWords ()
 

Protected Attributes

bool isBooleanVal
 
bool option
 
SWBuf optionValue
 
const char * optName
 
const char * optTip
 
const StringListoptValues
 

Detailed Description

This Filter shows/hides "red letter tags" (marking the words of Jesus) in a GBF text. Turn this off if you don't want to have this kind of markup in the text.

Definition at line 36 of file gbfredletterwords.h.

Constructor & Destructor Documentation

GBFRedLetterWords::GBFRedLetterWords ( )

Definition at line 45 of file gbfredletterwords.cpp.

46 }
static const StringList * oValues()
static const char oName[]
static const char oTip[]
GBFRedLetterWords::~GBFRedLetterWords ( )
virtual

Definition at line 49 of file gbfredletterwords.cpp.

49  {
50 }

Member Function Documentation

virtual const char* SWFilter::getHeader ( ) const
inlinevirtualinherited

This method can supply a header associated with the processing done with this filter. A typical example is a suggested CSS style block for classed containers.

Reimplemented in OSISLaTeX, OSISXHTML, ThMLLaTeX, ThMLXHTML, TEIXHTML, GBFLaTeX, and GBFXHTML.

Definition at line 62 of file swfilter.h.

62 { return ""; }
virtual const char* SWOptionFilter::getOptionName ( )
inlinevirtualinherited

gets the name of the option of this filter

Returns
option name

Reimplemented in UTF8Transliterator.

Definition at line 72 of file swoptfilter.h.

72 { return optName; }
const char * optName
Definition: swoptfilter.h:51
virtual const char* SWOptionFilter::getOptionTip ( )
inlinevirtualinherited

gets a short explanation of the option of this filter; it could be presented to the user in frontend programs

Returns
option tip/explanation

Reimplemented in UTF8Transliterator.

Definition at line 78 of file swoptfilter.h.

78 { return optTip; }
const char * optTip
Definition: swoptfilter.h:52
const char * SWOptionFilter::getOptionValue ( )
virtualinherited
Returns
The value of the current option.

Reimplemented in UTF8Transliterator.

Definition at line 62 of file swoptfilter.cpp.

62  {
63  return optionValue;
64 }
SWBuf optionValue
Definition: swoptfilter.h:50
virtual StringList SWOptionFilter::getOptionValues ( )
inlinevirtualinherited

returns a list of the possible option values

Returns
list of option values

Reimplemented in UTF8Transliterator.

Definition at line 84 of file swoptfilter.h.

84 { return *optValues; }
const StringList * optValues
Definition: swoptfilter.h:53
bool SWOptionFilter::isBoolean ( )
inlineinherited

many options are simple Off/On boolean type, and frontends may wish to show these with checkmarks or the like to the end user. This is a convenience method to allow a frontend to check if this filter has only Off/On values

Definition at line 67 of file swoptfilter.h.

67 { return isBooleanVal; }
char GBFRedLetterWords::processText ( SWBuf text,
const SWKey key = 0,
const SWModule module = 0 
)
virtual

This method processes and appropriately modifies the text given it for a particular filter task

Parameters
textThe text to be filtered/converted
keyCurrent key That was used.
moduleCurrent module.
Returns
0

This function removes the red letter words in Bible like the WEB The words are marked by <FR> as start and <Fr> as end tag.

Implements SWFilter.

Definition at line 53 of file gbfredletterwords.cpp.

53  {
57  if (!option) { // if we don't want footnotes
58  char token[4096]; // cheese. Fix.
59  int tokpos = 0;
60  bool intoken = false;
61  bool hide = false;
62 
63  const char *from;
64  SWBuf orig = text;
65  from = orig.c_str();
66  for (text = ""; *from; from++) {
67  if (*from == '<') {
68  intoken = true;
69  tokpos = 0;
70 // memset(token, 0, 4096);
71  token[0] = 0;
72  token[1] = 0;
73  token[2] = 0;
74  continue;
75  }
76  if (*from == '>') { // process tokens
77  intoken = false;
78  /*switch (*token) {
79  case 'F': // Font attribute
80  switch(token[1]) {
81  case 'R': // Begin red letter words
82  hide = true;
83  break;
84  case 'r': // end red letter words
85  hide = false;
86  break;
87  }
88  continue; // skip token
89  }*/
90 
91  //hide the token if either FR or Fr was detected
92  hide = (token[0] == 'F' && ( (token[1] == 'R') || (token[1] == 'r') ));
93 
94  // if not a red letter word token, keep token in text
95  if (!hide) {
96  text += '<';
97  for (char *tok = token; *tok; tok++)
98  text += *tok;
99  text += '>';
100  }
101  continue;
102  }
103  if (intoken) {
104  if (tokpos < 4090) {
105  token[tokpos++] = *from;
106  // TODO: why is this + 2 ? The below comment still doesn't help me understand. The switch statment
107  // is commented out in this filter
108  token[tokpos+2] = 0; // +2 cuz we init token with 2 extra '0' because of switch statement
109  }
110  }
111  else {
112  text += *from;
113  }
114  }
115  }
116  return 0;
117 }
Definition: swbuf.h:47
const char * c_str() const
Definition: swbuf.h:158
void SWOptionFilter::setOptionValue ( const char *  ival)
virtualinherited

sets the value of the option of this filter, e.g maybe a strong's filter might be set to "On" / "Off" - that would mean to show or not to show the strongs in the text, see also getOptionValues()

Parameters
ivalthe new option value

Reimplemented in UTF8Transliterator.

Definition at line 52 of file swoptfilter.cpp.

52  {
53  for (StringList::const_iterator loop = optValues->begin(); loop != optValues->end(); loop++) {
54  if (!stricmp(loop->c_str(), ival)) {
55  optionValue = *loop;
56  option = (!strnicmp(ival, "On", 2)); // convenience for boolean filters
57  break;
58  }
59  }
60 }
int stricmp(const char *s1, const char *s2)
Definition: utilstr.cpp:194
SWBuf optionValue
Definition: swoptfilter.h:50
int strnicmp(const char *s1, const char *s2, int len)
Definition: utilstr.cpp:180
const StringList * optValues
Definition: swoptfilter.h:53

Member Data Documentation

bool SWOptionFilter::isBooleanVal
protectedinherited

Definition at line 55 of file swoptfilter.h.

bool SWOptionFilter::option
protectedinherited

Definition at line 54 of file swoptfilter.h.

SWBuf SWOptionFilter::optionValue
protectedinherited

Definition at line 50 of file swoptfilter.h.

const char* SWOptionFilter::optName
protectedinherited

Definition at line 51 of file swoptfilter.h.

const char* SWOptionFilter::optTip
protectedinherited

Definition at line 52 of file swoptfilter.h.

const StringList* SWOptionFilter::optValues
protectedinherited

Definition at line 53 of file swoptfilter.h.


The documentation for this class was generated from the following files: