Regenerate version.h when version_h.cc changes
[xapian.git] / xapian-core / backends / contiguousalldocspostlist.cc
blob45d02c9a70f668154b7b12ce430058ef0442de55
1 /** @file contiguousalldocspostlist.cc
2 * @brief Iterate all document ids when they form a contiguous range.
3 */
4 /* Copyright (C) 2007,2008,2009,2011 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 <string>
25 #include "contiguousalldocspostlist.h"
27 #include "omassert.h"
28 #include "str.h"
30 using namespace std;
32 Xapian::doccount
33 ContiguousAllDocsPostList::get_termfreq() const
35 return doccount;
38 Xapian::docid
39 ContiguousAllDocsPostList::get_docid() const
41 Assert(did != 0);
42 Assert(!at_end());
43 return did;
46 Xapian::termcount
47 ContiguousAllDocsPostList::get_doclength() const
49 Assert(did != 0);
50 Assert(!at_end());
51 return db->get_doclength(did);
54 Xapian::termcount
55 ContiguousAllDocsPostList::get_unique_terms() const
57 Assert(did != 0);
58 Assert(!at_end());
59 return db->get_unique_terms(did);
62 Xapian::termcount
63 ContiguousAllDocsPostList::get_wdf() const
65 Assert(did != 0);
66 Assert(!at_end());
67 return 1;
70 PositionList *
71 ContiguousAllDocsPostList::read_position_list()
73 // Throws the same exception.
74 return ContiguousAllDocsPostList::open_position_list();
77 PositionList *
78 ContiguousAllDocsPostList::open_position_list() const
80 throw Xapian::InvalidOperationError("Position lists not meaningful for ContiguousAllDocsPostList");
83 PostList *
84 ContiguousAllDocsPostList::next(double)
86 Assert(!at_end());
87 if (did == doccount) {
88 db = NULL;
89 } else {
90 ++did;
92 return NULL;
95 PostList *
96 ContiguousAllDocsPostList::skip_to(Xapian::docid target, double)
98 Assert(!at_end());
99 if (target > did) {
100 if (target > doccount) {
101 db = NULL;
102 } else {
103 did = target;
106 return NULL;
109 bool
110 ContiguousAllDocsPostList::at_end() const
112 return db.get() == NULL;
115 string
116 ContiguousAllDocsPostList::get_description() const
118 string msg("ContiguousAllDocsPostList(1..");
119 msg += str(doccount);
120 msg += ')';
121 return msg;