xapian-core  2.0.0
msetiterator.cc
Go to the documentation of this file.
1 
4 /* Copyright (C) 2017 Olly Betts
5  *
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.
10  *
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.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, see
18  * <https://www.gnu.org/licenses/>.
19  */
20 
21 #include <config.h>
22 
23 #include "xapian/mset.h"
24 
25 #include "msetinternal.h"
26 
27 #include "debuglog.h"
28 #include "omassert.h"
29 #include "str.h"
30 
31 using namespace std;
32 
33 namespace Xapian {
34 
37 {
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());
42 }
43 
45 MSetIterator::get_document() const
46 {
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));
52 }
53 
54 double
55 MSetIterator::get_weight() const
56 {
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());
61 }
62 
63 string
64 MSetIterator::get_collapse_key() const
65 {
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());
70 }
71 
73 MSetIterator::get_collapse_count() const
74 {
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());
79 }
80 
81 string
82 MSetIterator::get_sort_key() const
83 {
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());
88 }
89 
90 std::string
91 MSetIterator::get_description() const
92 {
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);
98  }
99  desc += ')';
100  return desc;
101 }
102 
103 }
Class representing a document.
Definition: document.h:64
Debug logging macros.
#define RETURN(...)
Definition: debuglog.h:484
#define LOGCALL(CATEGORY, TYPE, FUNC, PARAMS)
Definition: debuglog.h:478
Class representing a list of search results.
Xapian::MSet internals.
string str(int value)
Convert int to std::string.
Definition: str.cc:91
The Xapian namespace contains public interfaces for the Xapian library.
Definition: compactor.cc:82
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
Definition: types.h:37
const Query operator*(double factor, const Query &q)
Scale a Xapian::Query object using OP_SCALE_WEIGHT.
Definition: query.h:827
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
Definition: types.h:51
Various assertion macros.
#define AssertRel(A, REL, B)
Definition: omassert.h:123
#define Assert(COND)
Definition: omassert.h:122
Convert types to std::string.