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

#include <gbffootnotes.h>

+ Inheritance diagram for GBFFootnotes:
+ Collaboration diagram for GBFFootnotes:

Public Member Functions

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

Protected Attributes

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

Detailed Description

This Filter shows/hides footnotes in a GBF text

Definition at line 33 of file gbffootnotes.h.

Constructor & Destructor Documentation

GBFFootnotes::GBFFootnotes ( )

Definition at line 49 of file gbffootnotes.cpp.

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

Definition at line 53 of file gbffootnotes.cpp.

53  {
54 }

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 GBFFootnotes::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 57 of file gbffootnotes.cpp.

58 {
59 
60  SWBuf token;
61  bool intoken = false;
62  bool hide = false;
63  SWBuf tagText;
64  XMLTag startTag;
65  SWBuf refs = "";
66  int footnoteNum = 1;
67  char buf[254];
68 
69  SWBuf orig = text;
70  const char *from = orig.c_str();
71 
72  //XMLTag tag;
73 
74  for (text = ""; *from; from++) {
75  if (*from == '<') {
76  intoken = true;
77  token = "";
78  continue;
79  }
80  if (*from == '>') { // process tokens
81  intoken = false;
82 
83  //XMLTag tag(token);
84  if (!strncmp(token, "RF",2)) {
85 // tag = token;
86 
87  refs = "";
88  startTag = token;
89  hide = true;
90  tagText = "";
91  continue;
92  }
93  else if (!strncmp(token, "Rf",2)) {
94  if (module->isProcessEntryAttributes()) {
95  //tag = token;
96 
97  if((tagText.length() == 1) || !strcmp(module->getName(), "IGNT")) {
98  if (option) { // for ASV marks text in verse then put explanation at end of verse
99  text.append(" <FS>[");
100  text.append(tagText);
101  text.append("]<Fs>");
102  hide = false;
103  continue;
104  }
105  }
106  SWBuf fc = module->getEntryAttributes()["Footnote"]["count"]["value"];
107  footnoteNum = (fc.length()) ? atoi(fc.c_str()) : 0;
108  sprintf(buf, "%i", ++footnoteNum);
109  module->getEntryAttributes()["Footnote"]["count"]["value"] = buf;
110  StringList attributes = startTag.getAttributeNames();
111  for (StringList::const_iterator it = attributes.begin(); it != attributes.end(); it++) {
112  module->getEntryAttributes()["Footnote"][buf][it->c_str()] = startTag.getAttribute(it->c_str());
113  }
114  module->getEntryAttributes()["Footnote"][buf]["body"] = tagText;
115  startTag.setAttribute("swordFootnote", buf);
116  }
117  hide = false;
118  if (option) {
119  text.append(startTag);
120  text.append(tagText);
121  }
122  else continue;
123  }
124  if (!hide) {
125  text.append('<');
126  text.append(token);
127  text.append('>');
128  }
129  else {
130  tagText.append('<');
131  tagText.append(token);
132  tagText.append('>');
133  }
134  continue;
135  }
136  if (intoken) { //copy token
137  token.append(*from);
138  }
139  else if (!hide) { //copy text which is not inside a token
140  text.append(*from);
141  }
142  else tagText.append(*from);
143  }
144  return 0;
145 
146  /*
147  if (!option) { // if we don't want footnotes
148  char token[4096]; // cheese. Fix.
149  int tokpos = 0;
150  bool intoken = false;
151  int len;
152  bool hide = false;
153 
154  const char *from;
155  SWBuf orig = text;
156  from = orig.c_str();
157  for (text = ""; *from; from++) {
158  if (*from == '<') {
159  intoken = true;
160  tokpos = 0;
161 // memset(token, 0, 4096);
162  token[0] = 0;
163  token[1] = 0;
164  token[2] = 0;
165  continue;
166  }
167  if (*from == '>') { // process tokens
168  intoken = false;
169  switch (*token) {
170  case 'R': // Reference
171  switch(token[1]) {
172  case 'F': // Begin footnote
173  hide = true;
174  break;
175  case 'f': // end footnote
176  hide = false;
177  break;
178  }
179  continue; // skip token
180  case 'W':
181  if (token[1] == 'T') {
182  switch (token[2]) {
183  case 'P':
184  case 'S':
185  case 'A':
186  continue; // remove this token
187  default:
188  break;
189  }
190  }
191  }
192  // if not a footnote token, keep token in text
193  if (!hide) {
194  text += '<';
195  text += token;
196  text += '>';
197  }
198  continue;
199  }
200  if (intoken) {
201  if (tokpos < 4090)
202  token[tokpos++] = *from;
203  token[tokpos+2] = 0; // +2 cuz we init token with 2 extra '0' because of switch statement
204  }
205  else {
206  if (!hide) {
207  text += *from;
208  }
209  }
210  }
211  }
212  return 0;*/
213 }
const char * getName() const
Definition: swmodule.cpp:204
Definition: swbuf.h:47
unsigned long length() const
Definition: swbuf.h:197
const char * setAttribute(const char *attribName, const char *attribValue, int partNum=-1, char partSplit= '|')
Definition: utilxml.cpp:248
Definition: utilxml.h:38
const StringList getAttributeNames() const
Definition: utilxml.cpp:188
const char * c_str() const
Definition: swbuf.h:158
std::list< SWBuf > StringList
Definition: swmodule.cpp:91
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
const char * getAttribute(const char *attribName, int partNum=-1, char partSplit= '|') const
Definition: utilxml.cpp:230
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: