Loading...
Searching...
No Matches
read_concern.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/read_concern-fwd.hpp> // IWYU pragma: export
//
#include <mongocxx/v1/read_concern.hpp> // IWYU pragma: export
#include <memory> // IWYU pragma: keep: backward compatibility, to be removed.
#include <utility>
#include <mongocxx/client-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <mongocxx/collection-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <mongocxx/database-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <mongocxx/options/transaction-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <mongocxx/uri-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <bsoncxx/document/value.hpp>
#include <bsoncxx/stdx/optional.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <bsoncxx/stdx/string_view.hpp>
#include <mongocxx/options/transaction.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <mongocxx/config/prelude.hpp>
namespace mongocxx {
namespace v_noabi {
class read_concern {
private:
v1::read_concern _rc;
public:
enum class level {
k_local,
k_majority,
k_linearizable,
k_server_default,
k_unknown,
k_available,
k_snapshot
};
read_concern() = default;
/* explicit(false) */ read_concern(v1::read_concern rc) : _rc{std::move(rc)} {}
explicit operator v1::read_concern() && {
return std::move(_rc);
}
explicit operator v1::read_concern() const& {
return _rc;
}
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(void) acknowledge_level(level rc_level);
level acknowledge_level() const {
return static_cast<level>(_rc.acknowledge_level());
}
void acknowledge_string(bsoncxx::v1::stdx::string_view rc_string) {
_rc.acknowledge_string(rc_string);
}
bsoncxx::v1::stdx::string_view acknowledge_string() const {
auto ret = _rc.acknowledge_string();
if (ret.empty()) {
ret = "";
}
return ret;
}
bsoncxx::v_noabi::document::value to_document() const {
return bsoncxx::v_noabi::from_v1(_rc.to_document());
}
friend bool operator==(read_concern const& lhs, read_concern const& rhs) {
return lhs.acknowledge_level() == rhs.acknowledge_level();
}
friend bool operator!=(read_concern const& lhs, read_concern const& rhs) {
return !(lhs == rhs);
}
class internal;
};
inline v_noabi::read_concern from_v1(v1::read_concern v) {
return {std::move(v)};
}
inline v1::read_concern to_v1(v_noabi::read_concern v) {
return v1::read_concern{std::move(v)};
}
} // namespace v_noabi
} // namespace mongocxx
#include <mongocxx/config/postlude.hpp>
bsoncxx::v1::stdx::string_view
A polyfill for std::string_view.
Definition string_view.hpp:412
bsoncxx::v_noabi::document::value
A read-only BSON document that owns its underlying buffer.
Definition value.hpp:48
mongocxx::read_concern::read_concern
read_concern()=default
Constructs a new read_concern with default acknowledge_level of k_server_default.
mongocxx::v1::read_concern
Options related to a MongoDB Read Concern.
Definition read_concern.hpp:42
mongocxx::v_noabi::read_concern
Controls the consistency and isolation properties of data read from replica sets and sharded clusters...
Definition read_concern.hpp:54
mongocxx::v_noabi::read_concern::acknowledge_level
level acknowledge_level() const
Gets the current read concern level.
Definition read_concern.hpp:129
mongocxx::v_noabi::read_concern::acknowledge_string
bsoncxx::v1::stdx::string_view acknowledge_string() const
Gets the current read concern string.
Definition read_concern.hpp:154
mongocxx::v_noabi::read_concern::level
level
A class to represent the read concern level for read operations.
Definition read_concern.hpp:66
mongocxx::v_noabi::read_concern::level::k_unknown
@ k_unknown
Represent an unknown read concern level.
Definition read_concern.hpp:71
mongocxx::v_noabi::read_concern::level::k_linearizable
@ k_linearizable
Represent read concern level "linearizable".
Definition read_concern.hpp:69
mongocxx::v_noabi::read_concern::level::k_server_default
@ k_server_default
Represent the server's default read concern level.
Definition read_concern.hpp:70
mongocxx::v_noabi::read_concern::level::k_local
@ k_local
Represent read concern level "local".
Definition read_concern.hpp:67
mongocxx::v_noabi::read_concern::level::k_snapshot
@ k_snapshot
Represent read concern level "snapshot".
Definition read_concern.hpp:73
mongocxx::v_noabi::read_concern::level::k_available
@ k_available
Represent read concern level "available".
Definition read_concern.hpp:72
mongocxx::v_noabi::read_concern::level::k_majority
@ k_majority
Represent read concern level "majority".
Definition read_concern.hpp:68
mongocxx::v_noabi::read_concern::read_concern
read_concern(v1::read_concern rc)
Construct with the mongocxx::v1 equivalent.
Definition read_concern.hpp:88
mongocxx::v_noabi::read_concern::operator!=
friend bool operator!=(read_concern const &lhs, read_concern const &rhs)
Compares two read_concern objects for (in)-equality.
Definition read_concern.hpp:182
mongocxx::v_noabi::read_concern::acknowledge_level
void acknowledge_level(level rc_level)
Sets the read concern level.
mongocxx::v_noabi::read_concern::acknowledge_string
void acknowledge_string(bsoncxx::v1::stdx::string_view rc_string)
Sets the read concern string. Any valid read concern string (e.g. "local", "majority",...
Definition read_concern.hpp:142
mongocxx::v_noabi::read_concern::to_document
bsoncxx::v_noabi::document::value to_document() const
Gets the document form of this read_concern.
Definition read_concern.hpp:168
mongocxx::v_noabi::read_concern::read_concern
read_concern()=default
Constructs a new read_concern with default acknowledge_level of k_server_default.
mongocxx::v_noabi::read_concern::operator==
friend bool operator==(read_concern const &lhs, read_concern const &rhs)
Compares two read_concern objects for (in)-equality.
Definition read_concern.hpp:178
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::from_v1
v_noabi::array::value from_v1(v1::array::value const &v)
Convert from the bsoncxx::v1 equivalent of v.
Definition value.hpp:263
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.
transaction-fwd.hpp
Declares mongocxx::v_noabi::options::transaction.
transaction.hpp
Provides mongocxx::v_noabi::options::transaction.
read_concern.hpp
Provides mongocxx::v1::read_concern.
value.hpp
Provides bsoncxx::v_noabi::document::value.
optional.hpp
Provides std::optional-related polyfills for library API usage.
string_view.hpp
Provides std::string_view-related polyfills for library API usage.
client-fwd.hpp
Declares mongocxx::v_noabi::client.
collection-fwd.hpp
Declares mongocxx::v_noabi::collection.
database-fwd.hpp
Declares mongocxx::v_noabi::database.
read_concern-fwd.hpp
Declares mongocxx::v_noabi::read_concern.
uri-fwd.hpp
Declares mongocxx::v_noabi::uri.