Loading...
Searching...
No Matches
range.hpp
Go to the documentation of this file.
// Copyright 2009-present MongoDB, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <mongocxx/options/range-fwd.hpp> // IWYU pragma: export
//
#include <bsoncxx/v1/types/value.hpp>
#include <mongocxx/v1/range_options.hpp> // IWYU pragma: export
#include <cstdint>
#include <utility>
#include <bsoncxx/stdx/optional.hpp>
#include <bsoncxx/types.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <bsoncxx/types/bson_value/view_or_value.hpp>
#include <bsoncxx/types/view.hpp>
#include <mongocxx/config/prelude.hpp>
namespace mongocxx {
namespace v_noabi {
namespace options {
class range {
public:
range() = default;
/* explicit(false) */ MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE() range(v1::range_options opts);
explicit operator v1::range_options() const {
v1::range_options ret;
if (_min) {
ret.min(bsoncxx::v1::types::value{bsoncxx::v_noabi::to_v1(_min->view())});
}
if (_max) {
ret.max(bsoncxx::v1::types::value{bsoncxx::v_noabi::to_v1(_max->view())});
}
if (_sparsity) {
ret.sparsity(*_sparsity);
}
if (_trim_factor) {
ret.trim_factor(*_trim_factor);
}
if (_precision) {
ret.precision(*_precision);
}
return ret;
}
range& min(bsoncxx::v_noabi::types::bson_value::view_or_value value) {
_min = value.view();
return *this;
}
bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::types::bson_value::view_or_value> const& min() const {
return _min;
}
range& max(bsoncxx::v_noabi::types::bson_value::view_or_value value) {
_max = value.view();
return *this;
}
bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::types::bson_value::view_or_value> const& max() const {
return _max;
}
range& sparsity(std::int64_t value) {
_sparsity = value;
return *this;
}
bsoncxx::v_noabi::stdx::optional<std::int64_t> const& sparsity() const {
return _sparsity;
}
range& trim_factor(std::int32_t value) {
_trim_factor = value;
return *this;
}
bsoncxx::v_noabi::stdx::optional<std::int32_t> const& trim_factor() const {
return _trim_factor;
}
range& precision(std::int32_t value) {
_precision = value;
return *this;
}
bsoncxx::v_noabi::stdx::optional<std::int32_t> const& precision() const {
return _precision;
}
private:
bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::types::bson_value::view_or_value> _min;
bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::types::bson_value::view_or_value> _max;
bsoncxx::v_noabi::stdx::optional<std::int64_t> _sparsity;
bsoncxx::v_noabi::stdx::optional<std::int32_t> _trim_factor;
bsoncxx::v_noabi::stdx::optional<std::int32_t> _precision;
};
} // namespace options
} // namespace v_noabi
} // namespace mongocxx
namespace mongocxx {
namespace v_noabi {
inline v_noabi::options::range from_v1(v1::range_options v) {
return {std::move(v)};
}
inline v1::range_options to_v1(v_noabi::options::range const& v) {
return v1::range_options{v};
}
} // namespace v_noabi
} // namespace mongocxx
#include <mongocxx/config/postlude.hpp>
bsoncxx::v1::stdx::optional
A polyfill for std::optional<T>.
Definition optional.hpp:799
bsoncxx::v1::types::value
A union of BSON type values.
Definition value.hpp:52
bsoncxx::v_noabi::types::bson_value::value::view
v_noabi::types::bson_value::view view() const noexcept
Get a view over the bson_value owned by this object.
Definition value.hpp:323
mongocxx::options::range::range
range()=default
Default initialization.
mongocxx::v1::range_options
Options related to range_options queries for Queryable Encryption.
Definition range_options.hpp:49
mongocxx::v1::range_options::trim_factor
range_options & trim_factor(std::int32_t v)
Set the "trimFactor" field.
mongocxx::v1::range_options::precision
range_options & precision(std::int32_t v)
Set the "precision" field.
mongocxx::v1::range_options::min
range_options & min(bsoncxx::v1::types::value v)
Set the "min" field.
mongocxx::v1::range_options::sparsity
range_options & sparsity(std::int64_t v)
Set the "sparsity" field.
mongocxx::v1::range_options::max
range_options & max(bsoncxx::v1::types::value v)
Set the "max" field.
mongocxx::v_noabi::options::range
Used by mongocxx::v_noabi::options::encrypt::range_opts.
Definition range.hpp:51
mongocxx::v_noabi::options::range::max
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::types::bson_value::view_or_value > const & max() const
Gets RangeOpts.max.
Definition range.hpp:114
mongocxx::v_noabi::options::range::sparsity
range & sparsity(std::int64_t value)
Sets RangeOpts.sparsity.
Definition range.hpp:119
mongocxx::v_noabi::options::range::min
range & min(bsoncxx::v_noabi::types::bson_value::view_or_value value)
Sets RangeOpts.min.
Definition range.hpp:94
mongocxx::v_noabi::options::range::trim_factor
range & trim_factor(std::int32_t value)
Sets RangeOpts.trimFactor.
Definition range.hpp:130
mongocxx::v_noabi::options::range::precision
bsoncxx::v_noabi::stdx::optional< std::int32_t > const & precision() const
Gets RangeOpts.precision.
Definition range.hpp:149
mongocxx::v_noabi::options::range::max
range & max(bsoncxx::v_noabi::types::bson_value::view_or_value value)
Sets RangeOpts.max.
Definition range.hpp:107
mongocxx::v_noabi::options::range::min
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::types::bson_value::view_or_value > const & min() const
Gets RangeOpts.min.
Definition range.hpp:101
mongocxx::v_noabi::options::range::sparsity
bsoncxx::v_noabi::stdx::optional< std::int64_t > const & sparsity() const
Gets RangeOpts.sparsity.
Definition range.hpp:125
mongocxx::v_noabi::options::range::range
range()=default
Default initialization.
mongocxx::v_noabi::options::range::trim_factor
bsoncxx::v_noabi::stdx::optional< std::int32_t > const & trim_factor() const
Gets RangeOpts.trimFactor.
Definition range.hpp:136
mongocxx::v_noabi::options::range::range_options
operator v1::range_options() const
Convert to the mongocxx::v1 equivalent.
Definition range.hpp:66
mongocxx::v_noabi::options::range::precision
range & precision(std::int32_t value)
Sets RangeOpts.precision.
Definition range.hpp:142
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE
#define MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(...)
Equivalent to MONGOCXX_ABI_EXPORT_UNSTABLE with MONGOCXX_ABI_CDECL.
Definition config.hpp:28
postlude.hpp
The mongocxx v_noabi macro guard postlude header.
prelude.hpp
The mongocxx v_noabi macro guard prelude header.
bsoncxx::v_noabi::types::bson_value::view_or_value
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
bsoncxx::v_noabi::to_v1
v1::element::view to_v1(v_noabi::array::element const &v)
Convert to the bsoncxx::v1 equivalent of v.
Definition element.hpp:132
mongocxx::v1
Declares entities whose ABI stability is guaranteed for documented symbols.
mongocxx::v_noabi::options
Declares entities representing options to use with various commands.
mongocxx::v_noabi
Declares entities whose ABI stability is NOT guaranteed.
mongocxx::v_noabi::to_v1
v1::bulk_write to_v1(v_noabi::bulk_write v)
Convert to the mongocxx::v1 equivalent of v.
Definition bulk_write.hpp:162
mongocxx::v_noabi::from_v1
v_noabi::bulk_write from_v1(v1::bulk_write v)
Convert to the mongocxx::v_noabi equivalent of v.
Definition bulk_write.hpp:155
mongocxx
The top-level namespace within which all mongocxx library entities are declared.
range-fwd.hpp
Declares mongocxx::v_noabi::options::range.
range_options.hpp
Provides mongocxx::v1::range_options.
view_or_value.hpp
Provides bsoncxx::v_noabi::types::bson_value::view_or_value.
types.hpp
Provides entities used to represent BSON types.
value.hpp
Provides bsoncxx::v1::types::value.
optional.hpp
Provides std::optional-related polyfills for library API usage.
view.hpp
Equivalent to bsoncxx/types/bson_value/view.hpp.