~ubuntu-branches/debian/squeeze/sword/squeeze

« back to all changes in this revision

Viewing changes to include/swsearchable.h

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Glassey
  • Date: 2004-01-15 15:50:07 UTC
  • Revision ID: james.westby@ubuntu.com-20040115155007-n9mz4x0zxrs1isd3
Tags: upstream-1.5.7
ImportĀ upstreamĀ versionĀ 1.5.7

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************************************
 
2
 *  swsearchable.h      - definition of class SWSearchable used to provide an
 
3
 *      interface for objects that be searched.
 
4
 *
 
5
 * $Id: swsearchable.h,v 1.1 2003/08/29 06:00:16 scribe Exp $
 
6
 *
 
7
 * Copyright 1998 CrossWire Bible Society (http://www.crosswire.org)
 
8
 *      CrossWire Bible Society
 
9
 *      P. O. Box 2528
 
10
 *      Tempe, AZ  85280-2528
 
11
 *
 
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.
 
15
 *
 
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.
 
20
 *
 
21
 */
 
22
 
 
23
#ifndef SWSEARCHABLE_H
 
24
#define SWSEARCHABLE_H
 
25
 
 
26
#include <defs.h>
 
27
#include <listkey.h>
 
28
 
 
29
SWORD_NAMESPACE_START
 
30
 
 
31
/** used to provide an interface for objects that be searched.
 
32
 */
 
33
class SWDLLEXPORT SWSearchable {
 
34
public:
 
35
        SWSearchable();
 
36
        virtual ~SWSearchable();
 
37
 
 
38
        /**
 
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().
 
43
        */
 
44
        static void nullPercent(char percent, void *userData);
 
45
 
 
46
        // search methods
 
47
 
 
48
        /** Searches a module for a string
 
49
        *
 
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.
 
59
        *
 
60
        * @return listkey set to verses that contain istr
 
61
        */
 
62
        virtual ListKey &search(const char *istr, int searchType = 0, int flags = 0,
 
63
                        SWKey * scope = 0,
 
64
                        bool * justCheckIfSupported = 0,
 
65
                        void (*percent) (char, void *) = &nullPercent,
 
66
                        void *percentUserData = 0) = 0;
 
67
 
 
68
        /** ask the object to build any framework it need to do it searching.
 
69
        *
 
70
        */
 
71
        virtual signed char createSearchFramework();    // special search framework
 
72
 
 
73
        /** does this class have a search framework built?
 
74
        *
 
75
        */
 
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.
 
80
        */
 
81
        virtual bool isSearchOptimallySupported(const char *istr, int searchType, int flags, SWKey * scope) {
 
82
                bool retVal = false;
 
83
                search(istr, searchType, flags, scope, &retVal);
 
84
                return retVal;
 
85
        }
 
86
};
 
87
 
 
88
SWORD_NAMESPACE_END
 
89
#endif