1 /** @file postingiterator.cc
2 * @brief Class for iterating over a list of document ids.
4 /* Copyright (C) 2008,2009,2010,2011,2013 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"
34 PostingIterator::decref()
37 if (--internal
->_refs
== 0)
42 PostingIterator::post_advance(Internal
* res
)
45 // FIXME: It seems this can't happen for any PostList which we wrap
46 // with PostingIterator.
51 if (internal
->at_end()) {
57 PostingIterator::PostingIterator(Internal
*internal_
) : internal(internal_
)
59 LOGCALL_CTOR(API
, "PostingIterator", internal_
);
60 if (!internal
) return;
63 post_advance(internal
->next());
65 // The destructor only runs if the constructor completes, so we have to
66 // take care of cleaning up for ourselves here.
72 PostingIterator::PostingIterator(const PostingIterator
& o
)
73 : internal(o
.internal
)
75 LOGCALL_CTOR(API
, "PostingIterator", o
);
81 PostingIterator::operator=(const PostingIterator
& o
)
83 LOGCALL(API
, PostingIterator
&, "PostingIterator::operator=", o
);
88 internal
= o
.internal
;
93 PostingIterator::operator*() const
95 LOGCALL(API
, Xapian::docid
, "PostingIterator::operator*", NO_ARGS
);
97 RETURN(internal
->get_docid());
101 PostingIterator::operator++()
103 LOGCALL(API
, PostingIterator
&, "PostingIterator::operator++", NO_ARGS
);
105 post_advance(internal
->next());
110 PostingIterator::get_wdf() const
112 LOGCALL(API
, Xapian::termcount
, "PostingIterator::get_wdf", NO_ARGS
);
114 RETURN(internal
->get_wdf());
118 PostingIterator::get_doclength() const
120 LOGCALL(API
, Xapian::termcount
, "PostingIterator::get_doclength", NO_ARGS
);
122 RETURN(internal
->get_doclength());
126 PostingIterator::get_unique_terms() const
128 LOGCALL(API
, Xapian::termcount
, "PostingIterator::get_unique_terms", NO_ARGS
);
130 RETURN(internal
->get_unique_terms());
133 #if 0 // FIXME: TermIterator supports this, so PostingIterator really ought to.
135 PostingIterator::positionlist_count() const
137 LOGCALL(API
, Xapian::termcount
, "PostingIterator::positionlist_count", NO_ARGS
);
139 RETURN(internal
->positionlist_count());
144 PostingIterator::positionlist_begin() const
146 LOGCALL(API
, PositionIterator
, "PostingIterator::positionlist_begin", NO_ARGS
);
148 RETURN(PositionIterator(internal
->open_position_list()));
152 PostingIterator::skip_to(Xapian::docid did
)
154 LOGCALL_VOID(API
, "PostingIterator::skip_to", did
);
156 post_advance(internal
->skip_to(did
));
160 PostingIterator::get_description() const
162 string desc
= "PostingIterator(";
164 desc
+= internal
->get_description();