Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

swbasicfilter.h

00001 /******************************************************************************
00002  *  swbasicfilter.h     - definition of class SWBasicFilter.  An SWFilter
00003  *                              impl that provides some basic methods that
00004  *                              many filter will need and can use as a starting
00005  *                              point. 
00006  *
00007  * $Id: swbasicfilter_8h-source.html,v 1.7 2002/06/20 20:23:10 mgruner Exp $
00008  *
00009  * Copyright 1998 CrossWire Bible Society (http://www.crosswire.org)
00010  *      CrossWire Bible Society
00011  *      P. O. Box 2528
00012  *      Tempe, AZ  85280-2528
00013  *
00014  * This program is free software; you can redistribute it and/or modify it
00015  * under the terms of the GNU General Public License as published by the
00016  * Free Software Foundation version 2.
00017  *
00018  * This program is distributed in the hope that it will be useful, but
00019  * WITHOUT ANY WARRANTY; without even the implied warranty of
00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00021  * General Public License for more details.
00022  *
00023  */
00024 
00025 #ifndef SWBASICFILTER_H
00026 #define SWBASICFILTER_H
00027 
00028 #include <swfilter.h>
00029 
00030 #include <defs.h>
00031 #include <map>
00032 using namespace std;
00033 
00045 class SWDLLEXPORT SWBasicFilter : public SWFilter {
00046 
00047         char *tokenStart;
00048         char *tokenEnd;
00049         char *escStart;
00050         char *escEnd;
00051         bool escStringCaseSensitive;
00052         bool tokenCaseSensitive;
00053         bool passThruUnknownToken;
00054         bool passThruUnknownEsc;
00055 
00056 public:
00057         SWBasicFilter();
00058         virtual char ProcessText(char *text, int maxlen, const SWKey *, const SWModule * = 0);
00059         virtual ~SWBasicFilter();
00060 
00061 protected:
00062         const SWModule *module;
00063         const SWKey *key;
00064         char *resultBuffer;
00065         typedef map<string, string> DualStringMap;
00066         DualStringMap tokenSubMap;
00067         DualStringMap escSubMap;
00068 
00070         void setEscapeStart(const char *escStart);
00071 
00073         void setEscapeEnd(const char *escEnd);
00074 
00076         void setTokenStart(const char *tokenStart);
00077 
00079         void setTokenEnd(const char *tokenEnd);
00080 
00083         void setPassThruUnknownToken(bool val);
00084 
00087         void setPassThruUnknownEscapeString(bool val);
00088 
00089         void setTokenCaseSensitive(bool val);
00090         void setEscapeStringCaseSensitive(bool val);
00091 
00092         void addTokenSubstitute(const char *findString, const char *replaceString);
00093         void addEscapeStringSubstitute(const char *findString, const char *replaceString);
00094         bool substituteToken(char **buf, const char *token);
00095         bool substituteEscapeString(char **buf, const char *escString);
00096 
00098         void pushString(char **buf, const char *format, ...);
00099 
00106         virtual bool handleToken(char **buf, const char *token, DualStringMap &userData);
00107 
00114         virtual bool handleEscapeString(char **buf, const char *escString, DualStringMap &userData);
00115 };
00116 
00117 #endif

Generated on Thu Jun 20 22:13:00 2002 for The Sword Project by doxygen1.2.15