3 * Copyright 1999,2000,2001 BrightStation PLC
4 * Copyright 2002,2003,2004,2005,2006,2007,2008,2010 Olly Betts
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.
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.
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
22 #ifndef OM_HGUARD_MAPTERMLIST_H
23 #define OM_HGUARD_MAPTERMLIST_H
27 #include "inmemory_positionlist.h"
34 class MapTermList
: public TermList
{
36 Xapian::Document::Internal::document_terms::const_iterator it
;
37 Xapian::Document::Internal::document_terms::const_iterator it_end
;
41 MapTermList(const Xapian::Document::Internal::document_terms::const_iterator
&it_
,
42 const Xapian::Document::Internal::document_terms::const_iterator
&it_end_
)
43 : it(it_
), it_end(it_end_
), started(false)
46 // Gets size of termlist
47 Xapian::termcount
get_approx_size() const {
48 // This method shouldn't get called on a MapTermList.
53 // Gets current termname
54 string
get_termname() const {
60 // Get wdf of current term
61 Xapian::termcount
get_wdf() const {
64 return it
->second
.wdf
;
67 // Get num of docs indexed by term
68 Xapian::doccount
get_termfreq() const {
69 throw Xapian::InvalidOperationError("Can't get term frequency from a document termlist which is not associated with a database.");
72 Xapian::PositionIterator
positionlist_begin() const {
73 return Xapian::PositionIterator(new InMemoryPositionList(it
->second
.positions
));
76 Xapian::termcount
positionlist_count() const {
77 return it
->second
.positions
.size();
90 TermList
* skip_to(const std::string
& term
) {
91 while (it
!= it_end
&& it
->first
< term
) {
98 // True if we're off the end of the list
105 #endif /* OM_HGUARD_MAPTERMLIST_H */