1 /* lastmod-fp.cc - lastmod range query glue
3 * This file is part of notmuch.
5 * Copyright © 2022 David Bremner
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see https://www.gnu.org/licenses/ .
20 * Author: David Bremner <david@tethera.net>
23 #include "database-private.h"
26 _notmuch_lastmod_strings_to_query (notmuch_database_t *notmuch,
27 const std::string &from, const std::string &to,
28 Xapian::Query &output, std::string &msg)
30 long from_idx = 0L, to_idx = LONG_MAX;
34 /* revision should not change, but for the avoidance of doubt,
35 * grab for both ends of range, if needed*/
36 current = notmuch_database_get_revision (notmuch, NULL);
42 from_idx = std::stol (from);
43 } catch (std::logic_error &e) {
44 msg = "bad 'from' revision: '" + from + "'";
45 return NOTMUCH_STATUS_BAD_QUERY_SYNTAX;
52 if (EMPTY_STRING (to))
55 to_idx = std::stol (to);
56 } catch (std::logic_error &e) {
57 msg = "bad 'to' revision: '" + to + "'";
58 return NOTMUCH_STATUS_BAD_QUERY_SYNTAX;
64 output = Xapian::Query (Xapian::Query::OP_VALUE_RANGE, NOTMUCH_VALUE_LAST_MOD,
65 Xapian::sortable_serialise (from_idx),
66 Xapian::sortable_serialise (to_idx));
67 return NOTMUCH_STATUS_SUCCESS;