2 * @brief Class for iterating over a list of terms.
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/termiterator.h"
34 TermIterator::decref()
37 if (--internal
->_refs
== 0)
42 TermIterator::post_advance(Internal
* res
)
45 // This can happen with iterating allterms from multiple databases.
50 if (internal
->at_end()) {
56 TermIterator::TermIterator(Internal
*internal_
) : internal(internal_
)
58 LOGCALL_CTOR(API
, "TermIterator", internal_
);
59 if (!internal
) return;
62 post_advance(internal
->next());
64 // The destructor only runs if the constructor completes, so we have to
65 // take care of cleaning up for ourselves here.
71 TermIterator::TermIterator(const TermIterator
& o
)
72 : internal(o
.internal
)
74 LOGCALL_CTOR(API
, "TermIterator", o
);
80 TermIterator::operator=(const TermIterator
& o
)
82 LOGCALL(API
, TermIterator
&, "TermIterator::operator=", o
);
87 internal
= o
.internal
;
92 TermIterator::operator*() const
94 LOGCALL(API
, string
, "TermIterator::operator*", NO_ARGS
);
96 RETURN(internal
->get_termname());
100 TermIterator::operator++()
102 LOGCALL(API
, TermIterator
&, "TermIterator::operator++", NO_ARGS
);
104 post_advance(internal
->next());
109 TermIterator::get_wdf() const
111 LOGCALL(API
, Xapian::termcount
, "TermIterator::get_wdf", NO_ARGS
);
113 RETURN(internal
->get_wdf());
117 TermIterator::get_termfreq() const
119 LOGCALL(API
, Xapian::doccount
, "TermIterator::get_termfreq", NO_ARGS
);
121 RETURN(internal
->get_termfreq());
125 TermIterator::positionlist_count() const
127 LOGCALL(API
, Xapian::termcount
, "TermIterator::positionlist_count", NO_ARGS
);
129 RETURN(internal
->positionlist_count());
133 TermIterator::positionlist_begin() const
135 LOGCALL(API
, PositionIterator
, "TermIterator::positionlist_begin", NO_ARGS
);
137 RETURN(internal
->positionlist_begin());
141 TermIterator::skip_to(const string
& term
)
143 LOGCALL_VOID(API
, "TermIterator::skip_to", term
);
145 post_advance(internal
->skip_to(term
));
149 TermIterator::get_description() const
151 #if 0 // FIXME: Add TermIterator::Internal::get_description() method.
152 string desc
= "TermIterator(";
154 desc
+= internal
->get_description();
158 return "TermIterator()";