File indexing completed on 2024-05-19 15:10:28
0001 /* This file is part of Strigi Desktop Search 0002 * 0003 * Copyright (C) 2006 Jos van den Oever <jos@vandenoever.info> 0004 * 0005 * This library is free software; you can redistribute it and/or 0006 * modify it under the terms of the GNU Library General Public 0007 * License as published by the Free Software Foundation; either 0008 * version 2 of the License, or (at your option) any later version. 0009 * 0010 * This library is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 * Library General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU Library General Public License 0016 * along with this library; see the file COPYING.LIB. If not, write to 0017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0018 * Boston, MA 02110-1301, USA. 0019 */ 0020 //#include <strigi/strigiconfig.h> 0021 #include <strigi/analyzerplugin.h> 0022 #include <strigi/streamendanalyzer.h> 0023 #include <strigi/streamsaxanalyzer.h> 0024 #include <strigi/streamthroughanalyzer.h> 0025 #include <strigi/streamlineanalyzer.h> 0026 #include <strigi/streameventanalyzer.h> 0027 0028 using namespace Strigi; 0029 using namespace std; 0030 0031 class DummyEndAnalyzerFactory; 0032 class DummyThroughAnalyzerFactory; 0033 class DummySaxAnalyzerFactory; 0034 class DummyLineAnalyzerFactory; 0035 class DummyEventAnalyzerFactory; 0036 0037 class STRIGI_PLUGIN_API DummyEndAnalyzer : public StreamEndAnalyzer 0038 { 0039 public: 0040 DummyEndAnalyzer() {} 0041 bool checkHeader(const char *, int32_t) const 0042 { 0043 return false; 0044 } 0045 signed char analyze(Strigi::AnalysisResult &, InputStream *) 0046 { 0047 return -1; 0048 } 0049 const char *name() const 0050 { 0051 return "DummyEndAnalyzer"; 0052 } 0053 }; 0054 class STRIGI_PLUGIN_API DummyEndAnalyzerFactory : public StreamEndAnalyzerFactory 0055 { 0056 const char *name() const 0057 { 0058 return "DummyEndAnalyzerFactory"; 0059 } 0060 void registerFields(Strigi::FieldRegister &) {} 0061 StreamEndAnalyzer *newInstance() const 0062 { 0063 return new DummyEndAnalyzer(); 0064 } 0065 }; 0066 class STRIGI_PLUGIN_API DummyThroughAnalyzer : public StreamThroughAnalyzer 0067 { 0068 public: 0069 DummyThroughAnalyzer() {} 0070 const char *name() const 0071 { 0072 return "DummyThroughAnalyzer"; 0073 } 0074 void setIndexable(Strigi::AnalysisResult *) {} 0075 InputStream *connectInputStream(InputStream *in) 0076 { 0077 return in; 0078 } 0079 bool isReadyWithStream() 0080 { 0081 return true; 0082 } 0083 }; 0084 class STRIGI_PLUGIN_API DummyThroughAnalyzerFactory : public StreamThroughAnalyzerFactory 0085 { 0086 const char *name() const 0087 { 0088 return "DummyThroughAnalyzerFactory"; 0089 } 0090 void registerFields(Strigi::FieldRegister &) {} 0091 StreamThroughAnalyzer *newInstance() const 0092 { 0093 return new DummyThroughAnalyzer(); 0094 } 0095 }; 0096 class STRIGI_PLUGIN_API DummySaxAnalyzer : public StreamSaxAnalyzer 0097 { 0098 public: 0099 DummySaxAnalyzer() {} 0100 const char *name() const 0101 { 0102 return "DummySaxAnalyzer"; 0103 } 0104 void startAnalysis(AnalysisResult *) {} 0105 void endAnalysis(bool /*complete*/) {} 0106 bool isReadyWithStream() 0107 { 0108 return true; 0109 } 0110 }; 0111 class STRIGI_PLUGIN_API DummySaxAnalyzerFactory : public StreamSaxAnalyzerFactory 0112 { 0113 const char *name() const 0114 { 0115 return "DummySaxAnalyzerFactory"; 0116 } 0117 void registerFields(Strigi::FieldRegister &) {} 0118 StreamSaxAnalyzer *newInstance() const 0119 { 0120 return new DummySaxAnalyzer(); 0121 } 0122 }; 0123 class STRIGI_PLUGIN_API DummyLineAnalyzer : public StreamLineAnalyzer 0124 { 0125 public: 0126 DummyLineAnalyzer() {} 0127 const char *name() const 0128 { 0129 return "DummyLineAnalyzer"; 0130 } 0131 void startAnalysis(AnalysisResult *) {} 0132 void endAnalysis(bool /*complete*/) {} 0133 void handleLine(const char *, uint32_t) {} 0134 bool isReadyWithStream() 0135 { 0136 return true; 0137 } 0138 }; 0139 class STRIGI_PLUGIN_API DummyLineAnalyzerFactory : public StreamLineAnalyzerFactory 0140 { 0141 const char *name() const 0142 { 0143 return "DummyLineAnalyzerFactory"; 0144 } 0145 void registerFields(Strigi::FieldRegister &) {} 0146 StreamLineAnalyzer *newInstance() const 0147 { 0148 return new DummyLineAnalyzer(); 0149 } 0150 }; 0151 class STRIGI_PLUGIN_API DummyEventAnalyzer : public StreamEventAnalyzer 0152 { 0153 public: 0154 DummyEventAnalyzer() {} 0155 const char *name() const 0156 { 0157 return "DummyEventAnalyzer"; 0158 } 0159 void startAnalysis(AnalysisResult *) {} 0160 void endAnalysis(bool /*complete*/) {} 0161 void handleData(const char *, uint32_t) {} 0162 bool isReadyWithStream() 0163 { 0164 return true; 0165 } 0166 }; 0167 class STRIGI_PLUGIN_API DummyEventAnalyzerFactory : public StreamEventAnalyzerFactory 0168 { 0169 const char *name() const 0170 { 0171 return "DummyEventAnalyzerFactory"; 0172 } 0173 void registerFields(Strigi::FieldRegister &) {} 0174 StreamEventAnalyzer *newInstance() const 0175 { 0176 return new DummyEventAnalyzer(); 0177 } 0178 }; 0179 0180 class Factory : public AnalyzerFactoryFactory 0181 { 0182 public: 0183 list<StreamEndAnalyzerFactory *> 0184 streamEndAnalyzerFactories() const 0185 { 0186 list<StreamEndAnalyzerFactory *> af; 0187 af.push_back(new DummyEndAnalyzerFactory()); 0188 return af; 0189 } 0190 list<StreamThroughAnalyzerFactory *> 0191 streamThroughAnalyzerFactories() const 0192 { 0193 list<StreamThroughAnalyzerFactory *> af; 0194 af.push_back(new DummyThroughAnalyzerFactory()); 0195 return af; 0196 } 0197 list<StreamSaxAnalyzerFactory *> 0198 streamSaxAnalyzerFactories() const 0199 { 0200 list<StreamSaxAnalyzerFactory *> af; 0201 af.push_back(new DummySaxAnalyzerFactory()); 0202 return af; 0203 } 0204 list<StreamLineAnalyzerFactory *> 0205 streamLineAnalyzerFactories() const 0206 { 0207 list<StreamLineAnalyzerFactory *> af; 0208 af.push_back(new DummyLineAnalyzerFactory()); 0209 return af; 0210 } 0211 list<StreamEventAnalyzerFactory *> 0212 streamEventAnalyzerFactories() const 0213 { 0214 list<StreamEventAnalyzerFactory *> af; 0215 af.push_back(new DummyEventAnalyzerFactory()); 0216 return af; 0217 } 0218 }; 0219 0220 /* 0221 Register the AnalyzerFactoryFactory 0222 */ 0223 STRIGI_ANALYZER_FACTORY(Factory)