Branch data Line data Source code
1 : : /* msetcmp.h - MSetItem comparison functions and functors.
2 : : *
3 : : * Copyright (C) 2006,2007 Olly Betts
4 : : *
5 : : * This program is free software; you can redistribute it and/or
6 : : * modify it under the terms of the GNU General Public License as
7 : : * published by the Free Software Foundation; either version 2 of the
8 : : * License, or (at your option) any later version.
9 : : *
10 : : * This program is distributed in the hope that it will be useful,
11 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 : : * GNU General Public License for more details.
14 : : *
15 : : * You should have received a copy of the GNU General Public License
16 : : * along with this program; if not, write to the Free Software
17 : : * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
18 : : * USA
19 : : */
20 : :
21 : :
22 : : #ifndef XAPIAN_INCLUDED_MSETCMP_H
23 : : #define XAPIAN_INCLUDED_MSETCMP_H
24 : :
25 : : #include "omenquireinternal.h"
26 : :
27 : : // typedef for MSetItem comparison function.
28 : : typedef bool (* mset_cmp)(const Xapian::Internal::MSetItem &,
29 : : const Xapian::Internal::MSetItem &);
30 : :
31 : : /// Select the appropriate msetcmp function.
32 : : mset_cmp get_msetcmp_function(Xapian::Enquire::Internal::sort_setting sort_by, bool sort_forward, bool sort_value_forward);
33 : :
34 : : /// MSetItem comparison functor.
35 : : class MSetCmp {
36 : : mset_cmp fn;
37 : : public:
38 : 173480 : MSetCmp(mset_cmp fn_) : fn(fn_) { }
39 : : /// Return true if MSetItem a should be ranked above MSetItem b.
40 : 427109334 : bool operator()(const Xapian::Internal::MSetItem &a,
41 : : const Xapian::Internal::MSetItem &b) const {
42 : 427109334 : return fn(a, b);
43 : : }
44 : : };
45 : :
46 : : #endif // XAPIAN_INCLUDED_MSETCMP_H
|