2 * @brief Class for iterating over document values.
4 /* Copyright (C) 2008,2009,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/valueiterator.h"
27 #include "backends/valuelist.h"
34 ValueIterator::decref()
37 if (--internal
->_refs
== 0)
41 ValueIterator::ValueIterator(Internal
*internal_
) : internal(internal_
)
43 LOGCALL_CTOR(API
, "ValueIterator", internal_
);
49 // The destructor only runs if the constructor completes, so we have to
50 // take care of cleaning up for ourselves here.
54 if (internal
->at_end()) {
60 ValueIterator::ValueIterator(const ValueIterator
& o
)
61 : internal(o
.internal
)
63 LOGCALL_CTOR(API
, "ValueIterator", o
);
69 ValueIterator::operator=(const ValueIterator
& o
)
71 LOGCALL(API
, ValueIterator
&, "ValueIterator::operator=", o
);
76 internal
= o
.internal
;
81 ValueIterator::operator*() const
83 LOGCALL(API
, string
, "ValueIterator::operator*", NO_ARGS
);
85 RETURN(internal
->get_value());
89 ValueIterator::operator++()
91 LOGCALL(API
, ValueIterator
&, "ValueIterator::operator++", NO_ARGS
);
94 if (internal
->at_end()) {
102 ValueIterator::get_docid() const
104 LOGCALL(API
, Xapian::docid
, "ValueIterator::get_docid", NO_ARGS
);
106 RETURN(internal
->get_docid());
110 ValueIterator::get_valueno() const
112 LOGCALL(API
, Xapian::valueno
, "ValueIterator::get_valueno", NO_ARGS
);
114 RETURN(internal
->get_valueno());
118 ValueIterator::skip_to(Xapian::docid docid_or_slot
)
120 LOGCALL_VOID(API
, "ValueIterator::skip_to", docid_or_slot
);
122 internal
->skip_to(docid_or_slot
);
123 if (internal
->at_end()) {
131 ValueIterator::check(Xapian::docid did
)
133 LOGCALL(API
, bool, "ValueIterator::check", did
);
135 if (!internal
->check(did
)) RETURN(false);
136 if (internal
->at_end()) {
145 ValueIterator::get_description() const
147 string desc
= "ValueIterator(";
149 desc
+= internal
->get_description();