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

#include <osisplain.h>

+ Inheritance diagram for OSISPlain:
+ Collaboration diagram for OSISPlain:

Public Member Functions

virtual const char * getHeader () const
 
 OSISPlain ()
 
virtual char processText (SWBuf &text, const SWKey *key=0, const SWModule *module=0)
 

Protected Member Functions

void addAllowedEscapeString (const char *findString)
 
void addEscapeStringSubstitute (const char *findString, const char *replaceString)
 
void addTokenSubstitute (const char *findString, const char *replaceString)
 
void appendEscapeString (SWBuf &buf, const char *escString)
 
virtual BasicFilterUserDatacreateUserData (const SWModule *module, const SWKey *key)
 
virtual bool handleEscapeString (SWBuf &buf, const char *escString, BasicFilterUserData *userData)
 
virtual bool handleNumericEscapeString (SWBuf &buf, const char *escString)
 
virtual bool handleToken (SWBuf &buf, const char *token, BasicFilterUserData *userData)
 
bool passAllowedEscapeString (SWBuf &buf, const char *escString)
 
virtual bool processStage (char stage, SWBuf &text, char *&from, BasicFilterUserData *userData)
 
void removeAllowedEscapeString (const char *findString)
 
void removeEscapeStringSubstitute (const char *findString)
 
void removeTokenSubstitute (const char *findString)
 
void setEscapeEnd (const char *escEnd)
 
void setEscapeStart (const char *escStart)
 
void setEscapeStringCaseSensitive (bool val)
 
void setPassThruNumericEscapeString (bool val)
 
void setPassThruUnknownEscapeString (bool val)
 
void setPassThruUnknownToken (bool val)
 
virtual void setStageProcessing (char stages)
 
void setTokenCaseSensitive (bool val)
 
void setTokenEnd (const char *tokenEnd)
 
void setTokenStart (const char *tokenStart)
 
bool substituteEscapeString (SWBuf &buf, const char *escString)
 
bool substituteToken (SWBuf &buf, const char *token)
 

Static Protected Attributes

static const char FINALIZE = 8
 
static const char INITIALIZE = 1
 
static const char POSTCHAR = 4
 
static const char PRECHAR = 2
 

Detailed Description

this filter converts OSIS text to plain text; primary stripFilter for OSIS

Definition at line 34 of file osisplain.h.

Constructor & Destructor Documentation

OSISPlain::OSISPlain ( )

Definition at line 47 of file osisplain.cpp.

47  {
48  setTokenStart("<");
49  setTokenEnd(">");
50 
51  setEscapeStart("&");
52  setEscapeEnd(";");
53 
55 
56  addEscapeStringSubstitute("amp", "&");
57  addEscapeStringSubstitute("apos", "'");
58  addEscapeStringSubstitute("lt", "<");
59  addEscapeStringSubstitute("gt", ">");
60  addEscapeStringSubstitute("quot", "\"");
61 
63  addTokenSubstitute("title", "\n");
64  addTokenSubstitute("/title", "\n");
65  addTokenSubstitute("/l", "\n");
66  addTokenSubstitute("lg", "\n");
67  addTokenSubstitute("/lg", "\n");
68 
70 }
static const char PRECHAR
Definition: swbasicfilter.h:97
void setTokenEnd(const char *tokenEnd)
void setTokenCaseSensitive(bool val)
void setEscapeStart(const char *escStart)
void addEscapeStringSubstitute(const char *findString, const char *replaceString)
void setTokenStart(const char *tokenStart)
virtual void setStageProcessing(char stages)
void setEscapeStringCaseSensitive(bool val)
void addTokenSubstitute(const char *findString, const char *replaceString)
void setEscapeEnd(const char *escEnd)

Member Function Documentation

void SWBasicFilter::addAllowedEscapeString ( const char *  findString)
protectedinherited

Registers an esc control sequence that can pass unchanged

Definition at line 156 of file swbasicfilter.cpp.

