~ubuntu-branches/debian/squeeze/sword/squeeze

« back to all changes in this revision

Viewing changes to include/swbasicfilter.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Marsden, Jonathan Marsden, Dmitrijs Ledkovs, Closed Bugs
  • Date: 2009-05-30 11:55:55 UTC
  • mfrom: (1.3.1 upstream) (6.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20090530115555-r427zsn3amivdpfu
Tags: 1.6.0+dfsg-1
[ Jonathan Marsden ]
* New upstream release. (Closes: #507960) (LP: #320558)
* debian/patches/02_libver.diff:
  - Bump SONAME to 8 -- SWORD 1.6 is not backward compatible with 1.5.11.
* debian/patches/series:
  - Remove 10_diatheke.diff -- included in upstream source.
* debian/patches/:
  - Remove several old unused .diff files.
  - Add 11_regex_only_when_needed.diff to conditionally include regex lib.
  - Add 12_fix_compiler_warnings.diff to remove all compiler warnings.
  - Add 13_fix_osis2mod_compression_default.diff from upstream svn.
  - Add 14_closing_section_not_chapter.diff from upstream svn.
* debian/libsword7.*: 
  - Rename to libsword8.*
  - Change libsword7 to libsword8 within files.
* debian/rules: 
  - SONAME bump to 8.
  - Set library version check to >= 1.6
* debian/control:
  - Change libsword7 to libsword8.
  - Add libsword7 to Conflicts.
  - Fix case of sword to SWORD in package descriptions.
  - Bump Standards-Version to 3.8.1 (no changes needed).
  - Fix section for libsword-dbg to avoid lintian warning.
* debian/rules:
  - Add DFSG get-orig-source target.
* debian/copyright:
  - Fix various mistakes in initial attempt to document copyrights.

[ Dmitrijs Ledkovs ]
* debian/rules: Added utils.mk to use missing-files target and call it on
  each build.
* debian/libsword-dev.install: Added libsword.la, previously missing.
* debian/libsword7.install: Added missing libicu translit files.
* debian/control:
  - Updated all uses of SWORD version to 1.6
  - Added libsword-dbg package
* debian/watch: Fixed a small mistake which was resulting in extra "."
  in final version name.
* debian/rules: simplified manpage processing.
* debian/libsword8.lintian-overrides: added override for module
  installation directory.
* debian/copyright: Updated with information about everyfile.
  Closes: #513448 LP: #322638
* debian/diatheke.examples: moved examples here from the diatheke.install
* debian/rules:
  - enabled shell script based testsuite
  - added commented out cppunit testsuite
* debian/patches/40_missing_includes.diff: 
  - added several missing stdio.h includes to prevent FTBFS of testsuite.

[ Closed Bugs ]
* FTBFS on intrepid (LP: #305172)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************************************
 
2
 *  swbasicfilter.h     - definition of class SWBasicFilter.  An SWFilter
 
3
 *                              impl that provides some basic methods that
 
4
 *                              many filter will need and can use as a starting
 
5
 *                              point. 
 
6
 *
 
7
 * $Id: swbasicfilter.h 1984 2006-10-08 05:06:52Z scribe $
 
8
 *
 
9
 * Copyright 1998 CrossWire Bible Society (http://www.crosswire.org)
 
10
 *      CrossWire Bible Society
 
11
 *      P. O. Box 2528
 
12
 *      Tempe, AZ  85280-2528
 
13
 *
 
14
 * This program is free software; you can redistribute it and/or modify it
 
15
 * under the terms of the GNU General Public License as published by the
 
16
 * Free Software Foundation version 2.
 
17
 *
 
18
 * This program is distributed in the hope that it will be useful, but
 
19
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
21
 * General Public License for more details.
 
22
 *
 
23
 */
 
24
 
 
25
#ifndef SWBASICFILTER_H
 
26
#define SWBASICFILTER_H
 
27
 
 
28
#include <swfilter.h>
 
29
#include <swbuf.h>
 
30
 
 
31
SWORD_NAMESPACE_START
 
32
 
 
33
 
 
34
// not a protected inner class because MSVC++ sucks and can't handle it
 
35
class SWDLLEXPORT BasicFilterUserData {
 
36
public:
 
37
        BasicFilterUserData(const SWModule *module, const SWKey *key) { this->module = module; this->key = key; suspendTextPassThru = false; supressAdjacentWhitespace = false; }
 
38
        virtual ~BasicFilterUserData() {}
 
39
        const SWModule *module;
 
40
        const SWKey *key;
 
41
        SWBuf lastTextNode;
 
42
        SWBuf lastSuspendSegment;
 
43
        bool suspendTextPassThru;
 
44
        bool supressAdjacentWhitespace;
 
45
};
 
46
 
 
47
/** A filter providing commonly used functionality.
 
48
 * This filter has facilities for handling SGML/HTML/XML like tokens and
 
49
 * escape strings (like SGML entities). It has the facility for just
 
50
 * substituting the given tokens and escape strings to other strings and for
 
51
 * "manual" custom token handling.
 
52
 *
 
53
 * In this class the functions with arguments looking as <code>char
 
54
 * **buf</code> write a character sequnce at address specified by
 
55
 * <code>*buf</code> address and change <code>*buf</code> to point past
 
56
 * the last char of the written sequence.
 
57
 */
 
58
class SWDLLEXPORT SWBasicFilter : public SWFilter {
 
59
 
 
60
class Private;
 
61
 
 
62
        char *tokenStart;
 
63
        char *tokenEnd;
 
64
        char *escStart;
 
65
        char *escEnd;
 
66
        char escStartLen;
 
67
        char escEndLen;
 
68
        char tokenStartLen;
 
69
        char tokenEndLen;
 
70
        bool escStringCaseSensitive;
 
71
        bool tokenCaseSensitive;
 
72
        bool passThruUnknownToken;
 
73
        bool passThruUnknownEsc;
 
74
        bool passThruNumericEsc;
 
75
        char processStages;
 
76
 
 
77
 
 
78
        Private *p;
 
79
public:
 
80
 
 
81
        SWBasicFilter();
 
82
        virtual char processText(SWBuf &text, const SWKey *key = 0, const SWModule *module = 0);
 
83
        virtual ~SWBasicFilter();
 
84
 
 
85
protected:
 
86
 
 
87
        virtual BasicFilterUserData *createUserData(const SWModule *module, const SWKey *key) {
 
88
                return new BasicFilterUserData(module, key);
 
89
        }
 
90
 
 
91
        // STAGEs
 
92
        static const char INITIALIZE;   // flag for indicating processing before char loop
 
93
        static const char PRECHAR;      // flag for indicating processing at top in char loop
 
94
        static const char POSTCHAR;     // flag for indicating processing at bottom in char loop
 
95
        static const char FINALIZE;     // flag for indicating processing after char loop
 
96
 
 
97
 
 
98
        /** Sets the beginning of escape sequence (by default "&").*/
 
99
        void setEscapeStart(const char *escStart);
 
100
 
 
101
        /** Sets the end of escape sequence (by default ";").*/
 
102
        void setEscapeEnd(const char *escEnd);
 
103
 
 
104
        /** Sets the beginning of token start sequence (by default "<").*/
 
105
        void setTokenStart(const char *tokenStart);
 
106
 
 
107
        /** Sets the end of token start sequence (by default ">").*/
 
108
        void setTokenEnd(const char *tokenEnd);
 
109
 
 
110
        /** Sets whether to pass thru an unknown token unchanged
 
111
         *      or just remove it.
 
112
         * Default is false.*/
 
113
        void setPassThruUnknownToken(bool val);
 
114
 
 
115
        /** Sets whether to pass thru an unknown escape sequence unchanged
 
116
         *      or just remove it.
 
117
         *      Default is false.
 
118
         */
 
119
        void setPassThruUnknownEscapeString(bool val);
 
120
 
 
121
        /** Sets whether to pass thru a numeric escape sequence unchanged
 
122
         *      or allow it to be handled otherwise.
 
123
         * Default is false.*/
 
124
        void setPassThruNumericEscapeString(bool val);
 
125
 
 
126
        /** Are escapeStrings case sensitive or not? Call this
 
127
         *      function before addEscapeStingSubstitute()
 
128
         */
 
129
        void setEscapeStringCaseSensitive(bool val);
 
130
 
 
131
        /** Registers an esc control sequence that can pass unchanged
 
132
         */
 
133
        void addAllowedEscapeString(const char *findString);
 
134
 
 
135
        /** Unregisters an esc control sequence that can pass unchanged
 
136
         */
 
137
        void removeAllowedEscapeString(const char *findString);
 
138
 
 
139
        /** Registers an esc control sequence
 
140
         */
 
141
        void addEscapeStringSubstitute(const char *findString, const char *replaceString);
 
142
 
 
143
        /** Unregisters an esc control sequence
 
144
         */
 
145
        void removeEscapeStringSubstitute(const char *findString);
 
146
 
 
147
        /** This function performs the substitution of escapeStrings */
 
148
        bool substituteEscapeString(SWBuf &buf, const char *escString);
 
149
 
 
150
        /** This passes allowed escapeStrings */
 
151
        bool passAllowedEscapeString(SWBuf &buf, const char *escString);
 
152
 
 
153
        /** This appends escString to buf as an entity */
 
154
        void appendEscapeString(SWBuf &buf, const char *escString);
 
155
 
 
156
        /** Are tokens case sensitive (like in GBF) or not? Call this
 
157
         *      function before addTokenSubstitute()
 
158
         */
 
159
        void setTokenCaseSensitive(bool val);
 
160
 
 
161
        /** Registers a simple token substitutions.  Usually called from the
 
162
         *      c-tor of a subclass
 
163
         */
 
164
        void addTokenSubstitute(const char *findString, const char *replaceString);
 
165
 
 
166
        /** Unregisters a simple token substitute
 
167
         */
 
168
        void removeTokenSubstitute(const char *findString);
 
169
 
 
170
        /** This function performs the substitution of tokens */
 
171
        bool substituteToken(SWBuf &buf, const char *token);
 
172
 
 
173
        /** This function is called for every token encountered in the input text.
 
174
         * @param buf the output buffer
 
175
         * @param token the token (e.g. <code>"p align='left'"</code>
 
176
         * @param userData user storage space for data transient to 1 full buffer parse
 
177
         * @return subclasses should return true if they handled the token, or false if they did not.
 
178
         */
 
179
        virtual bool handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData);
 
180
 
 
181
        virtual bool processStage(char /*stage*/, SWBuf &/*text*/, char *&/*from*/, BasicFilterUserData * /*userData*/) { return false; }
 
182
        virtual void setStageProcessing(char stages) { processStages = stages; }        // see STATICs up above
 
183
 
 
184
        /** This function is called for every escape sequence encountered in the input text.
 
185
         * @param buf the output buffer 
 
186
         * @param escString the escape sequence (e.g. <code>"amp"</code> for &amp;amp;)
 
187
         * @param userData user storage space for data transient to 1 full buffer parse
 
188
         * @return <code>false</code> if was not handled and should be handled in
 
189
         * @return subclasses should return true if they handled the esc seq, or false if they did not.
 
190
         */
 
191
        virtual bool handleEscapeString(SWBuf &buf, const char *escString, BasicFilterUserData *userData);
 
192
 
 
193
        /** This function is called for all numeric escape sequences. If passThrough
 
194
         * @param buf the output buffer 
 
195
         * @param escString the escape sequence (e.g. <code>"#235"</code> for &amp;235;)
 
196
         * @return subclasses should return true if they handled the esc seq, or false if they did not.
 
197
         */
 
198
        virtual bool handleNumericEscapeString(SWBuf &buf, const char *escString);
 
199
 
 
200
 
 
201
};
 
202
 
 
203
SWORD_NAMESPACE_END
 
204
#endif