Refactor to avoid warning with GCC 12.2
[xapian.git] / xapian-core / expand / ortermlist.h
blob8d5584944bccdcc757ac2ea05b1520679fce5a9c
1 /** @file
2 * @brief Merge two TermList objects using an OR operation.
3 */
4 /* Copyright (C) 2007,2010 Olly Betts
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef XAPIAN_INCLUDED_ORTERMLIST_H
22 #define XAPIAN_INCLUDED_ORTERMLIST_H
24 #include "api/termlist.h"
26 namespace Xapian {
27 namespace Internal {
28 class ExpandStats;
32 class OrTermList : public TermList {
33 protected:
34 /// The two TermList objects we're merging.
35 TermList *left, *right;
37 /** The current term for left and right respectively.
39 * Until next() is first called, these will be empty strings. Once next()
40 * has been called, they won't be empty (since the empty string isn't a
41 * valid term).
43 std::string left_current, right_current;
45 /// Check that next() has already been called.
46 void check_started() const;
48 public:
49 OrTermList(TermList * left_, TermList * right_)
50 : left(left_), right(right_) { }
52 ~OrTermList();
54 Xapian::termcount get_approx_size() const;
56 void accumulate_stats(Xapian::Internal::ExpandStats & stats) const;
58 std::string get_termname() const;
60 Xapian::termcount get_wdf() const;
62 Xapian::doccount get_termfreq() const;
64 TermList *next();
66 TermList * skip_to(const std::string & term);
68 bool at_end() const;
70 Xapian::termcount positionlist_count() const;
72 Xapian::PositionIterator positionlist_begin() const;
75 /** A termlist which ORs two termlists together, adding term frequencies.
77 * This termlist is just like OrTermList, but adds the term frequencies of
78 * terms which appear in both sublists together, rather than asserting that the
79 * frequencies are equal. This is appropriate for spelling termlists.
81 class FreqAdderOrTermList : public OrTermList {
82 public:
83 FreqAdderOrTermList(TermList * left_, TermList * right_)
84 : OrTermList(left_, right_)
85 { }
87 Xapian::doccount get_termfreq() const;
90 #endif // XAPIAN_INCLUDED_ORTERMLIST_H