1
/******************************************************************************
2
* swsearchable.h - definition of class SWSearchable used to provide an
3
* interface for objects that be searched.
5
* $Id: swsearchable.h,v 1.1 2003/08/29 06:00:16 scribe Exp $
7
* Copyright 1998 CrossWire Bible Society (http://www.crosswire.org)
8
* CrossWire Bible Society
10
* Tempe, AZ 85280-2528
12
* This program is free software; you can redistribute it and/or modify it
13
* under the terms of the GNU General Public License as published by the
14
* Free Software Foundation version 2.
16
* This program is distributed in the hope that it will be useful, but
17
* WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19
* General Public License for more details.
23
#ifndef SWSEARCHABLE_H
24
#define SWSEARCHABLE_H
31
/** used to provide an interface for objects that be searched.
33
class SWDLLEXPORT SWSearchable {
36
virtual ~SWSearchable();
39
* This is the default callback function for searching.
40
* This function is a placeholder and does nothing.
41
* You can define your own function for search progress
42
* evaluation, and pass it over to Search().
44
static void nullPercent(char percent, void *userData);
48
/** Searches a module for a string
50
* @param istr string for which to search
51
* @param searchType type of search to perform
52
* >=0 ->regex; -1 ->phrase; -2 ->multiword;
53
* @param flags options flags for search
54
* @param scope Key containing the scope. VerseKey or ListKey are useful here.
55
* @param justCheckIfSupported if set, don't search,
56
* only tell if this function supports requested search.
57
* @param percent Callback function to get the current search status in %.
58
* @param percentUserData User data that is given to the callback function as parameter.
60
* @return listkey set to verses that contain istr
62
virtual ListKey &search(const char *istr, int searchType = 0, int flags = 0,
64
bool * justCheckIfSupported = 0,
65
void (*percent) (char, void *) = &nullPercent,
66
void *percentUserData = 0) = 0;
68
/** ask the object to build any framework it need to do it searching.
71
virtual signed char createSearchFramework(); // special search framework
73
/** does this class have a search framework built?
76
virtual bool hasSearchFramework() { return false; } // special search framework
77
/** Check if the search is optimally supported (e.g. if index files are presnt and working)
78
* This function checks whether the search framework may work in the best way.
79
* @return True if the the search is optimally supported, false if it's not working in the best way.
81
virtual bool isSearchOptimallySupported(const char *istr, int searchType, int flags, SWKey * scope) {
83
search(istr, searchType, flags, scope, &retVal);