1 #include <swmodule.h>
2 #include <swkey.h>
3 #include <listkey.h>
4 
5 using namespace sword;
6 class SWSearcher{
7 public:
8 	sword::SWModule* mod;
9 	int percent;
10 
Callback(char status,void * me)11 	static void Callback(char status, void *me){
12 		SWSearcher* searcher = (SWSearcher*)me;
13 		searcher->PercentFunction((int) status);
14 	}
15 
PercentFunction(int value)16 	virtual void PercentFunction(int value){
17 		percent=value;
18 	}
19 
SWSearcher(sword::SWModule * Mod)20 	SWSearcher(sword::SWModule* Mod){mod=Mod;}
~SWSearcher()21 	virtual ~SWSearcher(){}
22 
GetPercent()23 	int GetPercent(){return percent;}
24 
25 	bool isSearchSupported(const char *istr, int searchType = 0,
26 							  int flags = 0,
27 			SWKey * scope = 0) {
28 			bool checksupported = true;
29 			mod->search(istr, searchType, flags, scope, &checksupported);
30 			return checksupported;
31 	}
32 
33 	ListKey &doSearch(const char *istr, int searchType = 0, int flags = 0,
34 					  SWKey *scope = 0) {
35 			return mod->search(istr, searchType, flags, scope,
36 				   0, this->Callback, (void *) this);
37 	}
38 
TerminateSearch()39 	void TerminateSearch(){
40 		mod->terminateSearch=true;
41 	}
42 };
43 
44