Make testsuite fd leak check work on more platforms
[xapian.git] / xapian-core / api / msetiterator.cc
blobdcad674e7797d80114db1589244eeab11100241b
1 /** @file msetiterator.cc
2 * @brief Iterator over a Xapian::MSet.
3 */
4 /* Copyright (C) 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
21 #include <config.h>
23 #include "xapian/mset.h"
25 #include "msetinternal.h"
27 #include "debuglog.h"
28 #include "omassert.h"
29 #include "str.h"
31 using namespace std;
33 namespace Xapian {
35 Xapian::docid
36 MSetIterator::operator*() const
38 LOGCALL(API, Xapian::docid, "MSetIterator::operator*", NO_ARGS);
39 Assert(off_from_end != 0);
40 AssertRel(off_from_end, <=, mset.internal->items.size());
41 RETURN((mset.internal->items.end() - off_from_end)->get_docid());
44 Xapian::Document
45 MSetIterator::get_document() const
47 LOGCALL(API, Xapian::Document, "MSetIterator::get_document", NO_ARGS);
48 auto size = mset.internal->items.size();
49 Assert(off_from_end != 0);
50 AssertRel(off_from_end, <=, size);
51 RETURN(mset.internal->get_document(size - off_from_end));
54 double
55 MSetIterator::get_weight() const
57 LOGCALL(API, double, "MSetIterator::get_weight", NO_ARGS);
58 Assert(off_from_end != 0);
59 AssertRel(off_from_end, <=, mset.internal->items.size());
60 RETURN((mset.internal->items.end() - off_from_end)->get_weight());
63 string
64 MSetIterator::get_collapse_key() const
66 LOGCALL(API, string, "MSetIterator::get_collapse_key", NO_ARGS);
67 Assert(off_from_end != 0);
68 AssertRel(off_from_end, <=, mset.internal->items.size());
69 RETURN((mset.internal->items.end() - off_from_end)->get_collapse_key());
72 Xapian::doccount
73 MSetIterator::get_collapse_count() const
75 LOGCALL(API, Xapian::doccount, "MSetIterator::get_collapse_count", NO_ARGS);
76 Assert(off_from_end != 0);
77 AssertRel(off_from_end, <=, mset.internal->items.size());
78 RETURN((mset.internal->items.end() - off_from_end)->get_collapse_count());
81 string
82 MSetIterator::get_sort_key() const
84 LOGCALL(API, string, "MSetIterator::get_sort_key", NO_ARGS);
85 Assert(off_from_end != 0);
86 AssertRel(off_from_end, <=, mset.internal->items.size());
87 RETURN((mset.internal->items.end() - off_from_end)->get_sort_key());
90 std::string
91 MSetIterator::get_description() const
93 string desc = "MSetIterator(";
94 if (off_from_end == 0) {
95 desc += "end";
96 } else {
97 desc += str(mset.internal->items.size() - off_from_end);
99 desc += ')';
100 return desc;