KIO
dummyanalyzers.cpp
Go to the documentation of this file.
00001 /* This file is part of Strigi Desktop Search 00002 * 00003 * Copyright (C) 2006 Jos van den Oever <jos@vandenoever.info> 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Library General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Library General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Library General Public License 00016 * along with this library; see the file COPYING.LIB. If not, write to 00017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 * Boston, MA 02110-1301, USA. 00019 */ 00020 //#include <strigi/strigiconfig.h> 00021 #include <strigi/analyzerplugin.h> 00022 #include <strigi/streamendanalyzer.h> 00023 #include <strigi/streamsaxanalyzer.h> 00024 #include <strigi/streamthroughanalyzer.h> 00025 #include <strigi/streamlineanalyzer.h> 00026 #include <strigi/streameventanalyzer.h> 00027 #include <config-strigi.h> 00028 00029 using namespace Strigi; 00030 using namespace std; 00031 00032 class DummyEndAnalyzerFactory; 00033 class DummyThroughAnalyzerFactory; 00034 class DummySaxAnalyzerFactory; 00035 class DummyLineAnalyzerFactory; 00036 class DummyEventAnalyzerFactory; 00037 00038 class STRIGI_PLUGIN_API DummyEndAnalyzer : public StreamEndAnalyzer { 00039 public: 00040 DummyEndAnalyzer() {} 00041 bool checkHeader(const char*, int32_t) const { 00042 return false; 00043 } 00044 STRIGI_ENDANALYZER_RETVAL analyze(Strigi::AnalysisResult&, InputStream*) { 00045 return -1; 00046 } 00047 const char* name() const { return "DummyEndAnalyzer"; } 00048 }; 00049 class STRIGI_PLUGIN_API DummyEndAnalyzerFactory : public StreamEndAnalyzerFactory { 00050 const char* name() const { 00051 return "DummyEndAnalyzerFactory"; 00052 } 00053 void registerFields(Strigi::FieldRegister&) {} 00054 StreamEndAnalyzer* newInstance() const { 00055 return new DummyEndAnalyzer(); 00056 } 00057 }; 00058 class STRIGI_PLUGIN_API DummyThroughAnalyzer : public StreamThroughAnalyzer { 00059 public: 00060 DummyThroughAnalyzer() {} 00061 const char* name() const { 00062 return "DummyThroughAnalyzer"; 00063 } 00064 void setIndexable(Strigi::AnalysisResult*) {} 00065 InputStream* connectInputStream(InputStream *in) { 00066 return in; 00067 } 00068 bool isReadyWithStream() { return true; } 00069 }; 00070 class STRIGI_PLUGIN_API DummyThroughAnalyzerFactory : public StreamThroughAnalyzerFactory { 00071 const char* name() const { 00072 return "DummyThroughAnalyzerFactory"; 00073 } 00074 void registerFields(Strigi::FieldRegister&) {} 00075 StreamThroughAnalyzer* newInstance() const { 00076 return new DummyThroughAnalyzer(); 00077 } 00078 }; 00079 class STRIGI_PLUGIN_API DummySaxAnalyzer : public StreamSaxAnalyzer { 00080 public: 00081 DummySaxAnalyzer() {} 00082 const char* name() const { return "DummySaxAnalyzer"; } 00083 void startAnalysis(AnalysisResult*) {} 00084 void endAnalysis(bool /*complete*/) {} 00085 bool isReadyWithStream() { return true; } 00086 }; 00087 class STRIGI_PLUGIN_API DummySaxAnalyzerFactory : public StreamSaxAnalyzerFactory { 00088 const char* name() const { 00089 return "DummySaxAnalyzerFactory"; 00090 } 00091 void registerFields(Strigi::FieldRegister&) {} 00092 StreamSaxAnalyzer* newInstance() const { 00093 return new DummySaxAnalyzer(); 00094 } 00095 }; 00096 class STRIGI_PLUGIN_API DummyLineAnalyzer : public StreamLineAnalyzer { 00097 public: 00098 DummyLineAnalyzer() {} 00099 const char* name() const { return "DummyLineAnalyzer"; } 00100 void startAnalysis(AnalysisResult*) {} 00101 void endAnalysis(bool /*complete*/) {} 00102 void handleLine(const char*, uint32_t) {} 00103 bool isReadyWithStream() { return true; } 00104 }; 00105 class STRIGI_PLUGIN_API DummyLineAnalyzerFactory : public StreamLineAnalyzerFactory { 00106 const char* name() const { 00107 return "DummyLineAnalyzerFactory"; 00108 } 00109 void registerFields(Strigi::FieldRegister&) {} 00110 StreamLineAnalyzer* newInstance() const { 00111 return new DummyLineAnalyzer(); 00112 } 00113 }; 00114 class STRIGI_PLUGIN_API DummyEventAnalyzer : public StreamEventAnalyzer { 00115 public: 00116 DummyEventAnalyzer() {} 00117 const char* name() const { return "DummyEventAnalyzer"; } 00118 void startAnalysis(AnalysisResult*) {} 00119 void endAnalysis(bool /*complete*/) {} 00120 void handleData(const char*, uint32_t) {} 00121 bool isReadyWithStream() { return true; } 00122 }; 00123 class STRIGI_PLUGIN_API DummyEventAnalyzerFactory : public StreamEventAnalyzerFactory { 00124 const char* name() const { 00125 return "DummyEventAnalyzerFactory"; 00126 } 00127 void registerFields(Strigi::FieldRegister&) {} 00128 StreamEventAnalyzer* newInstance() const { 00129 return new DummyEventAnalyzer(); 00130 } 00131 }; 00132 00133 class Factory : public AnalyzerFactoryFactory { 00134 public: 00135 list<StreamEndAnalyzerFactory*> 00136 streamEndAnalyzerFactories() const { 00137 list<StreamEndAnalyzerFactory*> af; 00138 af.push_back(new DummyEndAnalyzerFactory()); 00139 return af; 00140 } 00141 list<StreamThroughAnalyzerFactory*> 00142 streamThroughAnalyzerFactories() const { 00143 list<StreamThroughAnalyzerFactory*> af; 00144 af.push_back(new DummyThroughAnalyzerFactory()); 00145 return af; 00146 } 00147 list<StreamSaxAnalyzerFactory*> 00148 streamSaxAnalyzerFactories() const { 00149 list<StreamSaxAnalyzerFactory*> af; 00150 af.push_back(new DummySaxAnalyzerFactory()); 00151 return af; 00152 } 00153 list<StreamLineAnalyzerFactory*> 00154 streamLineAnalyzerFactories() const { 00155 list<StreamLineAnalyzerFactory*> af; 00156 af.push_back(new DummyLineAnalyzerFactory()); 00157 return af; 00158 } 00159 list<StreamEventAnalyzerFactory*> 00160 streamEventAnalyzerFactories() const { 00161 list<StreamEventAnalyzerFactory*> af; 00162 af.push_back(new DummyEventAnalyzerFactory()); 00163 return af; 00164 } 00165 }; 00166 00167 /* 00168 Register the AnalyzerFactoryFactory 00169 */ 00170 STRIGI_ANALYZER_FACTORY(Factory)
KDE 4.6 API Reference