summaryrefslogtreecommitdiff
path: root/src/modules/filters/swbasicfilter.cpp
diff options
context:
space:
mode:
authorRoberto C. Sanchez <roberto@connexer.com>2014-05-12 08:21:30 -0400
committerRoberto C. Sanchez <roberto@connexer.com>2014-05-12 08:21:30 -0400
commit7a00574163029c0c2b649878c95d5acbd083564a (patch)
treec13cc5736025834df2874ed87ee8598070025ea6 /src/modules/filters/swbasicfilter.cpp
parentb745315323de9f27538edac9453205ca70e6186e (diff)
Imported Upstream version 1.7.2+dfsg
Diffstat (limited to 'src/modules/filters/swbasicfilter.cpp')
-rw-r--r--src/modules/filters/swbasicfilter.cpp28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/modules/filters/swbasicfilter.cpp b/src/modules/filters/swbasicfilter.cpp
index ef10e45..e66017e 100644
--- a/src/modules/filters/swbasicfilter.cpp
+++ b/src/modules/filters/swbasicfilter.cpp
@@ -1,12 +1,13 @@
/******************************************************************************
- * swbasicfilter.h - definition of class SWBasicFilter. An SWFilter
- * impl that provides some basic methods that
- * many filters will need and can use as a starting
- * point.
*
- * $Id: swbasicfilter.cpp 2167 2008-05-16 23:23:39Z scribe $
+ * swbasicfilter.cpp - definition of class SWBasicFilter. An SWFilter
+ * impl that provides some basic methods that
+ * many filters will need and can use as a starting
+ * point.
*
- * Copyright 2001 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: swbasicfilter.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -33,9 +34,11 @@
SWORD_NAMESPACE_START
+
typedef std::map<SWBuf, SWBuf> DualStringMap;
typedef std::set<SWBuf> StringSet;
+
// I hate bridge patterns but this isolates std::map from a ton of filters
class SWBasicFilter::Private {
public:
@@ -44,11 +47,13 @@ public:
StringSet escPassSet;
};
+
const char SWBasicFilter::INITIALIZE = 1;
const char SWBasicFilter::PRECHAR = 2;
const char SWBasicFilter::POSTCHAR = 4;
const char SWBasicFilter::FINALIZE = 8;
+
SWBasicFilter::SWBasicFilter() {
p = new Private;
@@ -98,6 +103,7 @@ void SWBasicFilter::setPassThruUnknownEscapeString(bool val) {
passThruUnknownEsc = val;
}
+
void SWBasicFilter::setPassThruNumericEscapeString(bool val) {
passThruUnknownEsc = val;
}
@@ -132,6 +138,7 @@ void SWBasicFilter::removeTokenSubstitute(const char *findString) {
}
}
+
void SWBasicFilter::addAllowedEscapeString(const char *findString) {
char *buf = 0;
@@ -144,12 +151,14 @@ void SWBasicFilter::addAllowedEscapeString(const char *findString) {
else p->escPassSet.insert(StringSet::value_type(findString));
}
+
void SWBasicFilter::removeAllowedEscapeString(const char *findString) {
if (p->escPassSet.find(findString) != p->escPassSet.end()) {
p->escPassSet.erase( p->escPassSet.find(findString) );
}
}
+
void SWBasicFilter::addEscapeStringSubstitute(const char *findString, const char *replaceString) {
char *buf = 0;
@@ -162,12 +171,14 @@ void SWBasicFilter::addEscapeStringSubstitute(const char *findString, const char
else p->escSubMap.insert(DualStringMap::value_type(findString, replaceString));
}
+
void SWBasicFilter::removeEscapeStringSubstitute(const char *findString) {
if (p->escSubMap.find(findString) != p->escSubMap.end()) {
p->escSubMap.erase( p->escSubMap.find(findString) );
}
}
+
bool SWBasicFilter::substituteToken(SWBuf &buf, const char *token) {
DualStringMap::iterator it;
@@ -187,12 +198,14 @@ bool SWBasicFilter::substituteToken(SWBuf &buf, const char *token) {
return false;
}
+
void SWBasicFilter::appendEscapeString(SWBuf &buf, const char *escString) {
buf += escStart;
buf += escString;
buf += escEnd;
}
+
bool SWBasicFilter::passAllowedEscapeString(SWBuf &buf, const char *escString) {
StringSet::iterator it;
@@ -213,6 +226,7 @@ bool SWBasicFilter::passAllowedEscapeString(SWBuf &buf, const char *escString) {
return false;
}
+
bool SWBasicFilter::handleNumericEscapeString(SWBuf &buf, const char *escString) {
if (passThruNumericEsc) {
appendEscapeString(buf, escString);
@@ -221,6 +235,7 @@ bool SWBasicFilter::handleNumericEscapeString(SWBuf &buf, const char *escString)
return false;
}
+
bool SWBasicFilter::substituteEscapeString(SWBuf &buf, const char *escString) {
DualStringMap::iterator it;
@@ -403,4 +418,5 @@ char SWBasicFilter::processText(SWBuf &text, const SWKey *key, const SWModule *m
return 0;
}
+
SWORD_NAMESPACE_END