root / tags / 1.0.8 / xapian-core / backends / flint / flint_spellingwordslist.h
| Revision 9066, 3.3 kB (checked in by richard, 19 months ago) | |
|---|---|
|
|
| Line | |
|---|---|
| 1 | /* flint_spellingwordslist.h: A termlist containing all words which are spelling targets. |
| 2 | * |
| 3 | * Copyright (C) 2005 Olly Betts |
| 4 | * Copyright (C) 2007 Lemur Consulting Ltd |
| 5 | * |
| 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. |
| 10 | * |
| 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. |
| 15 | * |
| 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 |
| 19 | */ |
| 20 | |
| 21 | #ifndef XAPIAN_HGUARD_FLINT_SPELLINGWORDSLIST_H |
| 22 | #define XAPIAN_HGUARD_FLINT_SPELLINGWORDSLIST_H |
| 23 | |
| 24 | #include "alltermslist.h" |
| 25 | #include "database.h" |
| 26 | #include "flint_spelling.h" |
| 27 | |
| 28 | class FlintCursor; |
| 29 | |
| 30 | class FlintSpellingWordsList : public AllTermsList { |
| 31 | /// Copying is not allowed. |
| 32 | FlintSpellingWordsList(const FlintSpellingWordsList &); |
| 33 | |
| 34 | /// Assignment is not allowed. |
| 35 | void operator=(const FlintSpellingWordsList &); |
| 36 | |
| 37 | /// Keep a reference to our database to stop it being deleted. |
| 38 | Xapian::Internal::RefCntPtr<const Xapian::Database::Internal> database; |
| 39 | |
| 40 | /** A cursor which runs through the spelling table reading termnames from |
| 41 | * the keys. |
| 42 | */ |
| 43 | FlintCursor * cursor; |
| 44 | |
| 45 | /** The term frequency of the term at the current position. |
| 46 | * |
| 47 | * If this value is zero, then we haven't read the term frequency or |
| 48 | * collection frequency for the current term yet. We need to call |
| 49 | * read_termfreq() to read these. |
| 50 | */ |
| 51 | mutable Xapian::termcount termfreq; |
| 52 | |
| 53 | /// Read and cache the term frequency. |
| 54 | void read_termfreq() const; |
| 55 | |
| 56 | public: |
| 57 | FlintSpellingWordsList(Xapian::Internal::RefCntPtr<const Xapian::Database::Internal> database_, |
| 58 | FlintCursor * cursor_) |
| 59 | : database(database_), cursor(cursor_), termfreq(0) { |
| 60 | // Seek to the entry before the first key with a "W" prefix, so the |
| 61 | // first next() will advance us to the first such entry. |
| 62 | cursor->find_entry(string("W", 1)); |
| 63 | } |
| 64 | |
| 65 | /// Destructor. |
| 66 | ~FlintSpellingWordsList(); |
| 67 | |
| 68 | /** Returns the approximate size of the list. |
| 69 | */ |
| 70 | Xapian::termcount get_approx_size() const; |
| 71 | |
| 72 | /** Returns the current termname. |
| 73 | * |
| 74 | * Either next() or skip_to() must have been called before this |
| 75 | * method can be called. |
| 76 | */ |
| 77 | string get_termname() const; |
| 78 | |
| 79 | /** Returns the term frequency of the current term. |
| 80 | * |
| 81 | * Either next() or skip_to() must have been called before this |
| 82 | * method can be called. |
| 83 | */ |
| 84 | Xapian::doccount get_termfreq() const; |
| 85 | |
| 86 | /** Returns the collection frequency of the current term. |
| 87 | * |
| 88 | * Either next() or skip_to() must have been called before this |
| 89 | * method can be called. |
| 90 | */ |
| 91 | Xapian::termcount get_collection_freq() const; |
| 92 | |
| 93 | /// Advance to the next term in the list. |
| 94 | TermList * next(); |
| 95 | |
| 96 | /// Advance to the first term which is >= tname. |
| 97 | TermList * skip_to(const string &tname); |
| 98 | |
| 99 | /// True if we're off the end of the list |
| 100 | bool at_end() const; |
| 101 | }; |
| 102 | |
| 103 | #endif /* XAPIAN_HGUARD_FLINT_SPELLINGWORDSLIST_H */ |
Note: See TracBrowser
for help on using the browser.