156  {
157  char *buf = 0;
158 
159  if (!escStringCaseSensitive) {
160  stdstr(&buf, findString);
161  toupperstr(buf);
162  p->escPassSet.insert(StringSet::value_type(buf));
163  delete [] buf;
164  }
165  else p->escPassSet.insert(StringSet::value_type(findString));
166 }
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
bool escStringCaseSensitive
Definition: swbasicfilter.h:74
char * toupperstr(char *t, unsigned int max=0)
Definition: stringmgr.h:107
Private * p
Definition: swbasicfilter.h:82
void SWBasicFilter::addEscapeStringSubstitute ( const char *  findString,
const char *  replaceString 
)
protectedinherited

Registers an esc control sequence

Definition at line 176 of file swbasicfilter.cpp.

176  {
177  char *buf = 0;
178 
179  if (!escStringCaseSensitive) {
180  stdstr(&buf, findString);
181  toupperstr(buf);
182  p->escSubMap.insert(DualStringMap::value_type(buf, replaceString));
183  delete [] buf;
184  }
185  else p->escSubMap.insert(DualStringMap::value_type(findString, replaceString));
186 }
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
bool escStringCaseSensitive
Definition: swbasicfilter.h:74
char * toupperstr(char *t, unsigned int max=0)
Definition: stringmgr.h:107
Private * p
Definition: swbasicfilter.h:82
void SWBasicFilter::addTokenSubstitute ( const char *  findString,
const char *  replaceString 
)
protectedinherited

Registers a simple token substitutions. Usually called from the c-tor of a subclass

Definition at line 136 of file swbasicfilter.cpp.

136  {
137  char *buf = 0;
138 
139  if (!tokenCaseSensitive) {
140  stdstr(&buf, findString);
141  toupperstr(buf);
142  p->tokenSubMap[buf] = replaceString;
143  delete [] buf;
144  }
145  else p->tokenSubMap[findString] = replaceString;
146 }
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
bool tokenCaseSensitive
Definition: swbasicfilter.h:75
DualStringMap tokenSubMap
char * toupperstr(char *t, unsigned int max=0)
Definition: stringmgr.h:107
Private * p
Definition: swbasicfilter.h:82
void SWBasicFilter::appendEscapeString ( SWBuf buf,
const char *  escString 
)
protectedinherited

This appends escString to buf as an entity

Definition at line 216 of file swbasicfilter.cpp.

216  {
217  buf += escStart;
218  buf += escString;
219  buf += escEnd;
220 }
BasicFilterUserData * OSISPlain::createUserData ( const SWModule module,
const SWKey key 
)
protectedvirtual

Reimplemented from SWBasicFilter.

Definition at line 73 of file osisplain.cpp.

73  {
74  MyUserData *u = new MyUserData(module, key);
75  u->testament = (u->vkey) ? u->vkey->getTestament() : 2; // default to NT
76  return u;
77 }
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 ""; }
bool SWBasicFilter::handleEscapeString ( SWBuf buf,
const char *  escString,
BasicFilterUserData userData 
)
protectedvirtualinherited

This function is called for every escape sequence encountered in the input text.

Parameters
bufthe output buffer
escStringthe escape sequence (e.g. "amp" for &amp;)
userDatauser storage space for data transient to 1 full buffer parse
Returns
false if was not handled and should be handled in
subclasses should return true if they handled the esc seq, or false if they did not.

Definition at line 286 of file swbasicfilter.cpp.

286  {
287  return substituteEscapeString(buf, escString);
288 }
bool substituteEscapeString(SWBuf &buf, const char *escString)
bool SWBasicFilter::handleNumericEscapeString ( SWBuf buf,
const char *  escString 
)
protectedvirtualinherited

This function is called for all numeric escape sequences. If passThrough

Parameters
bufthe output buffer
escStringthe escape sequence (e.g. "#235" for &235;)
Returns
subclasses should return true if they handled the esc seq, or false if they did not.

