00001 00004 /* Copyright (C) 2007,2011 Olly Betts 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License as 00008 * published by the Free Software Foundation; either version 2 of the 00009 * License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00019 */ 00020 00021 #ifndef XAPIAN_INCLUDED_EXPANDDECIDER_H 00022 #define XAPIAN_INCLUDED_EXPANDDECIDER_H 00023 00024 #include <set> 00025 #include <string> 00026 00027 #include <xapian/visibility.h> 00028 00029 namespace Xapian { 00030 00032 class XAPIAN_VISIBILITY_DEFAULT ExpandDecider { 00033 public: 00038 virtual bool operator()(const std::string &term) const = 0; 00039 00041 virtual ~ExpandDecider(); 00042 }; 00043 00049 class XAPIAN_VISIBILITY_DEFAULT ExpandDeciderAnd : public ExpandDecider { 00050 const ExpandDecider &first, &second; 00051 00052 public: 00059 ExpandDeciderAnd(const ExpandDecider &first_, 00060 const ExpandDecider &second_) 00061 : first(first_), second(second_) { } 00062 00068 ExpandDeciderAnd(const ExpandDecider *first_, 00069 const ExpandDecider *second_) 00070 : first(*first_), second(*second_) { } 00071 00072 virtual bool operator()(const std::string &term) const; 00073 }; 00074 00080 class XAPIAN_VISIBILITY_DEFAULT ExpandDeciderFilterTerms : public ExpandDecider { 00081 std::set<std::string> rejects; 00082 00083 public: 00092 template <class Iterator> 00093 ExpandDeciderFilterTerms(Iterator reject_begin, Iterator reject_end) 00094 : rejects(reject_begin, reject_end) { } 00095 00096 virtual bool operator()(const std::string &term) const; 00097 }; 00098 00099 } 00100 00101 #endif // XAPIAN_INCLUDED_EXPANDDECIDER_H