LCOV - code coverage report
Current view: top level - backends/honey - honey_spellingwordslist.h (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core 954b5873a738 Lines: 4 4 100.0 %
Date: 2019-06-30 05:20:33 Functions: 1 1 100.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /** @file honey_spellingwordslist.h
       2                 :            :  * @brief A termlist containing all words which are spelling targets.
       3                 :            :  */
       4                 :            : /* Copyright (C) 2005,2008,2009,2010,2011,2017 Olly Betts
       5                 :            :  * Copyright (C) 2007 Lemur Consulting Ltd
       6                 :            :  *
       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.
      11                 :            :  *
      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.
      16                 :            :  *
      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
      20                 :            :  */
      21                 :            : 
      22                 :            : #ifndef XAPIAN_INCLUDED_HONEY_SPELLINGWORDSLIST_H
      23                 :            : #define XAPIAN_INCLUDED_HONEY_SPELLINGWORDSLIST_H
      24                 :            : 
      25                 :            : #include "backends/alltermslist.h"
      26                 :            : #include "honey_spelling.h"
      27                 :            : #include "honey_cursor.h"
      28                 :            : 
      29                 :            : class HoneyDatabase;
      30                 :            : 
      31                 :            : class HoneySpellingWordsList : public AllTermsList {
      32                 :            :     /// Copying is not allowed.
      33                 :            :     HoneySpellingWordsList(const HoneySpellingWordsList &);
      34                 :            : 
      35                 :            :     /// Assignment is not allowed.
      36                 :            :     void operator=(const HoneySpellingWordsList &);
      37                 :            : 
      38                 :            :     /// Keep a reference to our database to stop it being deleted.
      39                 :            :     Xapian::Internal::intrusive_ptr<const HoneyDatabase> database;
      40                 :            : 
      41                 :            :     /** A cursor which runs through the spelling table reading termnames from
      42                 :            :      *  the keys.
      43                 :            :      */
      44                 :            :     HoneyCursor * cursor;
      45                 :            : 
      46                 :            :     /** The term frequency of the term at the current position.
      47                 :            :      *
      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.
      51                 :            :      */
      52                 :            :     mutable Xapian::termcount termfreq;
      53                 :            : 
      54                 :            :     /// Read and cache the term frequency.
      55                 :            :     void read_termfreq() const;
      56                 :            : 
      57                 :            :   public:
      58                 :          2 :     HoneySpellingWordsList(const HoneyDatabase* database_, HoneyCursor* cursor_)
      59                 :          2 :             : database(database_), cursor(cursor_), termfreq(0) {
      60                 :            :         // Set the cursor to its end to signal we haven't started yet.  Then
      61                 :            :         // if the first action is next() we can move the cursor to the first
      62                 :            :         // word with:
      63                 :            :         //
      64                 :            :         // cursor.find_entry_ge(string(1, KEY_PREFIX_WORD));
      65                 :          2 :         cursor->to_end();
      66                 :          2 :     }
      67                 :            : 
      68                 :            :     /// Destructor.
      69                 :            :     ~HoneySpellingWordsList();
      70                 :            : 
      71                 :            :     Xapian::termcount get_approx_size() const;
      72                 :            : 
      73                 :            :     /** Returns the current termname.
      74                 :            :      *
      75                 :            :      *  Either next() or skip_to() must have been called before this
      76                 :            :      *  method can be called.
      77                 :            :      */
      78                 :            :     std::string get_termname() const;
      79                 :            : 
      80                 :            :     /** Returns the term frequency of the current term.
      81                 :            :      *
      82                 :            :      *  Either next() or skip_to() must have been called before this
      83                 :            :      *  method can be called.
      84                 :            :      */
      85                 :            :     Xapian::doccount get_termfreq() const;
      86                 :            : 
      87                 :            :     /** Returns the collection frequency of the current term.
      88                 :            :      *
      89                 :            :      *  Either next() or skip_to() must have been called before this
      90                 :            :      *  method can be called.
      91                 :            :      */
      92                 :            :     Xapian::termcount get_collection_freq() const;
      93                 :            : 
      94                 :            :     /// Advance to the next term in the list.
      95                 :            :     TermList * next();
      96                 :            : 
      97                 :            :     /// Advance to the first term which is >= term.
      98                 :            :     TermList * skip_to(const std::string& term);
      99                 :            : 
     100                 :            :     /// True if we're off the end of the list
     101                 :            :     bool at_end() const;
     102                 :            : };
     103                 :            : 
     104                 :            : #endif /* XAPIAN_INCLUDED_HONEY_SPELLINGWORDSLIST_H */

Generated by: LCOV version 1.11