summaryrefslogtreecommitdiff
path: root/bindings/swig/package/searcher.h
blob: e04db92896cee29132f104a0656930202be751f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <swmodule.h>
#include <swkey.h>
#include <listkey.h>

using namespace sword;
class SWSearcher{
public:
	sword::SWModule* mod;
	int percent;

	static void Callback(char status, void *me){
		SWSearcher* searcher = (SWSearcher*)me;
		searcher->PercentFunction((int) status);
	}

	virtual void PercentFunction(int value){
		percent=value;
	}
	
	SWSearcher(sword::SWModule* Mod){mod=Mod;}
	virtual ~SWSearcher(){}

	int GetPercent(){return percent;}

	bool isSearchSupported(const char *istr, int searchType = 0,
							  int flags = 0,
			SWKey * scope = 0) {
			bool checksupported = true;
			mod->search(istr, searchType, flags, scope, &checksupported);
			return checksupported;
	}

	ListKey &doSearch(const char *istr, int searchType = 0, int flags = 0,
					  SWKey *scope = 0) {
			return mod->search(istr, searchType, flags, scope,
				   0, this->Callback, (void *) this);
	}

	void TerminateSearch(){
		mod->terminateSearch=true;
	}
};