Definition at line 244 of file swbasicfilter.cpp.

244  {
245  if (passThruNumericEsc) {
246  appendEscapeString(buf, escString);
247  return true;
248  }
249  return false;
250 }
bool passThruNumericEsc
Definition: swbasicfilter.h:78
void appendEscapeString(SWBuf &buf, const char *escString)
bool OSISPlain::handleToken ( SWBuf buf,
const char *  token,
BasicFilterUserData userData 
)
protectedvirtual

This function is called for every token encountered in the input text.

Parameters
bufthe output buffer
tokenthe token (e.g. "p align='left'"
userDatauser storage space for data transient to 1 full buffer parse
Returns
subclasses should return true if they handled the token, or false if they did not.

Reimplemented from SWBasicFilter.

Definition at line 91 of file osisplain.cpp.

91  {
92  // manually process if it wasn't a simple substitution
93  if (!substituteToken(buf, token)) {
94  MyUserData *u = (MyUserData *)userData;
95  if (((*token == 'w') && (token[1] == ' ')) ||
96  ((*token == '/') && (token[1] == 'w') && (!token[2]))) {
97  u->tag = token;
98 
99  bool start = false;
100  if (*token == 'w') {
101  if (token[strlen(token)-1] != '/') {
102  u->w = token;
103  return true;
104  }
105  start = true;
106  }
107  u->tag = (start) ? token : u->w.c_str();
108  bool show = true; // to handle unplaced article in kjv2003-- temporary till combined
109 
110  SWBuf lastText = (start) ? "stuff" : u->lastTextNode.c_str();
111 
112  const char *attrib;
113  const char *val;
114  if ((attrib = u->tag.getAttribute("xlit"))) {
115  val = strchr(attrib, ':');
116  val = (val) ? (val + 1) : attrib;
117  buf.append(" <");
118  buf.append(val);
119  buf.append('>');
120  }
121  if ((attrib = u->tag.getAttribute("gloss"))) {
122  buf.append(" <");
123  buf.append(attrib);
124  buf.append('>');
125  }
126  if ((attrib = u->tag.getAttribute("lemma"))) {
127  int count = u->tag.getAttributePartCount("lemma", ' ');
128  int i = (count > 1) ? 0 : -1; // -1 for whole value cuz it's faster, but does the same thing as 0
129  do {
130  char gh;
131  attrib = u->tag.getAttribute("lemma", i, ' ');
132  if (i < 0) i = 0; // to handle our -1 condition
133  val = strchr(attrib, ':');
134  val = (val) ? (val + 1) : attrib;
135  if ((strchr("GH", *val)) && (isdigit(val[1]))) {
136  gh = *val;
137  val++;
138  }
139  else {
140  gh = (u->testament>1) ? 'G' : 'H';
141  }
142  if ((!strcmp(val, "3588")) && (lastText.length() < 1))
143  show = false;
144  else {
145  buf.append(" <");
146  buf.append(gh);
147  buf.append(val);
148  buf.append(">");
149  }
150  } while (++i < count);
151  }
152  if ((attrib = u->tag.getAttribute("morph")) && (show)) {
153  int count = u->tag.getAttributePartCount("morph", ' ');
154  int i = (count > 1) ? 0 : -1; // -1 for whole value cuz it's faster, but does the same thing as 0
155  do {
156  attrib = u->tag.getAttribute("morph", i, ' ');
157  if (i < 0) i = 0; // to handle our -1 condition
158  val = strchr(attrib, ':');
159  val = (val) ? (val + 1) : attrib;
160  if ((*val == 'T') && (strchr("GH", val[1])) && (isdigit(val[2])))
161  val+=2;
162  buf.append(" (");
163  buf.append(val);
164  buf.append(')');
165  } while (++i < count);
166  }
167  if ((attrib = u->tag.getAttribute("POS"))) {
168  val = strchr(attrib, ':');
169  val = (val) ? (val + 1) : attrib;
170 
171  buf.append(" <");
172  buf.append(val);
173  buf.append('>');
174  }
175  }
176 
177  // <note> tag
178  else if (!strncmp(token, "note", 4)) {
179  if (!strstr(token, "strongsMarkup")) { // leave strong's markup notes out, in the future we'll probably have different option filters to turn different note types on or off
180  buf.append(" [");
181  }
182  else u->suspendTextPassThru = true;
183  if (u->module) {
184  XMLTag tag = token;
185  SWBuf swordFootnote = tag.getAttribute("swordFootnote");
186  SWBuf footnoteBody = u->module->getEntryAttributes()["Footnote"][swordFootnote]["body"];
187  buf.append(u->module->renderText(footnoteBody));
188  }
189  }
190  else if (!strncmp(token, "/note", 5)) {
191  if (!u->suspendTextPassThru)
192  buf.append("] ");
193  else u->suspendTextPassThru = false;
194  }
195 
196  // <p> paragraph tag
197  else if (((*token == 'p') && ((token[1] == ' ') || (!token[1]))) ||
198  ((*token == '/') && (token[1] == 'p') && (!token[2]))) {
199  userData->supressAdjacentWhitespace = true;
200  buf.append('\n');
201  }
202 
203  // Milestoned paragraph, created by osis2mod
204  // <div type="paragraph" sID... />
205  // <div type="paragraph" eID... />
206  else if (!strcmp(u->tag.getName(), "div") && u->tag.getAttribute("type") && (!strcmp(u->tag.getAttribute("type"), "x-p") || !strcmp(u->tag.getAttribute("type"), "paragraph")) &&
207  (u->tag.isEmpty() && (u->tag.getAttribute("sID") || u->tag.getAttribute("eID")))) {
208  userData->supressAdjacentWhitespace = true;
209  buf.append('\n');
210  }
211 
212  // <lb .../>
213  else if (!strncmp(token, "lb", 2)) {
214  userData->supressAdjacentWhitespace = true;
215  buf.append('\n');
216  }
217  else if (!strncmp(token, "l", 1) && strstr(token, "eID")) {
218  userData->supressAdjacentWhitespace = true;
219  buf.append('\n');
220  }
221  else if (!strncmp(token, "/divineName", 11)) {
222  // Get the end portion of the string, and upper case it
223  char* end = buf.getRawData();
224  end += buf.size() - u->lastTextNode.size();
225  toupperstr(end);
226  }
227  else if (!strncmp(token, "hi", 2)) {
228 
229  // handle both OSIS 'type' and TEI 'rend' attributes
230  // there is no officially supported OSIS overline attribute,
231  // thus either TEI overline or OSIS x-overline would be best,
232  // but we have used "ol" in the past, as well. Once a valid
233  // OSIS overline attribute is made available, these should all
234  // eventually be deprecated and never documented that they are supported.
235  if (strstr(token, "rend=\"ol\"") || strstr(token, "rend=\"x-overline\"") || strstr(token, "rend=\"overline\"")
236  || strstr(token, "type=\"ol\"") || strstr(token, "type=\"x-overline\"") || strstr(token, "type=\"overline\"")) {
237  u->hiType = "overline";
238  }
239  else u->hiType = "";
240  u->suspendTextPassThru = true;
241  }
242  else if (!strncmp(token, "/hi", 3)) {
243  if (u->hiType == "overline") {
244  const unsigned char *b = (const unsigned char *)u->lastTextNode.c_str();
245  while (*b) {
246  const unsigned char *o = b;
247  if (getUniCharFromUTF8(&b)) {
248  while (o != b) buf.append(*(o++));
249  buf.append((unsigned char)0xCC);
250  buf.append((unsigned char)0x85);
251  }
252  }
253  }
254  else {
255  buf.append("* ");
256  buf.append(u->lastSuspendSegment);
257  buf.append(" *");
258  }
259  u->suspendTextPassThru = false;
260  }
261 
262  else if ((!strncmp(token, "q", 1) && (u->tag.getAttribute("marker")))) {
263  buf.append(u->tag.getAttribute("marker"));
264  }
265 
266 
267  // <milestone type="line"/>
268  else if (!strncmp(token, "milestone", 9)) {
269  const char* type = strstr(token+10, "type=\"");
270  if (type && strncmp(type+6, "line", 4)) { //we check for type != line
271  userData->supressAdjacentWhitespace = true;
272  buf.append('\n');
273  }
274  if (u->tag.getAttribute("marker")) {
275  buf.append(u->tag.getAttribute("marker"));
276  }
277  }
278 
279  else {
280  return false; // we still didn't handle token
281  }
282  }
283  return true;
284 }
Definition: swbuf.h:47
unsigned long length() const
Definition: swbuf.h:197
Definition: utilxml.h:38
bool substituteToken(SWBuf &buf, const char *token)
char * getRawData()
Definition: swbuf.h:379
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
const char * getAttribute(const char *attribName, int partNum=-1, char partSplit= '|') const
Definition: utilxml.cpp:230
char * toupperstr(char *t, unsigned int max=0)
Definition: stringmgr.h:107
SW_u32 getUniCharFromUTF8(const unsigned char **buf, bool skipValidation=false)
Definition: utilstr.h:88
bool SWBasicFilter::passAllowedEscapeString ( SWBuf buf,
const char *  escString 
)
protectedinherited

This passes allowed escapeStrings

Definition at line 223 of file swbasicfilter.cpp.

223  {
224  StringSet::iterator it;
225 
226  if (!escStringCaseSensitive) {
227  char *tmp = 0;
228  stdstr(&tmp, escString);
229  toupperstr(tmp);
230  it = p->escPassSet.find(tmp);
231  delete [] tmp;
232  } else
233  it = p->escPassSet.find(escString);
234 
235  if (it != p->escPassSet.end()) {
236  appendEscapeString(buf, escString);
237  return true;
238  }
239 
240  return false;
241 }
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
bool escStringCaseSensitive
Definition: swbasicfilter.h:74
char * toupperstr(char *t, unsigned int max=0)
Definition: stringmgr.h:107
Private * p
Definition: swbasicfilter.h:82
void appendEscapeString(SWBuf &buf, const char *escString)
bool OSISPlain::processStage ( char  stage,
SWBuf text,
char *&  from,
BasicFilterUserData userData 
)
protectedvirtual

Reimplemented from SWBasicFilter.

Definition at line 80 of file osisplain.cpp.

80  {
81  // this is a strip filter so we want to do this as optimized as possible. Avoid calling
82  // getUniCharFromUTF8 for slight speed improvement
83 
84  if (stage == PRECHAR) {
85  if ((unsigned)from[0] == 0xC2 && (unsigned)from[1] == 0xAD) return true; // skip soft hyphens
86  }
87  return false;
88 }
static const char PRECHAR
Definition: swbasicfilter.h:97
char SWBasicFilter::processText ( SWBuf text,
const SWKey key = 0,
const SWModule module = 0 
)
virtualinherited

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.

Reimplemented in ThMLRTF, OSISOSIS, and OSISRTF.

Definition at line 315 of file swbasicfilter.cpp.

315  {
316  char *from;
317  char token[4096];
318  int tokpos = 0;
319  bool intoken = false;
320  bool inEsc = false;
321  int escStartPos = 0, escEndPos = 0;
322  int tokenStartPos = 0, tokenEndPos = 0;
323  SWBuf lastTextNode;
324  BasicFilterUserData *userData = createUserData(module, key);
325 
326  SWBuf orig = text;
327  from = orig.getRawData();
328  text = "";
329 
330  if (processStages & INITIALIZE) {
331  if (processStage(INITIALIZE, text, from, userData)) { // processStage handled it all
332  delete userData;
333  return 0;
334  }
335  }
336 
337  for (;*from; from++) {
338 
339  if (processStages & PRECHAR) {
340  if (processStage(PRECHAR, text, from, userData)) // processStage handled this char
341  continue;
342  }
343 
344  if (*from == tokenStart[tokenStartPos]) {
345  if (tokenStartPos == (tokenStartLen - 1)) {
346  intoken = true;
347  tokpos = 0;
348  token[0] = 0;
349  token[1] = 0;
350  token[2] = 0;
351  inEsc = false;
352  }
353  else tokenStartPos++;
354  continue;
355  }
356 
357  if (*from == escStart[escStartPos]) {
358  if (escStartPos == (escStartLen - 1)) {
359  intoken = true;
360  tokpos = 0;
361  token[0] = 0;
362  token[1] = 0;
363  token[2] = 0;
364  inEsc = true;
365  }
366  else escStartPos++;
367  continue;
368  }
369 
370  if (inEsc) {
371  if (*from == escEnd[escEndPos]) {
372  if (escEndPos == (escEndLen - 1)) {
373  intoken = inEsc = false;
374  userData->lastTextNode = lastTextNode;
375 
376  if (!userData->suspendTextPassThru) { //if text through is disabled no tokens should pass, too
377  if ((!handleEscapeString(text, token, userData)) && (passThruUnknownEsc)) {
378  appendEscapeString(text, token);
379  }
380  }
381  escEndPos = escStartPos = tokenEndPos = tokenStartPos = 0;
382  lastTextNode = "";
383  continue;
384  }
385  }
386  }
387 
388  if (!inEsc) {
389  if (*from == tokenEnd[tokenEndPos]) {
390  if (tokenEndPos == (tokenEndLen - 1)) {
391  intoken = false;
392  userData->lastTextNode = lastTextNode;
393  if ((!handleToken(text, token, userData)) && (passThruUnknownToken)) {
394  text += tokenStart;
395  text += token;
396  text += tokenEnd;
397  }
398  escEndPos = escStartPos = tokenEndPos = tokenStartPos = 0;
399  lastTextNode = "";
400  if (!userData->suspendTextPassThru) {
401  userData->lastSuspendSegment.size(0);
402  }
403  continue;
404  }
405  }
406  }
407 
408  if (intoken) {
409  if (tokpos < 4090) {
410  token[tokpos++] = *from;
411  token[tokpos+2] = 0;
412  }
413  }
414  else {
415  if ((!userData->supressAdjacentWhitespace) || (*from != ' ')) {
416  if (!userData->suspendTextPassThru) {
417  text.append(*from);
418  }
419  else userData->lastSuspendSegment.append(*from);
420  lastTextNode.append(*from);
421  }
422  userData->supressAdjacentWhitespace = false;
423  }
424 
425  if (processStages & POSTCHAR)
426  processStage(POSTCHAR, text, from, userData);
427 
428  }
429 
430  if (processStages & FINALIZE)
431  processStage(FINALIZE, text, from, userData);
432 
433  delete userData;
434  return 0;
435 }
static const char PRECHAR
Definition: swbasicfilter.h:97
Definition: swbuf.h:47
static const char POSTCHAR
Definition: swbasicfilter.h:98
char * tokenStart
Definition: swbasicfilter.h:64
virtual bool handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData)
bool passThruUnknownEsc
Definition: swbasicfilter.h:77
virtual bool handleEscapeString(SWBuf &buf, const char *escString, BasicFilterUserData *userData)
bool passThruUnknownToken
Definition: swbasicfilter.h:76
static const char FINALIZE
Definition: swbasicfilter.h:99
char * getRawData()
Definition: swbuf.h:379
SWBuf & append(const char *str, long max=-1)
Definition: swbuf.h:274
virtual bool processStage(char, SWBuf &, char *&, BasicFilterUserData *)
virtual BasicFilterUserData * createUserData(const SWModule *module, const SWKey *key)
Definition: swbasicfilter.h:91
unsigned long size() const
Definition: swbuf.h:185
static const char INITIALIZE
Definition: swbasicfilter.h:96
void appendEscapeString(SWBuf &buf, const char *escString)
void SWBasicFilter::removeAllowedEscapeString ( const char *  findString)
protectedinherited

