LCOV - code coverage report
Current view: top level - backends/chert - chert_spellingwordslist.h (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core r Lines: 4 4 100.0 %
Date: 2011-08-21 Functions: 1 1 100.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* chert_spellingwordslist.h: A termlist containing all words which are spelling targets.
       2                 :            :  *
       3                 :            :  * Copyright (C) 2005,2008 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_CHERT_SPELLINGWORDSLIST_H
      22                 :            : #define XAPIAN_HGUARD_CHERT_SPELLINGWORDSLIST_H
      23                 :            : 
      24                 :            : #include "alltermslist.h"
      25                 :            : #include "database.h"
      26                 :            : #include "chert_spelling.h"
      27                 :            : 
      28                 :            : class ChertCursor;
      29                 :            : 
      30                 :            : class ChertSpellingWordsList : public AllTermsList {
      31                 :            :     /// Copying is not allowed.
      32                 :            :     ChertSpellingWordsList(const ChertSpellingWordsList &);
      33                 :            : 
      34                 :            :     /// Assignment is not allowed.
      35                 :            :     void operator=(const ChertSpellingWordsList &);
      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                 :            :     ChertCursor * 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                 :          5 :     ChertSpellingWordsList(Xapian::Internal::RefCntPtr<const Xapian::Database::Internal> database_,
      58                 :            :                            ChertCursor * cursor_)
      59                 :          5 :             : 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                 :          5 :         cursor->find_entry(std::string("W", 1));
      63                 :          5 :     }
      64                 :            : 
      65                 :            :     /// Destructor.
      66                 :            :     ~ChertSpellingWordsList();
      67                 :            : 
      68                 :            :     /** Returns the current termname.
      69                 :            :      *
      70                 :            :      *  Either next() or skip_to() must have been called before this
      71                 :            :      *  method can be called.
      72                 :            :      */
      73                 :            :     std::string get_termname() const;
      74                 :            : 
      75                 :            :     /** Returns the term frequency of the current term.
      76                 :            :      *
      77                 :            :      *  Either next() or skip_to() must have been called before this
      78                 :            :      *  method can be called.
      79                 :            :      */
      80                 :            :     Xapian::doccount get_termfreq() const;
      81                 :            : 
      82                 :            :     /** Returns the collection frequency of the current term.
      83                 :            :      *
      84                 :            :      *  Either next() or skip_to() must have been called before this
      85                 :            :      *  method can be called.
      86                 :            :      */
      87                 :            :     Xapian::termcount get_collection_freq() const;
      88                 :            : 
      89                 :            :     /// Advance to the next term in the list.
      90                 :            :     TermList * next();
      91                 :            : 
      92                 :            :     /// Advance to the first term which is >= tname.
      93                 :            :     TermList * skip_to(const std::string &tname);
      94                 :            : 
      95                 :            :     /// True if we're off the end of the list
      96                 :            :     bool at_end() const;
      97                 :            : };
      98                 :            : 
      99                 :            : #endif /* XAPIAN_HGUARD_CHERT_SPELLINGWORDSLIST_H */

Generated by: LCOV version 1.8