scriptindex: Fix weird error cases
[xapian.git] / xapian-core / matcher / valuegepostlist.cc
blobc76b0d4ed8278058c3aea8213479d75d9e96c6f5
1 /** @file
2 * @brief Return document ids matching a range test on a specified doc value.
3 */
4 /* Copyright 2007,2008,2011,2013 Olly Betts
5 * Copyright 2008 Lemur Consulting Ltd
6 * Copyright 2010 Richard Boulton
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #include <config.h>
25 #include "valuegepostlist.h"
27 #include "omassert.h"
28 #include "str.h"
29 #include "unicode/description_append.h"
31 using namespace std;
33 PostList *
34 ValueGePostList::next(double)
36 Assert(db);
37 if (!valuelist) valuelist = db->open_value_list(slot);
38 valuelist->next();
39 while (!valuelist->at_end()) {
40 const string & v = valuelist->get_value();
41 if (v >= begin) return NULL;
42 valuelist->next();
44 db = NULL;
45 return NULL;
48 PostList *
49 ValueGePostList::skip_to(Xapian::docid did, double)
51 Assert(db);
52 if (!valuelist) valuelist = db->open_value_list(slot);
53 valuelist->skip_to(did);
54 while (!valuelist->at_end()) {
55 const string & v = valuelist->get_value();
56 if (v >= begin) return NULL;
57 valuelist->next();
59 db = NULL;
60 return NULL;
63 PostList *
64 ValueGePostList::check(Xapian::docid did, double, bool &valid)
66 Assert(db);
67 AssertRelParanoid(did, <=, db->get_lastdocid());
68 if (!valuelist) valuelist = db->open_value_list(slot);
69 valid = valuelist->check(did);
70 if (!valid) {
71 return NULL;
73 const string & v = valuelist->get_value();
74 valid = (v >= begin);
75 return NULL;
78 string
79 ValueGePostList::get_description() const
81 string desc = "ValueGePostList(";
82 desc += str(slot);
83 desc += ", ";
84 description_append(desc, begin);
85 desc += ")";
86 return desc;