1 /***************************************************** vim:set ts=4 sw=4 sts=4:
2 Generic String Replacement Filter Processing class.
3 This is the interface definition for text filters.
6 (C) 2005 by Gary Cramblitt <garycramblitt@comcast.net>
8 Original author: Gary Cramblitt <garycramblitt@comcast.net>
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA.
23 ******************************************************************************/
25 #ifndef _STRINGREPLACERPROC_H_
26 #define _STRINGREPLACERPROC_H_
30 #include <qtextstream.h>
31 #include <q3valuelist.h>
33 #include <qstringlist.h>
38 #include "filterproc.h"
40 class StringReplacerProc
: virtual public KttsFilterProc
48 StringReplacerProc( QObject
*parent
, const char *name
, const QStringList
&args
= QStringList() );
53 virtual ~StringReplacerProc();
56 * Initialize the filter.
57 * @param config Settings object.
58 * @param configGroup Settings Group.
59 * @return False if filter is not ready to filter.
61 * Note: The parameters are for reading from kttsdrc file. Plugins may wish to maintain
62 * separate configuration files of their own.
64 virtual bool init(KConfig
*config
, const QString
&configGroup
);
67 * Convert input, returning output.
68 * @param inputText Input text.
69 * @param talkerCode TalkerCode structure for the talker that KTTSD intends to
70 * use for synthing the text. Useful for extracting hints about
71 * how to filter the text. For example, languageCode.
72 * @param appId The DCOP appId of the application that queued the text.
73 * Also useful for hints about how to do the filtering.
75 virtual QString
convert(const QString
& inputText
, TalkerCode
* talkerCode
, const Q3CString
& appId
);
78 * Did this filter do anything? If the filter returns the input as output
79 * unmolested, it should return False when this method is called.
81 virtual bool wasModified();
84 // Language codes supported by the filter.
85 QStringList m_languageCodeList
;
86 // If not empty, apply filter only to apps containing one or more of these strings.
87 QStringList m_appIdList
;
89 // List of regular expressions to match.
90 Q3ValueList
<QRegExp
> m_matchList
;
91 // List of substitutions to replace matches.
92 Q3ValueList
<QString
> m_substList
;
93 // True if this filter did anything to the text.
97 #endif // _STRINGREPLACERPROC_H_