Couchbase C++ SDK 1.0.2 (rev. 51f4775)
Loading...
Searching...
No Matches
date_range_query.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 * Copyright 2023-Present Couchbase, Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#pragma once
19
22
23#include <chrono>
24#include <cstdint>
25#include <ctime>
26#include <optional>
27#include <string>
28
29namespace couchbase
30{
49{
50public:
62 auto start(std::chrono::system_clock::time_point value) -> date_range_query&;
63
75 auto start(std::tm value) -> date_range_query&;
76
89 auto start(std::chrono::system_clock::time_point value, bool inclusive) -> date_range_query&;
90
103 auto start(std::tm value, bool inclusive) -> date_range_query&;
104
116 auto start(std::string value) -> date_range_query&
117 {
118 start_ = std::move(value);
119 return *this;
120 }
121
134 auto start(std::string value, bool inclusive) -> date_range_query&
135 {
136 start_ = std::move(value);
137 inclusive_start_ = inclusive;
138 return *this;
139 }
140
152 auto end(std::chrono::system_clock::time_point value) -> date_range_query&;
153
165 auto end(std::tm value) -> date_range_query&;
166
179 auto end(std::chrono::system_clock::time_point value, bool inclusive) -> date_range_query&;
180
193 auto end(std::tm value, bool inclusive) -> date_range_query&;
194
206 auto end(std::string value)
207 {
208 end_ = std::move(value);
209 return *this;
210 }
211
224 auto end(std::string value, bool inclusive) -> date_range_query&
225 {
226 end_ = std::move(value);
227 inclusive_end_ = inclusive;
228 return *this;
229 }
230
241 auto date_time_parser(std::string parser_name) -> date_range_query&
242 {
243 date_time_parser_ = std::move(parser_name);
244 return *this;
245 }
246
257 auto field(std::string field_name) -> date_range_query&
258 {
259 field_ = std::move(field_name);
260 return *this;
261 }
262
269 [[nodiscard]] auto encode() const -> encoded_search_query override;
270
271private:
272 std::optional<std::string> start_{};
273 std::optional<std::string> end_{};
274 std::optional<bool> inclusive_start_{};
275 std::optional<bool> inclusive_end_{};
276 std::optional<std::string> date_time_parser_{};
277 std::optional<std::string> field_{};
278};
279} // namespace couchbase
The date range query finds documents containing a date value in the specified field within the specif...
Definition date_range_query.hxx:49
auto start(std::chrono::system_clock::time_point value) -> date_range_query &
Set lower limit and automatically format so that default date_time parser will be able to parse it on...
auto end(std::chrono::system_clock::time_point value) -> date_range_query &
Set upper limit and automatically format so that default date_time parser will be able to parse it on...
auto end(std::string value, bool inclusive) -> date_range_query &
Set preformatted date as upper limit.
Definition date_range_query.hxx:224
auto end(std::string value)
Set preformatted date as upper limit.
Definition date_range_query.hxx:206
auto end(std::chrono::system_clock::time_point value, bool inclusive) -> date_range_query &
Set upper limit and automatically format so that default date_time parser will be able to parse it on...
auto start(std::tm value, bool inclusive) -> date_range_query &
Set lower limit and automatically format so that default date_time parser will be able to parse it on...
auto field(std::string field_name) -> date_range_query &
If a field is specified, only terms in that field will be matched.
Definition date_range_query.hxx:257
auto encode() const -> encoded_search_query override
auto date_time_parser(std::string parser_name) -> date_range_query &
Enable custom date parser.
Definition date_range_query.hxx:241
auto end(std::tm value) -> date_range_query &
Set upper limit and automatically format so that default date_time parser will be able to parse it on...
auto start(std::string value, bool inclusive) -> date_range_query &
Set preformatted date as lower limit.
Definition date_range_query.hxx:134
auto start(std::tm value) -> date_range_query &
Set lower limit and automatically format so that default date_time parser will be able to parse it on...
auto start(std::chrono::system_clock::time_point value, bool inclusive) -> date_range_query &
Set lower limit and automatically format so that default date_time parser will be able to parse it on...
auto end(std::tm value, bool inclusive) -> date_range_query &
Set upper limit and automatically format so that default date_time parser will be able to parse it on...
auto start(std::string value) -> date_range_query &
Set preformatted date as lower limit.
Definition date_range_query.hxx:116
Base class for full text search queries.
Definition search_query.hxx:33
Represents a single item from the result of collection::scan()
Definition allow_querying_search_index_options.hxx:28