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

#include <thmlstrongs.h>

+ Inheritance diagram for ThMLStrongs:
+ Collaboration diagram for ThMLStrongs:

Public Member Functions

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)
 
 ThMLStrongs ()
 
virtual ~ThMLStrongs ()
 

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 ThML text

Definition at line 33 of file thmlstrongs.h.

Constructor & Destructor Documentation

ThMLStrongs::ThMLStrongs ( )

Definition at line 47 of file thmlstrongs.cpp.

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

Definition at line 51 of file thmlstrongs.cpp.

51  {
52 }

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 ThMLStrongs::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 55 of file thmlstrongs.cpp.

55  {
56  char token[2048]; // cheese. Fix.
57  const char *from;
58  int tokpos = 0;
59  bool intoken = false;
60  bool lastspace = false;
61  int word = 1;
62  char val[128];
63  char wordstr[11];
64  char *valto;
65  char *ch;
66  unsigned int textStart = 0, textEnd = 0;
67  SWBuf tmp;
68  bool newText = false;
69 
70  SWBuf orig = text;
71  from = orig.c_str();
72 
73  for (text = ""; *from; from++) {
74  if (*from == '<') {
75  intoken = true;
76  tokpos = 0;
77  token[0] = 0;
78  token[1] = 0;
79  token[2] = 0;
80  textEnd = (unsigned int)text.length();
81  continue;
82  }
83  if (*from == '>') { // process tokens
84  intoken = false;
85  if (!strnicmp(token, "sync type=\"Strongs\" ", 20)) { // Strongs
86  if (module->isProcessEntryAttributes()) {
87  valto = val;
88  for (unsigned int i = 27; token[i] != '\"' && i < 150; i++)
89  *valto++ = token[i];
90  *valto = 0;
91  if (atoi((!isdigit(*val))?val+1:val) < 5627) {
92  // normal strongs number
93  sprintf(wordstr, "%03d", word);
94  module->getEntryAttributes()["Word"][wordstr]["PartCount"] = "1";
95  module->getEntryAttributes()["Word"][wordstr]["Lemma"] = val;
96  module->getEntryAttributes()["Word"][wordstr]["LemmaClass"] = "strong";
97  module->getEntryAttributes()["Word"][wordstr]["Lemma.1"] = val;
98  module->getEntryAttributes()["Word"][wordstr]["LemmaClass.1"] = "strong";
99  tmp = "";
100  tmp.append(text.c_str()+textStart, (int)(textEnd - textStart));
101  module->getEntryAttributes()["Word"][wordstr]["Text"] = tmp;
102  newText = true;
103  }
104  else {
105 /*
106  // verb morph
107  sprintf(wordstr, "%03d", word);
108  module->getEntryAttributes()["Word"][wordstr]["Morph"] = val;
109  module->getEntryAttributes()["Word"][wordstr]["MorphClass"] = "OLBMorph";
110  module->getEntryAttributes()["Word"][wordstr]["Morph.1"] = val;
111  module->getEntryAttributes()["Word"][wordstr]["MorphClass.1"] = "OLBMorph";
112 */
113  word--; // for now, completely ignore this word attribute.
114  }
115  word++;
116  }
117 
118  if (!option) { // if we don't want strongs
119  if ((from[1] == ' ') || (from[1] == ',') || (from[1] == ';') || (from[1] == '.') || (from[1] == '?') || (from[1] == '!') || (from[1] == ')') || (from[1] == '\'') || (from[1] == '\"')) {
120  if (lastspace)
121  text--;
122  }
123  if (newText) {textStart = (unsigned int)text.length(); newText = false; }
124  continue;
125  }
126  }
127  if (module->isProcessEntryAttributes()) {
128  if (!strncmp(token, "sync type=\"morph\"", 17)) {
129  for (ch = token+17; *ch; ch++) {
130  if (!strncmp(ch, "class=\"", 7)) {
131  valto = val;
132  for (unsigned int i = 7; ch[i] != '\"' && i < 127; i++)
133  *valto++ = ch[i];
134  *valto = 0;
135  sprintf(wordstr, "%03d", word-1);
136  if ((!stricmp(val, "Robinsons")) || (!stricmp(val, "Robinson"))) {
137  strcpy(val, "robinson");
138  }
139  module->getEntryAttributes()["Word"][wordstr]["MorphClass"] = val;
140  module->getEntryAttributes()["Word"][wordstr]["MorphClass.1"] = val;
141  }
142  if (!strncmp(ch, "value=\"", 7)) {
143  valto = val;
144  for (unsigned int i = 7; ch[i] != '\"' && i < 127; i++)
145  *valto++ = ch[i];
146  *valto = 0;
147  sprintf(wordstr, "%03d", word-1);
148  module->getEntryAttributes()["Word"][wordstr]["Morph"] = val;
149  module->getEntryAttributes()["Word"][wordstr]["Morph.1"] = val;
150  }
151  }
152  newText = true;
153  }
154  }
155  // if not a strongs token, keep token in text
156  text += '<';
157  text += token;
158  text += '>';
159  if (newText) {textStart = (unsigned int)text.length(); newText = false; }
160  continue;
161  }
162  if (intoken) {
163  if (tokpos < 2045) {
164  token[tokpos++] = *from;
165  // TODO: why is this + 2 ?
166  token[tokpos+2] = 0;
167  }
168  }
169  else {
170  text += *from;
171  lastspace = (*from == ' ');
172  }
173  }
174  return 0;
175 }
Definition: swbuf.h:47
unsigned long length() const
Definition: swbuf.h:197
int stricmp(const char *s1, const char *s2)
Definition: utilstr.cpp:194
const char * c_str() const
Definition: swbuf.h:158
SWBuf & append(const char *str, long max=-1)
Definition: swbuf.h:274
virtual bool isProcessEntryAttributes() const
Definition: swmodule.h:832
virtual AttributeTypeList & getEntryAttributes() const
Definition: swmodule.h:817
int strnicmp(const char *s1, const char *s2, int len)
Definition: utilstr.cpp:180
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: