LCOV - code coverage report
Current view: top level - backends/glass - glass_spellingwordslist.h (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core fcfb185a9dd5 Lines: 4 4 100.0 %
Date: 2019-04-18 16:33:14 Functions: 1 1 100.0 %
Branches: 2 4 50.0 %

           Branch data     Line data    Source code
       1                 :            : /** @file glass_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_GLASS_SPELLINGWORDSLIST_H
      23                 :            : #define XAPIAN_INCLUDED_GLASS_SPELLINGWORDSLIST_H
      24                 :            : 
      25                 :            : #include "backends/alltermslist.h"
      26                 :            : #include "glass_spelling.h"
      27                 :            : #include "glass_cursor.h"
      28                 :            : 
      29                 :            : class GlassDatabase;
      30                 :            : 
      31                 :            : class GlassSpellingWordsList : public AllTermsList {
      32                 :            :     /// Copying is not allowed.
      33                 :            :     GlassSpellingWordsList(const GlassSpellingWordsList &);
      34                 :            : 
      35                 :            :     /// Assignment is not allowed.
      36                 :            :     void operator=(const GlassSpellingWordsList &);
      37                 :            : 
      38                 :            :     /// Keep a reference to our database to stop it being deleted.
      39                 :            :     Xapian::Internal::intrusive_ptr<const GlassDatabase> database;
      40                 :            : 
      41                 :            :     /** A cursor which runs through the spelling table reading termnames from
      42                 :            :      *  the keys.
      43                 :            :      */
      44                 :            :     GlassCursor * 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                 :          8 :     GlassSpellingWordsList(Xapian::Internal::intrusive_ptr<const GlassDatabase> database_,
      59                 :            :                            GlassCursor * cursor_)
      60                 :          8 :             : 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 [ +  - ][ +  - ]:          8 :         cursor->find_entry(std::string("W", 1));
      64                 :          8 :     }
      65                 :            : 
      66                 :            :     /// Destructor.
      67                 :            :     ~GlassSpellingWordsList();
      68                 :            : 
      69                 :            :     Xapian::termcount get_approx_size() const;
      70                 :            : 
      71                 :            :     /** Returns the current termname.
      72                 :            :      *
      73                 :            :      *  Either next() or skip_to() must have been called before this
      74                 :            :      *  method can be called.
      75                 :            :      */
      76                 :            :     std::string get_termname() const;
      77                 :            : 
      78                 :            :     /** Returns the term frequency of the current term.
      79                 :            :      *
      80                 :            :      *  Either next() or skip_to() must have been called before this
      81                 :            :      *  method can be called.
      82                 :            :      */
      83                 :            :     Xapian::doccount get_termfreq() const;
      84                 :            : 
      85                 :            :     /** Returns the collection frequency of the current term.
      86                 :            :      *
      87                 :            :      *  Either next() or skip_to() must have been called before this
      88                 :            :      *  method can be called.
      89                 :            :      */
      90                 :            :     Xapian::termcount get_collection_freq() const;
      91                 :            : 
      92                 :            :     /// Advance to the next term in the list.
      93                 :            :     TermList * next();
      94                 :            : 
      95                 :            :     /// Advance to the first term which is >= tname.
      96                 :            :     TermList * skip_to(const std::string &tname);
      97                 :            : 
      98                 :            :     /// True if we're off the end of the list
      99                 :            :     bool at_end() const;
     100                 :            : };
     101                 :            : 
     102                 :            : #endif /* XAPIAN_INCLUDED_GLASS_SPELLINGWORDSLIST_H */

Generated by: LCOV version 1.11