1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
/** @file termlist.h
* @brief Abstract base class for termlists.
*/
/* Copyright (C) 2007,2010,2013 Olly Betts
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef XAPIAN_INCLUDED_TERMLIST_H
#define XAPIAN_INCLUDED_TERMLIST_H
#include <string>
#include <vector>
#include "xapian/intrusive_ptr.h"
#include <xapian/types.h>
#include <xapian/termiterator.h>
namespace Xapian {
class PositionIterator;
namespace Internal {
class ExpandStats;
}
}
/// Abstract base class for termlists.
class Xapian::TermIterator::Internal : public Xapian::Internal::intrusive_base {
/// Don't allow assignment.
void operator=(const Internal &);
/// Don't allow copying.
Internal(const Internal &);
protected:
/// Only constructable as a base class for derived classes.
Internal() { }
public:
/** We have virtual methods and want to be able to delete derived classes
* using a pointer to the base class, so we need a virtual destructor.
*/
virtual ~Internal();
/// Return approximate size of this termlist.
virtual Xapian::termcount get_approx_size() const = 0;
/// Collate weighting information for the current term.
virtual void accumulate_stats(Xapian::Internal::ExpandStats & stats) const;
/// Return the termname at the current position.
virtual std::string get_termname() const = 0;
/// Return the wdf for the term at the current position.
virtual Xapian::termcount get_wdf() const = 0;
/// Return the term frequency for the term at the current position.
virtual Xapian::doccount get_termfreq() const = 0;
/** Return the collection frequency for the term at the current position.
*
* This method is only implemented for subclasses of AllTermsList
* (and isn't currently used).
*/
virtual Xapian::termcount get_collection_freq() const;
/** Advance the current position to the next term in the termlist.
*
* The list starts before the first term in the list, so next()
* must be called before any methods which need the context of
* the current position.
*
* @return If a non-NULL pointer is returned, then the caller should
* substitute the returned pointer for its pointer to us, and then
* delete us. This "pruning" can only happen for a non-leaf
* subclass of this class.
*/
virtual Internal * next() = 0;
/** Skip forward to the specified term.
*
* If the specified term isn't in the list, position ourselves on the
* first term after tname (or at_end() if no terms after tname exist).
*/
virtual Internal * skip_to(const std::string &term) = 0;
/// Return true if the current position is past the last term in this list.
virtual bool at_end() const = 0;
/// Return the length of the position list for the current position.
virtual Xapian::termcount positionlist_count() const = 0;
/** Get pointer to vector<termpos> if that's the internal representation.
*
* This avoids unnecessary copying of positions in the common cases - the
* case it doesn't help with is adding a document back with unmodified
* positions *AND* a different docid, which is an unusual thing to do.
*
* @return Pointer to vector<termpos> or NULL.
*/
virtual const std::vector<Xapian::termpos> * get_vector_termpos() const;
/// Return a PositionIterator for the current position.
virtual Xapian::PositionIterator positionlist_begin() const = 0;
};
// In the external API headers, this class is Xapian::TermIterator::Internal,
// but in the library code it's still known as "TermList" in most places.
typedef Xapian::TermIterator::Internal TermList;
#endif // XAPIAN_INCLUDED_TERMLIST_H
|