Loading...
Searching...
No Matches
index_view.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/index_view-fwd.hpp> // IWYU pragma: export
//
#include <bsoncxx/v1/document/value.hpp>
#include <mongocxx/v1/indexes.hpp> // IWYU pragma: export
#include <chrono>
#include <cstdint>
#include <string>
#include <utility>
#include <bsoncxx/document/value.hpp>
#include <bsoncxx/document/view.hpp>
#include <bsoncxx/stdx/optional.hpp>
#include <mongocxx/write_concern.hpp>
#include <mongocxx/config/prelude.hpp>
namespace mongocxx {
namespace v_noabi {
namespace options {
class index_view {
public:
index_view() = default;
/* explicit(false) */ MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE() index_view(v1::indexes::create_one_options opts);
/* explicit(false) */ MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE() index_view(v1::indexes::create_many_options opts);
explicit operator v1::indexes::create_many_options() const {
using bsoncxx::v_noabi::to_v1;
using v_noabi::to_v1;
v1::indexes::create_many_options ret;
if (_max_time) {
ret.max_time(*_max_time);
}
if (_write_concern) {
ret.write_concern(to_v1(*_write_concern));
}
if (_commit_quorum) {
ret.commit_quorum(bsoncxx::v1::document::value{to_v1(_commit_quorum->view())});
}
return ret;
}
explicit operator v1::indexes::create_one_options() const {
using bsoncxx::v_noabi::to_v1;
using v_noabi::to_v1;
v1::indexes::create_one_options ret;
if (_max_time) {
ret.max_time(*_max_time);
}
if (_write_concern) {
ret.write_concern(to_v1(*_write_concern));
}
if (_commit_quorum) {
ret.commit_quorum(bsoncxx::v1::document::value{to_v1(_commit_quorum->view())});
}
return ret;
}
index_view& max_time(std::chrono::milliseconds max_time) {
_max_time = max_time;
return *this;
}
bsoncxx::v_noabi::stdx::optional<std::chrono::milliseconds> const& max_time() const {
return _max_time;
}
index_view& write_concern(v_noabi::write_concern write_concern) {
_write_concern = std::move(write_concern);
return *this;
}
bsoncxx::v_noabi::stdx::optional<v_noabi::write_concern> const& write_concern() const {
return _write_concern;
}
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(index_view&) commit_quorum(std::int32_t commit_quorum);
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(index_view&) commit_quorum(std::string commit_quorum);
bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::value> const commit_quorum() const {
return _commit_quorum;
}
private:
bsoncxx::v_noabi::stdx::optional<std::chrono::milliseconds> _max_time;
bsoncxx::v_noabi::stdx::optional<v_noabi::write_concern> _write_concern;
bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::value> _commit_quorum;
};
} // namespace options
} // namespace v_noabi
} // namespace mongocxx
namespace mongocxx {
namespace v_noabi {
inline v_noabi::options::index_view from_v1(v1::indexes::create_many_options v) {
return {std::move(v)};
}
inline v_noabi::options::index_view from_v1(v1::indexes::create_one_options v) {
return {std::move(v)};
}
// Ambiguous whether `v_noabi::options::index_view` should be converted to `v1::indexes::create_many_options` or
// `v1::indexes::create_one_options`. Require users to explicitly cast to the expected type instead.
//
// v1::indexes::create_many_options to_v1(v_noabi::options::index_view const& v);
// v1::indexes::create_one_options to_v1(v_noabi::options::index_view const& v);
} // namespace v_noabi
} // namespace mongocxx
#include <mongocxx/config/postlude.hpp>
bsoncxx::v1::document::value
A BSON document.
Definition value.hpp:44
bsoncxx::v1::stdx::optional
A polyfill for std::optional<T>.
Definition optional.hpp:799
mongocxx::options::index_view::index_view
index_view()=default
Default initialization.
mongocxx::v1::indexes::create_many_options
Options for mongocxx::v1::indexes::create_many.
Definition indexes.hpp:530
mongocxx::v1::indexes::create_many_options::write_concern
create_many_options & write_concern(v1::write_concern v)
Set the "writeConcern" field.
mongocxx::v1::indexes::create_many_options::commit_quorum
create_many_options & commit_quorum(bsoncxx::v1::document::value v)
Set the "commitQuorum" field.
mongocxx::v1::indexes::create_many_options::max_time
create_many_options & max_time(std::chrono::milliseconds v)
Set the "maxTimeMS" field.
mongocxx::v1::indexes::create_one_options
Options for mongocxx::v1::indexes::create_one.
Definition indexes.hpp:429
mongocxx::v1::indexes::create_one_options::write_concern
create_one_options & write_concern(v1::write_concern v)
Set the "writeConcern" field.
mongocxx::v1::indexes::create_one_options::commit_quorum
create_one_options & commit_quorum(bsoncxx::v1::document::value v)
Set the "commitQuorum" field.
mongocxx::v1::indexes::create_one_options::max_time
create_one_options & max_time(std::chrono::milliseconds v)
Set the "maxTimeMS" field.
mongocxx::v_noabi::options::index_view
Used by MongoDB index view operations.
Definition index_view.hpp:45
mongocxx::v_noabi::options::index_view::write_concern
bsoncxx::v_noabi::stdx::optional< v_noabi::write_concern > const & write_concern() const
Gets the current write concern.
Definition index_view.hpp:167
mongocxx::v_noabi::options::index_view::commit_quorum
index_view & commit_quorum(std::string commit_quorum)
Sets the commit quorum for this operation.
mongocxx::v_noabi::options::index_view::create_many_options
operator v1::indexes::create_many_options() const
Convert to the mongocxx::v1 equivalent.
Definition index_view.hpp:65
mongocxx::v_noabi::options::index_view::commit_quorum
index_view & commit_quorum(std::int32_t commit_quorum)
Sets the commit quorum for this operation.
mongocxx::v_noabi::options::index_view::create_one_options
operator v1::indexes::create_one_options() const
Convert to the mongocxx::v1 equivalent.
Definition index_view.hpp:86
mongocxx::v_noabi::options::index_view::commit_quorum
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::value > const commit_quorum() const
Gets the current commitQuorum setting.
Definition index_view.hpp:220
mongocxx::v_noabi::options::index_view::write_concern
index_view & write_concern(v_noabi::write_concern write_concern)
Sets the write concern for this operation.
Definition index_view.hpp:153
mongocxx::v_noabi::options::index_view::max_time
bsoncxx::v_noabi::stdx::optional< std::chrono::milliseconds > const & max_time() const
The current max_time setting.
Definition index_view.hpp:136
mongocxx::v_noabi::options::index_view::max_time
index_view & max_time(std::chrono::milliseconds max_time)
Sets the maximum amount of time for this operation to run (server-side) in milliseconds.
Definition index_view.hpp:122
mongocxx::v_noabi::options::index_view::index_view
index_view()=default
Default initialization.
mongocxx::v_noabi::write_concern
The level of acknowledgment requested for write operations to a MongoDB server.
Definition write_concern.hpp:54
indexes.hpp
Provides mongocxx::v1::indexes.
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::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.
index_view-fwd.hpp
Declares mongocxx::v_noabi::options::index_view.
value.hpp
Provides bsoncxx::v1::document::value.
value.hpp
Provides bsoncxx::v_noabi::document::value.
view.hpp
Provides bsoncxx::v_noabi::document::view.
optional.hpp
Provides std::optional-related polyfills for library API usage.
write_concern.hpp
Provides mongocxx::v_noabi::write_concern.