00001 00004 /* Copyright (C) 2008,2010 Olly Betts 00005 * Copyright (C) 2011 Action Without Borders 00006 * 00007 * This program is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00020 */ 00021 00022 #ifndef XAPIAN_INCLUDED_ESETINTERNAL_H 00023 #define XAPIAN_INCLUDED_ESETINTERNAL_H 00024 00025 #include "xapian/base.h" 00026 #include "xapian/enquire.h" 00027 #include "xapian/types.h" 00028 00029 #include <algorithm> 00030 #include <string> 00031 #include <vector> 00032 00033 namespace Xapian { 00034 class Database; 00035 class ExpandDecider; 00036 00037 namespace Internal { 00038 class ExpandWeight; 00039 00041 class ExpandTerm { 00042 friend class Xapian::ESetIterator; 00043 friend class Xapian::ESet::Internal; 00044 00046 Xapian::weight wt; 00047 00049 std::string term; 00050 00051 public: 00053 ExpandTerm(Xapian::weight wt_, const std::string & term_) 00054 : wt(wt_), term(term_) { } 00055 00057 void swap(ExpandTerm & o) { 00058 std::swap(wt, o.wt); 00059 std::swap(term, o.term); 00060 } 00061 00063 bool operator<(const ExpandTerm & o) const { 00064 if (wt > o.wt) return true; 00065 if (wt < o.wt) return false; 00066 return term > o.term; 00067 } 00068 00070 std::string get_description() const; 00071 }; 00072 00073 } 00074 00076 class ESet::Internal : public Xapian::Internal::RefCntBase { 00077 friend class ESet; 00078 friend class ESetIterator; 00079 00085 Xapian::termcount ebound; 00086 00088 std::vector<Xapian::Internal::ExpandTerm> items; 00089 00091 void operator=(const Internal &); 00092 00094 Internal(const Internal &); 00095 00096 public: 00098 Internal() : ebound(0) { } 00099 00101 void expand(Xapian::termcount max_esize, 00102 const Xapian::Database & db, 00103 const Xapian::RSet & rset, 00104 const Xapian::ExpandDecider * edecider, 00105 const Xapian::Internal::ExpandWeight & eweight, 00106 Xapian::weight min_wt); 00107 00109 std::string get_description() const; 00110 }; 00111 00112 } 00113 00114 #endif // XAPIAN_INCLUDED_ESETINTERNAL_H