[java] Improve build on FreeBSD and DragonFlyBSD
[xapian.git] / xapian-core / backends / glass / glass_spellingwordslist.h
blobcabf377be24e6e89d7c67f4adeb92212d5424fa4
1 /** @file
2 * @brief A termlist containing all words which are spelling targets.
3 */
4 /* Copyright (C) 2005,2008,2009,2010,2011,2017,2024 Olly Betts
5 * Copyright (C) 2007 Lemur Consulting Ltd
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #ifndef XAPIAN_INCLUDED_GLASS_SPELLINGWORDSLIST_H
23 #define XAPIAN_INCLUDED_GLASS_SPELLINGWORDSLIST_H
25 #include "backends/alltermslist.h"
26 #include "glass_spelling.h"
27 #include "glass_cursor.h"
29 class GlassDatabase;
31 class GlassSpellingWordsList : public AllTermsList {
32 /// Copying is not allowed.
33 GlassSpellingWordsList(const GlassSpellingWordsList &);
35 /// Assignment is not allowed.
36 void operator=(const GlassSpellingWordsList &);
38 /// Keep a reference to our database to stop it being deleted.
39 Xapian::Internal::intrusive_ptr<const GlassDatabase> database;
41 /** A cursor which runs through the spelling table reading termnames from
42 * the keys.
44 GlassCursor * cursor;
46 /** The term frequency of the term at the current position.
48 * If this value is zero, then we haven't read the term frequency or
49 * collection frequency for the current term yet. We need to call
50 * read_termfreq() to read these.
52 mutable Xapian::termcount termfreq;
54 /// Read and cache the term frequency.
55 void read_termfreq() const;
57 public:
58 GlassSpellingWordsList(Xapian::Internal::intrusive_ptr<const GlassDatabase> database_,
59 GlassCursor * cursor_)
60 : database(database_), cursor(cursor_), termfreq(0) {
61 // Seek to the entry before the first key with a "W" prefix, so the
62 // first next() will advance us to the first such entry.
63 cursor->find_entry(std::string("W", 1));
66 /// Destructor.
67 ~GlassSpellingWordsList();
69 Xapian::termcount get_approx_size() const;
71 /** Returns the term frequency of the current term.
73 * Either next() or skip_to() must have been called before this
74 * method can be called.
76 Xapian::doccount get_termfreq() const;
78 /// Advance to the next term in the list.
79 TermList * next();
81 /// Advance to the first term which is >= tname.
82 TermList* skip_to(std::string_view tname);
85 #endif /* XAPIAN_INCLUDED_GLASS_SPELLINGWORDSLIST_H */