-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExpand.patch
More file actions
49 lines (46 loc) · 1.46 KB
/
Expand.patch
File metadata and controls
49 lines (46 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
Index: xapian-core/include/xapian/expanddecider.h
===================================================================
--- xapian-core/include/xapian/expanddecider.h (revision 17103)
+++ xapian-core/include/xapian/expanddecider.h (working copy)
@@ -96,6 +96,28 @@
virtual bool operator()(const std::string &term) const;
};
+/** ExpandDecider subclass which restrict terms to a particular prefix
+ *
+ * ExpandDeciderFilterPrefix provides an easy way to choose terms with a
+ * particular prefix when generating an ESet.
+ */
+class XAPIAN_VISIBILITY_DEFAULT ExpandDeciderFilterPrefix : public ExpandDecider {
+ std::string prefix;
+ unsigned length;
+
+ public:
+ /** The parameter specify the prefix of terms to be retained
+ * @param prefix_ restrict terms to the particular prefix_
+ */
+ ExpandDeciderFilterPrefix(const std::string &prefix_)
+ : prefix(prefix_)
+ {
+ length = prefix.length();
+ }
+
+ virtual bool operator() (const std::string &term) const;
+};
+
}
#endif // XAPIAN_INCLUDED_EXPANDDECIDER_H
Index: xapian-core/api/expanddecider.cc
===================================================================
--- xapian-core/api/expanddecider.cc (revision 17103)
+++ xapian-core/api/expanddecider.cc (working copy)
@@ -45,4 +45,11 @@
return i == rejects.end();
}
+bool
+ExpandDeciderFilterPrefix::operator()(const string &term) const
+{
+ string p = term.substr(0, length);
+ return p != prefix;
}
+
+}