Unregisters an esc control sequence that can pass unchanged

Definition at line 169 of file swbasicfilter.cpp.

169  {
170  if (p->escPassSet.find(findString) != p->escPassSet.end()) {
171  p->escPassSet.erase( p->escPassSet.find(findString) );
172  }
173 }
Private * p
Definition: swbasicfilter.h:82
void SWBasicFilter::removeEscapeStringSubstitute ( const char *  findString)
protectedinherited

Unregisters an esc control sequence

Definition at line 189 of file swbasicfilter.cpp.

189  {
190  if (p->escSubMap.find(findString) != p->escSubMap.end()) {
191  p->escSubMap.erase( p->escSubMap.find(findString) );
192  }
193 }
Private * p
Definition: swbasicfilter.h:82
void SWBasicFilter::removeTokenSubstitute ( const char *  findString)
protectedinherited

Unregisters a simple token substitute

Definition at line 149 of file swbasicfilter.cpp.

149  {
150  if (p->tokenSubMap.find(findString) != p->tokenSubMap.end()) {
151  p->tokenSubMap.erase( p->tokenSubMap.find(findString) );
152  }
153 }
DualStringMap tokenSubMap
Private * p
Definition: swbasicfilter.h:82
void SWBasicFilter::setEscapeEnd ( const char *  escEnd)
protectedinherited

