search.h
上传用户:psq1974
上传日期:2007-01-06
资源大小:1195k
文件大小:2k
- /* Copyright (C) 1998, 1999 State University of New York at Stony Brook
- Author: Andrew V. Shuvalov ( andrew@ecsl.cs.sunysb.edu )
- Software license is located in file "COPYING"
- */
- #ifndef _search_h_
- #define _search_h_
- #include "string_of_text.h"
- #include "gtk_search_win.h"
- /** abstract base class */
- class BoolSearchOperation {
- protected:
- const WordDb &wordDb;
- BoolSearchOperation *left;
- BoolSearchOperation *right;
- /** place result here */
- WordOccurencesT WordOccurences;
- public:
- BoolSearchOperation( const WordDb &wdb ) : wordDb( wdb ),
- left( NULL ), right( NULL ) {}
- virtual const WordOccurencesT &get_result() = 0;
- /** priority level is */
- int precedence() const;
- static int precedence( SearchItem::type type );
- virtual SearchItem::type get_type() const = 0;
- BoolSearchOperation *create_by_childs_and_item
- ( BoolSearchOperation *leftchild, BoolSearchOperation *rightchild,
- const SearchItem &item ) const;
- /** this call may be recursive */
- static BoolSearchOperation *merge_search_items
- ( BoolSearchOperation *head, BoolSearchOperation *right,
- const SearchItem &item );
- };
- /** this class hold the result of search */
- class BoolSearchOperationResult : public BoolSearchOperation {
- public:
- BoolSearchOperationResult( const WordDb &wdb, const WordOccurencesT &wo )
- : BoolSearchOperation( wdb )
- {
- WordOccurences = wo;
- }
- virtual const WordOccurencesT &get_result() {
- return WordOccurences;
- }
- virtual SearchItem::type get_type() const { return SearchItem::result; }
- };
- class BoolSearchOperationAnd : public BoolSearchOperation {
- public:
- BoolSearchOperationAnd( const WordDb &wdb ) :
- BoolSearchOperation( wdb ) {}
- virtual const WordOccurencesT &get_result();
- virtual SearchItem::type get_type() const { return SearchItem::and; }
- };
- class BoolSearchOperationAndNot : public BoolSearchOperation {
- public:
- BoolSearchOperationAndNot( const WordDb &wdb ) :
- BoolSearchOperation( wdb ) {}
- virtual const WordOccurencesT &get_result();
- virtual SearchItem::type get_type() const { return SearchItem::andnot; }
- };
- class BoolSearchOperationOr : public BoolSearchOperation {
- public:
- BoolSearchOperationOr( const WordDb &wdb ) :
- BoolSearchOperation( wdb ) {}
- virtual const WordOccurencesT &get_result();
- virtual SearchItem::type get_type() const { return SearchItem::or; }
- };
- #endif // _search_h_