LCOV - lcov.info - /usr/include/xapian/expanddecider.h

LTP GCOV extension - code coverage report
Current view: | directory - usr/include/xapian - expanddecider.h
Test: | lcov.info
Date: | 2008-08-14 |  | Instrumented lines: | 1
Code covered: | 100.0 % |  | Executed lines: | 1

           1                 : /** @file expanddecider.h
           2                 :  * @brief Allow rejection of terms during ESet generation.
           3                 :  */
           4                 : /* Copyright (C) 2007 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_EXPANDDECIDER_H
          22                 : #define XAPIAN_INCLUDED_EXPANDDECIDER_H
          23                 :
          24                 : #include <set>
          25                 : #include <string>
          26                 :
          27                 : #include <xapian/visibility.h>
          28                 :
          29                 : namespace Xapian {
          30                 :
          31                 : /** Virtual base class for expand decider functor. */
          32               5 : class XAPIAN_VISIBILITY_DEFAULT ExpandDecider {
          33                 :   public:
          34                 :     /** Do we want this term in the ESet? */
          35                 :     virtual bool operator()(const std::string &term) const = 0;
          36                 :
          37                 :     /** Virtual destructor, because we have virtual methods. */
          38                 :     virtual ~ExpandDecider();
          39                 : };
          40                 :
          41                 : /** ExpandDecider subclass which rejects terms using two ExpandDeciders.
          42                 :  *
          43                 :  *  Terms are only accepted if they are accepted by both of the specified
          44                 :  *  ExpandDecider objects.
          45                 :  */
          46                 : class XAPIAN_VISIBILITY_DEFAULT ExpandDeciderAnd : public ExpandDecider {
          47                 :     const ExpandDecider &first, &second;
          48                 :
          49                 :   public:
          50                 :     /** Terms will be checked with @a first, and if accepted, then checked
          51                 :      *  with @a second.
          52                 :      */
          53                 :     ExpandDeciderAnd(const ExpandDecider &first_,
          54                 :                      const ExpandDecider &second_)
          55                 :         : first(first_), second(second_) { }
          56                 :
          57                 :     /** Compatibility method. */
          58                 :     ExpandDeciderAnd(const ExpandDecider *first_,
          59                 :                      const ExpandDecider *second_)
          60                 :         : first(*first_), second(*second_) { }
          61                 :
          62                 :     virtual bool operator()(const std::string &term) const;
          63                 : };
          64                 :
          65                 : /** ExpandDecider subclass which rejects terms in a specified list.
          66                 :  *
          67                 :  *  ExpandDeciderFilterTerms provides an easy way to filter out terms from
          68                 :  *  a fixed list when generating an ESet.
          69                 :  */
          70                 : class XAPIAN_VISIBILITY_DEFAULT ExpandDeciderFilterTerms : public ExpandDecider {
          71                 :     std::set<std::string> rejects;
          72                 :
          73                 :   public:
          74                 :     /** The two iterators specify a list of terms to be rejected.
          75                 :      *
          76                 :      *  @a reject_begin and @a reject_end can be any input_iterator type
          77                 :      *  which returns std::string or char * (e.g. TermIterator or char **).
          78                 :      */
          79                 :     template <class Iterator>
          80                 :     ExpandDeciderFilterTerms(Iterator reject_begin, Iterator reject_end)
          81                 :         : rejects(reject_begin, reject_end) { }
          82                 :
          83                 :     virtual bool operator()(const std::string &term) const;
          84                 : };
          85                 :
          86                 : }
          87                 :
          88                 : #endif // XAPIAN_INCLUDED_EXPANDDECIDER_H

Generated by: LTP GCOV extension version 1.6