Sets the end of escape sequence (by default ";").

Definition at line 297 of file swbasicfilter.cpp.

297  {
298  stdstr(&(this->escEnd), escEnd);
299  escEndLen = strlen(escEnd);
300 }
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
void SWBasicFilter::setEscapeStart ( const char *  escStart)
protectedinherited

Sets the beginning of escape sequence (by default "&").

Definition at line 291 of file swbasicfilter.cpp.

291  {
292  stdstr(&(this->escStart), escStart);
293  escStartLen = strlen(escStart);
294 }
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
void SWBasicFilter::setEscapeStringCaseSensitive ( bool  val)
protectedinherited

Are escapeStrings case sensitive or not? Call this function before addEscapeStingSubstitute()

Definition at line 131 of file swbasicfilter.cpp.

131  {
133 }
bool escStringCaseSensitive
Definition: swbasicfilter.h:74
void SWBasicFilter::setPassThruNumericEscapeString ( bool  val)
protectedinherited

Sets whether to pass thru a numeric escape sequence unchanged or allow it to be handled otherwise. Default is false.

Definition at line 121 of file swbasicfilter.cpp.

121  {
122  passThruUnknownEsc = val;
123 }
bool passThruUnknownEsc
Definition: swbasicfilter.h:77
void SWBasicFilter::setPassThruUnknownEscapeString ( bool  val)
protectedinherited

