[python3] Simplify generated wrapper post-processing
[xapian.git] / xapian-core / include / xapian / valuesetmatchdecider.h
blob636104781a872d265203a1fe3df116d7c13f8646
1 /** @file valuesetmatchdecider.h
2 * @brief MatchDecider subclass for filtering results by value.
3 */
4 /* Copyright 2008 Lemur Consulting Ltd
5 * Copyright 2008,2009,2011,2013,2014,2017 Olly Betts
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
20 * USA
23 #ifndef XAPIAN_INCLUDED_VALUESETMATCHDECIDER_H
24 #define XAPIAN_INCLUDED_VALUESETMATCHDECIDER_H
26 #if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD
27 # error "Never use <xapian/valuesetmatchdecider.h> directly; include <xapian.h> instead."
28 #endif
30 #include <xapian/matchdecider.h>
31 #include <xapian/types.h>
32 #include <xapian/visibility.h>
34 #include <string>
35 #include <set>
37 namespace Xapian {
39 class Document;
41 /** MatchDecider filtering results based on whether document values are in a
42 * user-defined set.
44 class XAPIAN_VISIBILITY_DEFAULT ValueSetMatchDecider : public MatchDecider {
45 /** Set of values to test for. */
46 std::set<std::string> testset;
48 /** The value slot to look in. */
49 valueno valuenum;
51 /** Whether to include or exclude documents with the specified values.
53 * If true, documents with a value in the set are returned.
54 * If false, documents with a value not in the set are returned.
56 bool inclusive;
58 public:
59 /** Construct a ValueSetMatchDecider.
61 * @param slot The value slot number to look in.
63 * @param inclusive_ If true, match decider accepts documents which have a
64 * value in the specified slot which is a member of the test set; if
65 * false, match decider accepts documents which do not have a value in the
66 * specified slot.
68 ValueSetMatchDecider(Xapian::valueno slot, bool inclusive_)
69 : valuenum(slot), inclusive(inclusive_) { }
71 /** Add a value to the test set.
73 * @param value The value to add to the test set.
75 void add_value(const std::string& value)
77 testset.insert(value);
80 /** Remove a value from the test set.
82 * @param value The value to remove from the test set.
84 void remove_value(const std::string& value)
86 testset.erase(value);
89 /** Decide whether we want a particular document to be in the MSet.
91 * @param doc The document to test.
92 * @return true if the document is acceptable, or false if the
93 * document should be excluded from the MSet.
95 bool operator()(const Xapian::Document& doc) const;
100 #endif /* XAPIAN_INCLUDED_VALUESETMATCHDECIDER_H */