1 /** @file postingiterator.cc
2 * @brief Class for iterating over a list of document ids.
4 /* Copyright (C) 2008,2009,2010,2011,2013,2017 Olly Betts
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (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 USA
23 #include "xapian/postingiterator.h"
25 #include "api/postingiteratorinternal.h"
35 PostingIterator::decref()
38 if (--internal
->_refs
== 0)
42 PostingIterator::PostingIterator(Internal
*internal_
) : internal(internal_
)
44 LOGCALL_CTOR(API
, "PostingIterator", internal_
);
45 if (!internal
) return;
48 if (!internal
->next()) {
53 // The destructor only runs if the constructor completes, so we have to
54 // take care of cleaning up for ourselves here.
60 PostingIterator::PostingIterator(const PostingIterator
& o
)
61 : internal(o
.internal
)
63 LOGCALL_CTOR(API
, "PostingIterator", o
);
69 PostingIterator::operator=(const PostingIterator
& o
)
71 LOGCALL(API
, PostingIterator
&, "PostingIterator::operator=", o
);
76 internal
= o
.internal
;
81 PostingIterator::operator*() const
83 LOGCALL(API
, Xapian::docid
, "PostingIterator::operator*", NO_ARGS
);
85 RETURN(internal
->get_docid());
89 PostingIterator::operator++()
91 LOGCALL(API
, PostingIterator
&, "PostingIterator::operator++", NO_ARGS
);
93 if (!internal
->next()) {
101 PostingIterator::get_wdf() const
103 LOGCALL(API
, Xapian::termcount
, "PostingIterator::get_wdf", NO_ARGS
);
105 RETURN(internal
->get_wdf());
109 PostingIterator::get_doclength() const
111 LOGCALL(API
, Xapian::termcount
, "PostingIterator::get_doclength", NO_ARGS
);
113 RETURN(internal
->get_doclength());
117 PostingIterator::get_unique_terms() const
119 LOGCALL(API
, Xapian::termcount
, "PostingIterator::get_unique_terms", NO_ARGS
);
121 RETURN(internal
->get_unique_terms());
124 #if 0 // FIXME: TermIterator supports this, so PostingIterator really ought to.
126 PostingIterator::positionlist_count() const
128 LOGCALL(API
, Xapian::termcount
, "PostingIterator::positionlist_count", NO_ARGS
);
130 RETURN(internal
->positionlist_count());
135 PostingIterator::positionlist_begin() const
137 LOGCALL(API
, PositionIterator
, "PostingIterator::positionlist_begin", NO_ARGS
);
139 RETURN(PositionIterator(internal
->open_position_list()));
143 PostingIterator::skip_to(Xapian::docid did
)
145 LOGCALL_VOID(API
, "PostingIterator::skip_to", did
);
147 if (!internal
->skip_to(did
)) {
155 PostingIterator::get_description() const
157 string desc
= "PostingIterator(";
159 desc
+= internal
->get_description();