Sets whether to pass thru an unknown escape sequence unchanged or just remove it. Default is false.

Definition at line 116 of file swbasicfilter.cpp.

116  {
117  passThruUnknownEsc = val;
118 }
bool passThruUnknownEsc
Definition: swbasicfilter.h:77
void SWBasicFilter::setPassThruUnknownToken ( bool  val)
protectedinherited

Sets whether to pass thru an unknown token unchanged or just remove it. Default is false.

Definition at line 111 of file swbasicfilter.cpp.

111  {
112  passThruUnknownToken = val;
113 }
bool passThruUnknownToken
Definition: swbasicfilter.h:76
virtual void SWBasicFilter::setStageProcessing ( char  stages)
inlineprotectedvirtualinherited

Definition at line 186 of file swbasicfilter.h.

186 { processStages = stages; } // see STATICs up above
void SWBasicFilter::setTokenCaseSensitive ( bool  val)
protectedinherited

Are tokens case sensitive (like in GBF) or not? Call this function before addTokenSubstitute()

Definition at line 126 of file swbasicfilter.cpp.

126  {
127  tokenCaseSensitive = val;
128 }
bool tokenCaseSensitive
Definition: swbasicfilter.h:75
void SWBasicFilter::setTokenEnd ( const char *  tokenEnd)
protectedinherited

