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

#include <gbfstrongs.h>

+ Inheritance diagram for GBFStrongs:
+ Collaboration diagram for GBFStrongs:

Public Member Functions

 GBFStrongs ()
 
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 ~GBFStrongs ()
 

Protected Attributes

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

Detailed Description

This Filter shows/hides strong's numbers in a GBF text

Definition at line 33 of file gbfstrongs.h.

Constructor & Destructor Documentation

GBFStrongs::GBFStrongs ( )

Definition at line 46 of file gbfstrongs.cpp.

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

Definition at line 50 of file gbfstrongs.cpp.

50  {
51 }

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 GBFStrongs::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

Implements SWFilter.

Definition at line 54 of file gbfstrongs.cpp.

54  {
55  char token[2048]; // cheese. Fix.
56  int tokpos = 0;
57  bool intoken = false;
58  bool lastspace = false;
59  int word = 1;
60  char val[128];
61  char wordstr[11];
62  char *valto;
63  unsigned int textStart = 0, textEnd = 0;
64  bool newText = false;
65  SWBuf tmp;
66  const char *from;
67 
68  SWBuf orig = text;
69  from = orig.c_str();
70 
71  for (text = ""; *from; from++) {
72  if (*from == '<') {
73  intoken = true;
74  tokpos = 0;
75  token[0] = 0;
76  token[1] = 0;
77  token[2] = 0;
78  textEnd = (unsigned int)text.size();
79  continue;
80  }
81  if (*from == '>') { // process tokens
82  intoken = false;
83  if (*token == 'W' && (token[1] == 'G' || token[1] == 'H')) { // Strongs
84  if (module->isProcessEntryAttributes()) {
85  valto = val;
86  for (unsigned int i = 1; ((token[i]) && (i < 150)); i++)
87  *valto++ = token[i];
88  *valto = 0;
89  if (atoi((!isdigit(*val))?val+1:val) < 5627) {
90  // normal strongs number
91  sprintf(wordstr, "%03d", word++);
92  module->getEntryAttributes()["Word"][wordstr]["PartsCount"] = "1";
93  module->getEntryAttributes()["Word"][wordstr]["Lemma"] = val;
94  module->getEntryAttributes()["Word"][wordstr]["LemmaClass"] = "strong";
95  tmp = "";
96  tmp.append(text.c_str()+textStart, (int)(textEnd - textStart));
97  module->getEntryAttributes()["Word"][wordstr]["Text"] = tmp;
98  newText = true;
99  }
100  else {
101  // verb morph
102  sprintf(wordstr, "%03d", word-1);
103  module->getEntryAttributes()["Word"][wordstr]["Morph"] = val;
104  module->getEntryAttributes()["Word"][wordstr]["MorphClass"] = "OLBMorph";
105  }
106  }
107 
108  if (!option) {
109  if ((from[1] == ' ') || (from[1] == ',') || (from[1] == ';') || (from[1] == '.') || (from[1] == '?') || (from[1] == '!') || (from[1] == ')') || (from[1] == '\'') || (from[1] == '\"')) {
110  if (lastspace)
111  text--;
112  }
113  if (newText) {textStart = (unsigned int)text.size(); newText = false; }
114  continue;
115  }
116  }
117  if (module->isProcessEntryAttributes()) {
118  if ((*token == 'W') && (token[1] == 'T')) { // Morph
119  valto = val;
120  for (unsigned int i = 2; ((token[i]) && (i < 150)); i++)
121  *valto++ = token[i];
122  *valto = 0;
123  sprintf(wordstr, "%03d", word-1);
124  module->getEntryAttributes()["Word"][wordstr]["MorphClass"] = "GBFMorph";
125  module->getEntryAttributes()["Word"][wordstr]["Morph"] = val;
126  newText = true;
127  }
128  }
129  // if not a strongs token, keep token in text
130  text += '<';
131  text += token;
132  text += '>';
133  if (newText) {textStart = (unsigned int)text.size(); newText = false; }
134  continue;
135  }
136  if (intoken) {
137  if (tokpos < 2045) {
138  token[tokpos++] = *from;
139  // TODO: why is this + 2 ?
140  token[tokpos+2] = 0;
141  }
142  }
143  else {
144  text += *from;
145  lastspace = (*from == ' ');
146  }
147  }
148  return 0;
149 }
Definition: swbuf.h:47
const char * c_str() const
Definition: swbuf.h:158
SWBuf & append(const char *str, long max=-1)
Definition: swbuf.h:274
unsigned long size() const
Definition: swbuf.h:185
virtual bool isProcessEntryAttributes() const
Definition: swmodule.h:832
virtual AttributeTypeList & getEntryAttributes() const
Definition: swmodule.h:817
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: