MongoDB C++ Driver 4.2.0
Loading...
Searching...
No Matches
range.hpp
Go to the documentation of this file.
1// Copyright 2009-present MongoDB, Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include <mongocxx/options/range-fwd.hpp> // IWYU pragma: export
18
19//
20
22
23#include <mongocxx/v1/range_options.hpp> // IWYU pragma: export
24
25#include <cstdint>
26#include <utility>
27
29#include <bsoncxx/types.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
32
34
35namespace mongocxx {
36namespace v_noabi {
37namespace options {
38
51class range {
52 public:
56 range() = default;
57
61 /* explicit(false) */ MONGOCXX_ABI_EXPORT_CDECL() range(v1::range_options opts);
62
66 explicit operator v1::range_options() const {
68
69 if (_min) {
71 }
72
73 if (_max) {
75 }
76
77 if (_sparsity) {
78 ret.sparsity(*_sparsity);
79 }
80
81 if (_trim_factor) {
82 ret.trim_factor(*_trim_factor);
83 }
84
85 if (_precision) {
86 ret.precision(*_precision);
87 }
88
89 return ret;
90 }
91
95 _min = value.view();
96 return *this;
97 }
98
104
108 _max = value.view();
109 return *this;
110 }
111
117
119 range& sparsity(std::int64_t value) {
120 _sparsity = value;
121 return *this;
122 }
123
126 return _sparsity;
127 }
128
130 range& trim_factor(std::int32_t value) {
131 _trim_factor = value;
132 return *this;
133 }
134
137 return _trim_factor;
138 }
139
142 range& precision(std::int32_t value) {
143 _precision = value;
144 return *this;
145 }
146
150 return _precision;
151 }
152
153 private:
159};
160
161} // namespace options
162} // namespace v_noabi
163} // namespace mongocxx
164
165namespace mongocxx {
166namespace v_noabi {
167
172 return {std::move(v)};
173}
174
181
182} // namespace v_noabi
183} // namespace mongocxx
184
186
A polyfill for std::optional<T>.
Definition optional.hpp:799
A union of BSON type values.
Definition value.hpp:54
v_noabi::types::bson_value::view view() const noexcept
Get a view over the bson_value owned by this object.
Definition value.hpp:323
range()=default
Default initialization.
Options related to range_options queries for Queryable Encryption.
Definition range_options.hpp:51
range_options & max(bsoncxx::v1::types::value value)
Set the "max" field.
range_options & min(bsoncxx::v1::types::value value)
Set the "min" field.
range_options & precision(std::int32_t value)
Set the "precision" field.
range_options & sparsity(std::int64_t value)
Set the "sparsity" field.
range_options & trim_factor(std::int32_t value)
Set the "trimFactor" field.
Used by mongocxx::v_noabi::options::encrypt::range_opts.
Definition range.hpp:51
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::types::bson_value::view_or_value > const & max() const
Gets RangeOpts.max.
Definition range.hpp:114
range & sparsity(std::int64_t value)
Sets RangeOpts.sparsity.
Definition range.hpp:119
range & min(bsoncxx::v_noabi::types::bson_value::view_or_value value)
Sets RangeOpts.min.
Definition range.hpp:94
range & trim_factor(std::int32_t value)
Sets RangeOpts.trimFactor.
Definition range.hpp:130
bsoncxx::v_noabi::stdx::optional< std::int32_t > const & precision() const
Gets RangeOpts.precision.
Definition range.hpp:149
range & max(bsoncxx::v_noabi::types::bson_value::view_or_value value)
Sets RangeOpts.max.
Definition range.hpp:107
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::types::bson_value::view_or_value > const & min() const
Gets RangeOpts.min.
Definition range.hpp:101
bsoncxx::v_noabi::stdx::optional< std::int64_t > const & sparsity() const
Gets RangeOpts.sparsity.
Definition range.hpp:125
range()=default
Default initialization.
bsoncxx::v_noabi::stdx::optional< std::int32_t > const & trim_factor() const
Gets RangeOpts.trimFactor.
Definition range.hpp:136
operator v1::range_options() const
Convert to the mongocxx::v1 equivalent.
Definition range.hpp:66
range & precision(std::int32_t value)
Sets RangeOpts.precision.
Definition range.hpp:142
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition export.hpp:52
The mongocxx v_noabi macro guard postlude header.
The mongocxx v_noabi macro guard prelude header.
v_noabi::view_or_value< view, value > view_or_value
Equivalent to v_noabi::view_or_value<view, value>.
Definition view_or_value.hpp:31
v1::element::view to_v1(v_noabi::array::element const &v)
Convert to the bsoncxx::v1 equivalent of v.
Definition element.hpp:132
Declares entities whose ABI stability is guaranteed for documented symbols.
Declares entities representing options to use with various commands.
Declares entities whose ABI stability is NOT guaranteed.
v1::bulk_write to_v1(v_noabi::bulk_write v)
Convert to the mongocxx::v1 equivalent of v.
Definition bulk_write.hpp:162
v_noabi::bulk_write from_v1(v1::bulk_write v)
Convert to the mongocxx::v_noabi equivalent of v.
Definition bulk_write.hpp:155
The top-level namespace within which all mongocxx library entities are declared.
Declares mongocxx::v_noabi::options::range.
Provides mongocxx::v1::range_options.
Provides bsoncxx::v_noabi::types::bson_value::view_or_value.
Provides entities used to represent BSON types.
Provides bsoncxx::v1::types::value.
Provides std::optional-related polyfills for library API usage.
Equivalent to bsoncxx/types/bson_value/view.hpp.