Sets the end of token start sequence (by default ">").

Definition at line 309 of file swbasicfilter.cpp.

309  {
310  stdstr(&(this->tokenEnd), tokenEnd);
311  tokenEndLen = strlen(tokenEnd);
312 }
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
void SWBasicFilter::setTokenStart ( const char *  tokenStart)
protectedinherited

Sets the beginning of token start sequence (by default "<").

Definition at line 303 of file swbasicfilter.cpp.

303  {
304  stdstr(&(this->tokenStart), tokenStart);
305  tokenStartLen = strlen(tokenStart);
306 }
char * tokenStart
Definition: swbasicfilter.h:64
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
bool SWBasicFilter::substituteEscapeString ( SWBuf buf,
const char *  escString 
)
protectedinherited

This function performs the substitution of escapeStrings

Definition at line 253 of file swbasicfilter.cpp.

253  {
254  DualStringMap::iterator it;
255 
256  if (*escString == '#') {
257  return handleNumericEscapeString(buf, escString);
258  }
259 
260  if (passAllowedEscapeString(buf, escString)) {
261  return true;
262  }
263 
264  if (!escStringCaseSensitive) {
265  char *tmp = 0;
266  stdstr(&tmp, escString);
267  toupperstr(tmp);
268  it = p->escSubMap.find(tmp);
269  delete [] tmp;
270  } else
271  it = p->escSubMap.find(escString);
272 
273  if (it != p->escSubMap.end()) {
274  buf += it->second.c_str();
275  return true;
276  }
277  return false;
278 }
virtual bool handleNumericEscapeString(SWBuf &buf, const char *escString)
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
const char * c_str() const
Definition: swbuf.h:158
bool escStringCaseSensitive
Definition: swbasicfilter.h:74
bool passAllowedEscapeString(SWBuf &buf, const char *escString)
char * toupperstr(char *t, unsigned int max=0)
Definition: stringmgr.h:107
Private * p
Definition: swbasicfilter.h:82
bool SWBasicFilter::substituteToken ( SWBuf buf,
const char *  token 
)
protectedinherited

