Main Page   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_h-source.html,v 1.4 2001/10/05 20:45:21 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 
00034 
00035 class SWDLLEXPORT SWBasicFilter : public SWFilter {
00036 
00037         char *tokenStart;
00038         char *tokenEnd;
00039         char *escStart;
00040         char *escEnd;
00041         bool escStringCaseSensitive;
00042         bool tokenCaseSensitive;
00043         bool passThruUnknownToken;
00044         bool passThruUnknownEsc;
00045 
00046 public:
00047         SWBasicFilter();
00048         virtual char ProcessText(char *text, int maxlen = -1);
00049         virtual ~SWBasicFilter();
00050 
00051 protected:
00052         typedef map<string, string> DualStringMap;
00053         DualStringMap tokenSubMap;
00054         DualStringMap escSubMap;
00055         void setEscapeStart(const char *escStart);
00056         void setEscapeEnd(const char *escEnd);
00057         void setTokenStart(const char *tokenStart);
00058         void setTokenEnd(const char *tokenEnd);
00059         void setPassThruUnknownToken(bool val);
00060         void setPassThruUnknownEscapeString(bool val);
00061         void setTokenCaseSensitive(bool val);
00062         void setEscapeStringCaseSensitive(bool val);
00063         void addTokenSubstitute(const char *findString, const char *replaceString);
00064         void addEscapeStringSubstitute(const char *findString, const char *replaceString);
00065         bool substituteToken(char **buf, const char *token);
00066         bool substituteEscapeString(char **buf, const char *escString);
00067         void pushString(char **buf, const char *fragToPush);
00068 
00069         virtual bool handleToken(char **buf, const char *token, DualStringMap &userData);
00070         virtual bool handleEscapeString(char **buf, const char *escString, DualStringMap &userData);
00071 };
00072 
00073 #endif

Generated at Fri Oct 5 22:45:33 2001 for The Sword Project by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001