2 * @brief Class for iterating over term positions.
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/positioniterator.h"
27 #include "backends/positionlist.h"
34 PositionIterator::decref()
37 if (--internal
->_refs
== 0)
41 PositionIterator::PositionIterator(Internal
*internal_
) : internal(internal_
)
43 LOGCALL_CTOR(API
, "PositionIterator", internal_
);
47 if (!internal
->next()) {
52 // The destructor only runs if the constructor completes, so we have to
53 // take care of cleaning up for ourselves here.
59 PositionIterator::PositionIterator(const PositionIterator
& o
)
60 : internal(o
.internal
)
62 LOGCALL_CTOR(API
, "PositionIterator", o
);
68 PositionIterator::operator=(const PositionIterator
& o
)
70 LOGCALL(API
, PositionIterator
&, "PositionIterator::operator=", o
);
75 internal
= o
.internal
;
80 PositionIterator::operator*() const
82 LOGCALL(API
, Xapian::termpos
, "PositionIterator::operator*", NO_ARGS
);
84 RETURN(internal
->get_position());
88 PositionIterator::operator++()
90 LOGCALL(API
, PositionIterator
&, "PositionIterator::operator++", NO_ARGS
);
92 if (!internal
->next()) {
100 PositionIterator::skip_to(Xapian::termpos pos
)
102 LOGCALL_VOID(API
, "PositionIterator::skip_to", pos
);
104 if (!internal
->skip_to(pos
)) {
112 PositionIterator::get_description() const
114 #if 0 // FIXME: Add PositionIterator::Internal::get_description() method.
115 string desc
= "PositionIterator(";
117 desc
+= internal
->get_description();
121 return "PositionIterator()";