xapian-core  1.4.27
expanddecider.h
Go to the documentation of this file.
1 
4 /* Copyright (C) 2007,2011,2013,2014,2015,2016 Olly Betts
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of the
9  * License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #ifndef XAPIAN_INCLUDED_EXPANDDECIDER_H
22 #define XAPIAN_INCLUDED_EXPANDDECIDER_H
23 
24 #if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD
25 # error Never use <xapian/expanddecider.h> directly; include <xapian.h> instead.
26 #endif
27 
28 #include <set>
29 #include <string>
30 
31 #include <xapian/intrusive_ptr.h>
32 #include <xapian/visibility.h>
33 
34 namespace Xapian {
35 
40  void operator=(const ExpandDecider &);
41 
44 
45  public:
48 
53  virtual bool operator()(const std::string &term) const = 0;
54 
56  virtual ~ExpandDecider();
57 
66  opt_intrusive_base::release();
67  return this;
68  }
69 
77  const ExpandDecider * release() const {
78  opt_intrusive_base::release();
79  return this;
80  }
81 };
82 
90 
91  public:
99  const ExpandDecider &second_)
100  : first(&first_), second(&second_) { }
101 
108  const ExpandDecider *second_)
109  : first(first_), second(second_) { }
110 
111  virtual bool operator()(const std::string &term) const;
112 };
113 
120  std::set<std::string> rejects;
121 
122  public:
131  template<class Iterator>
132  ExpandDeciderFilterTerms(Iterator reject_begin, Iterator reject_end)
133  : rejects(reject_begin, reject_end) { }
134 
135  virtual bool operator()(const std::string &term) const;
136 };
137 
144  std::string prefix;
145 
146  public:
150  explicit ExpandDeciderFilterPrefix(const std::string &prefix_)
151  : prefix(prefix_) { }
152 
153  virtual bool operator() (const std::string &term) const;
154 };
155 
156 }
157 
158 #endif // XAPIAN_INCLUDED_EXPANDDECIDER_H
The Xapian namespace contains public interfaces for the Xapian library.
Definition: compactor.cc:80
ExpandDecider subclass which restrict terms to a particular prefix.
ExpandDecider subclass which rejects terms in a specified list.
ExpandDeciderFilterTerms(Iterator reject_begin, Iterator reject_end)
The two iterators specify a list of terms to be rejected.
Internal::opt_intrusive_ptr< const ExpandDecider > second
Definition: expanddecider.h:89
ExpandDecider()
Default constructor.
Definition: expanddecider.h:47
std::set< std::string > rejects
ExpandDecider subclass which rejects terms using two ExpandDeciders.
Definition: expanddecider.h:88
Virtual base class for expand decider functor.
Definition: expanddecider.h:37
#define XAPIAN_VISIBILITY_DEFAULT
Definition: visibility.h:28
ExpandDecider * release()
Start reference counting this object.
Definition: expanddecider.h:65
ExpandDeciderAnd(const ExpandDecider &first_, const ExpandDecider &second_)
Terms will be checked with first, and if accepted, then checked with second.
Definition: expanddecider.h:98
Define XAPIAN_VISIBILITY_* macros.
const ExpandDecider * release() const
Start reference counting this object.
Definition: expanddecider.h:77
Base class for objects managed by opt_intrusive_ptr.
ExpandDeciderAnd(const ExpandDecider *first_, const ExpandDecider *second_)
Compatibility method.
A smart pointer that optionally uses intrusive reference counting.
ExpandDeciderFilterPrefix(const std::string &prefix_)
The parameter specify the prefix of terms to be retained.