00001 /* msetcmp.h - MSetItem comparison functions and functors. 00002 * 00003 * Copyright (C) 2006,2007 Olly Betts 00004 * 00005 * This program is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU General Public License as 00007 * published by the Free Software Foundation; either version 2 of the 00008 * License, or (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 00018 * USA 00019 */ 00020 00021 00022 #ifndef XAPIAN_INCLUDED_MSETCMP_H 00023 #define XAPIAN_INCLUDED_MSETCMP_H 00024 00025 #include "omenquireinternal.h" 00026 00027 // typedef for MSetItem comparison function. 00028 typedef bool (* mset_cmp)(const Xapian::Internal::MSetItem &, 00029 const Xapian::Internal::MSetItem &); 00030 00032 mset_cmp get_msetcmp_function(Xapian::Enquire::Internal::sort_setting sort_by, bool sort_forward, bool sort_value_forward); 00033 00035 class MSetCmp { 00036 mset_cmp fn; 00037 public: 00038 MSetCmp(mset_cmp fn_) : fn(fn_) { } 00040 bool operator()(const Xapian::Internal::MSetItem &a, 00041 const Xapian::Internal::MSetItem &b) const { 00042 return fn(a, b); 00043 } 00044 }; 00045 00046 #endif // XAPIAN_INCLUDED_MSETCMP_H