LCOV - code coverage report
Current view: top level - api - termlist.h (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core 954b5873a738 Lines: 1 1 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 termlist.h
       2                 :            :  * @brief Abstract base class for termlists.
       3                 :            :  */
       4                 :            : /* Copyright (C) 2007,2010,2013 Olly Betts
       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_INCLUDED_TERMLIST_H
      22                 :            : #define XAPIAN_INCLUDED_TERMLIST_H
      23                 :            : 
      24                 :            : #include "api/smallvector.h"
      25                 :            : 
      26                 :            : #include "backends/positionlist.h"
      27                 :            : 
      28                 :            : #include <string>
      29                 :            : 
      30                 :            : #include "xapian/intrusive_ptr.h"
      31                 :            : #include <xapian/types.h>
      32                 :            : #include <xapian/termiterator.h>
      33                 :            : 
      34                 :            : namespace Xapian {
      35                 :            :     namespace Internal {
      36                 :            :         class ExpandStats;
      37                 :            :     }
      38                 :            : }
      39                 :            : 
      40                 :            : /// Abstract base class for termlists.
      41                 :            : class Xapian::TermIterator::Internal : public Xapian::Internal::intrusive_base {
      42                 :            :     /// Don't allow assignment.
      43                 :            :     void operator=(const Internal &) = delete;
      44                 :            : 
      45                 :            :     /// Don't allow copying.
      46                 :            :     Internal(const Internal &) = delete;
      47                 :            : 
      48                 :            :   protected:
      49                 :            :     /// Only constructable as a base class for derived classes.
      50                 :    1515842 :     Internal() { }
      51                 :            : 
      52                 :            :   public:
      53                 :            :     /** We have virtual methods and want to be able to delete derived classes
      54                 :            :      *  using a pointer to the base class, so we need a virtual destructor.
      55                 :            :      */
      56                 :            :     virtual ~Internal();
      57                 :            : 
      58                 :            :     /// Return approximate size of this termlist.
      59                 :            :     virtual Xapian::termcount get_approx_size() const = 0;
      60                 :            : 
      61                 :            :     /// Collate weighting information for the current term.
      62                 :            :     virtual void accumulate_stats(Xapian::Internal::ExpandStats & stats) const;
      63                 :            : 
      64                 :            :     /// Return the termname at the current position.
      65                 :            :     virtual std::string get_termname() const = 0;
      66                 :            : 
      67                 :            :     /// Return the wdf for the term at the current position.
      68                 :            :     virtual Xapian::termcount get_wdf() const = 0;
      69                 :            : 
      70                 :            :     /// Return the term frequency for the term at the current position.
      71                 :            :     virtual Xapian::doccount get_termfreq() const = 0;
      72                 :            : 
      73                 :            :     /** Advance the current position to the next term in the termlist.
      74                 :            :      *
      75                 :            :      *  The list starts before the first term in the list, so next(), skip_to()
      76                 :            :      *  or check() must be called before any methods which need the context of
      77                 :            :      *  the current position.
      78                 :            :      *
      79                 :            :      *  @return If a non-NULL pointer is returned, then the caller should
      80                 :            :      *          substitute the returned pointer for its pointer to us, and then
      81                 :            :      *          delete us.  This "pruning" can only happen for a non-leaf
      82                 :            :      *          subclass of this class.
      83                 :            :      */
      84                 :            :     virtual Internal * next() = 0;
      85                 :            : 
      86                 :            :     /** Skip forward to the specified term.
      87                 :            :      *
      88                 :            :      *  If the specified term isn't in the list, position ourselves on the
      89                 :            :      *  first term after tname (or at_end() if no terms after tname exist).
      90                 :            :      */
      91                 :            :     virtual Internal * skip_to(const std::string &term) = 0;
      92                 :            : 
      93                 :            :     /// Return true if the current position is past the last term in this list.
      94                 :            :     virtual bool at_end() const = 0;
      95                 :            : 
      96                 :            :     /// Return the length of the position list for the current position.
      97                 :            :     virtual Xapian::termcount positionlist_count() const = 0;
      98                 :            : 
      99                 :            :     /** Get pointer to VecCOW<termpos> if that's the internal representation.
     100                 :            :      *
     101                 :            :      *  This avoids unnecessary copying of positions in the common cases - the
     102                 :            :      *  case it doesn't help with is adding a document back with unmodified
     103                 :            :      *  positions *AND* a different docid, which is an unusual thing to do.
     104                 :            :      *
     105                 :            :      *  @return Pointer to VecCOW<termpos> or NULL.
     106                 :            :      */
     107                 :            :     virtual const Xapian::VecCOW<Xapian::termpos> * get_vec_termpos() const;
     108                 :            : 
     109                 :            :     /// Return PositionList for the current position.
     110                 :            :     virtual PositionList* positionlist_begin() const = 0;
     111                 :            : };
     112                 :            : 
     113                 :            : // In the external API headers, this class is Xapian::TermIterator::Internal,
     114                 :            : // but in the library code it's still known as "TermList" in most places.
     115                 :            : typedef Xapian::TermIterator::Internal TermList;
     116                 :            : 
     117                 :            : #endif // XAPIAN_INCLUDED_TERMLIST_H

Generated by: LCOV version 1.11