This function performs the substitution of tokens

Definition at line 196 of file swbasicfilter.cpp.

196  {
197  DualStringMap::iterator it;
198 
199  if (!tokenCaseSensitive) {
200  char *tmp = 0;
201  stdstr(&tmp, token);
202  toupperstr(tmp);
203  it = p->tokenSubMap.find(tmp);
204  delete [] tmp;
205  } else
206  it = p->tokenSubMap.find(token);
207 
208  if (it != p->tokenSubMap.end()) {
209  buf += it->second.c_str();
210  return true;
211  }
212  return false;
213 }
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
const char * c_str() const
Definition: swbuf.h:158
bool tokenCaseSensitive
Definition: swbasicfilter.h:75
DualStringMap tokenSubMap
char * toupperstr(char *t, unsigned int max=0)
Definition: stringmgr.h:107
Private * p
Definition: swbasicfilter.h:82

Member Data Documentation

const char SWBasicFilter::FINALIZE = 8
staticprotectedinherited

Definition at line 99 of file swbasicfilter.h.

const char SWBasicFilter::INITIALIZE = 1
staticprotectedinherited

Definition at line 96 of file swbasicfilter.h.

const char SWBasicFilter::POSTCHAR = 4
staticprotectedinherited

Definition at line 98 of file swbasicfilter.h.

const char SWBasicFilter::PRECHAR = 2
staticprotectedinherited

Definition at line 97 of file swbasicfilter.h.


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