1414
1515#pragma once
1616
17- #include < memory>
18-
19- #include < mongocxx/client-fwd.hpp>
20- #include < mongocxx/collection-fwd.hpp>
21- #include < mongocxx/database-fwd.hpp>
22- #include < mongocxx/options/transaction-fwd.hpp>
2317#include < mongocxx/read_concern-fwd.hpp> // IWYU pragma: export
24- #include < mongocxx/uri-fwd.hpp>
18+
19+ //
20+
21+ #include < mongocxx/v1/read_concern.hpp> // IWYU pragma: export
22+
23+ #include < memory> // IWYU pragma: keep: backward compatibility, to be removed.
24+ #include < utility>
25+
26+ #include < mongocxx/client-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
27+ #include < mongocxx/collection-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
28+ #include < mongocxx/database-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
29+ #include < mongocxx/options/transaction-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
30+ #include < mongocxx/uri-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
2531
2632#include < bsoncxx/document/value.hpp>
2733#include < bsoncxx/stdx/optional.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
2834#include < bsoncxx/stdx/string_view.hpp>
2935
30- #include < mongocxx/options/transaction.hpp>
36+ #include < mongocxx/options/transaction.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
3137
3238#include < mongocxx/config/prelude.hpp>
3339
@@ -46,6 +52,9 @@ namespace v_noabi {
4652// / - [Read Concern (MongoDB Manual)](https://www.mongodb.com/docs/manual/reference/read-concern/)
4753// /
4854class read_concern {
55+ private:
56+ v1::read_concern _rc;
57+
4958 public:
5059 // /
5160 // / A class to represent the read concern level for read operations.
@@ -71,32 +80,31 @@ class read_concern {
7180 // / run with this read_concern will use the server's default read_concern instead of
7281 // / specifying one.
7382 // /
74- MONGOCXX_ABI_EXPORT_CDECL () read_concern();
75-
76- // /
77- // / Copy constructs a read_concern.
78- // /
79- MONGOCXX_ABI_EXPORT_CDECL () read_concern(read_concern const &);
83+ read_concern () = default ;
8084
8185 // /
82- // / Copy assigns a read_concern .
86+ // / Construct with the @ref mongocxx::v1 equivalent .
8387 // /
84- MONGOCXX_ABI_EXPORT_CDECL (read_concern&) operator =( read_concern const &);
88+ /* explicit(false) */ read_concern(v1:: read_concern rc) : _rc{ std::move (rc)} {}
8589
8690 // /
87- // / Move constructs a read_concern .
91+ // / Convert to the @ref mongocxx::v1 equivalent .
8892 // /
89- MONGOCXX_ABI_EXPORT_CDECL () read_concern(read_concern&&) noexcept ;
90-
93+ // / @par Postconditions:
94+ // / - `other` is in an assign-or-destroy-only state.
9195 // /
92- // / Move assigns a read_concern .
96+ // / @warning Invalidates all associated iterators and views .
9397 // /
94- MONGOCXX_ABI_EXPORT_CDECL (read_concern&) operator =(read_concern&&) noexcept ;
98+ explicit operator v1::read_concern () && {
99+ return std::move (_rc);
100+ }
95101
96102 // /
97- // / Destroys a read_concern .
103+ // / Convert to the @ref mongocxx::v1 equivalent .
98104 // /
99- MONGOCXX_ABI_EXPORT_CDECL () ~read_concern ();
105+ explicit operator v1::read_concern () const & {
106+ return _rc;
107+ }
100108
101109 // /
102110 // / Sets the read concern level.
@@ -118,7 +126,9 @@ class read_concern {
118126 // /
119127 // / @return The read concern level.
120128 // /
121- MONGOCXX_ABI_EXPORT_CDECL (level) acknowledge_level() const ;
129+ level acknowledge_level () const {
130+ return static_cast <level>(_rc.acknowledge_level ());
131+ }
122132
123133 // /
124134 // / Sets the read concern string. Any valid read concern string (e.g. "local",
@@ -129,8 +139,9 @@ class read_concern {
129139 // / @param rc_string
130140 // / The read concern string.
131141 // /
132- MONGOCXX_ABI_EXPORT_CDECL (void )
133- acknowledge_string (bsoncxx::v_noabi::stdx::string_view rc_string);
142+ void acknowledge_string (bsoncxx::v1::stdx::string_view rc_string) {
143+ _rc.acknowledge_string (rc_string);
144+ }
134145
135146 // /
136147 // / Gets the current read concern string.
@@ -140,40 +151,56 @@ class read_concern {
140151 // /
141152 // / @return The read concern string.
142153 // /
143- MONGOCXX_ABI_EXPORT_CDECL (bsoncxx::v_noabi::stdx::string_view) acknowledge_string() const ;
154+ bsoncxx::v1::stdx::string_view acknowledge_string () const {
155+ auto ret = _rc.acknowledge_string ();
156+ if (ret.empty ()) {
157+ ret = " " ;
158+ }
159+ return ret;
160+ }
144161
145162 // /
146163 // / Gets the document form of this read_concern.
147164 // /
148165 // / @return
149166 // / Document representation of this read_concern.
150167 // /
151- MONGOCXX_ABI_EXPORT_CDECL (bsoncxx::v_noabi::document::value) to_document() const ;
168+ bsoncxx::v_noabi::document::value to_document () const {
169+ return bsoncxx::v_noabi::from_v1 (_rc.to_document ());
170+ }
152171
153172 // /
154173 // / @relates mongocxx::v_noabi::read_concern
155174 // /
156175 // / Compares two read_concern objects for (in)-equality.
157176 // /
158177 // / @{
159- friend MONGOCXX_ABI_EXPORT_CDECL (bool ) operator==(read_concern const &, read_concern const &);
160- friend MONGOCXX_ABI_EXPORT_CDECL (bool ) operator!=(read_concern const &, read_concern const &);
178+ friend bool operator ==(read_concern const & lhs, read_concern const & rhs) {
179+ return lhs.acknowledge_level () == rhs.acknowledge_level ();
180+ }
181+
182+ friend bool operator !=(read_concern const & lhs, read_concern const & rhs) {
183+ return !(lhs == rhs);
184+ }
161185 // / @}
162186 // /
163187
164- private:
165- friend ::mongocxx::v_noabi::client;
166- friend ::mongocxx::v_noabi::collection;
167- friend ::mongocxx::v_noabi::database;
168- friend ::mongocxx::v_noabi::options::transaction;
169- friend ::mongocxx::v_noabi::uri;
170-
171- class impl ;
188+ class internal ;
189+ };
172190
173- read_concern (std::unique_ptr<impl>&& implementation);
191+ // /
192+ // / Convert to the @ref mongocxx::v_noabi equivalent of `v`.
193+ // /
194+ inline v_noabi::read_concern from_v1 (v1::read_concern v) {
195+ return {std::move (v)};
196+ }
174197
175- std::unique_ptr<impl> _impl;
176- };
198+ // /
199+ // / Convert to the @ref mongocxx::v1 equivalent of `v`.
200+ // /
201+ inline v1::read_concern to_v1 (v_noabi::read_concern v) {
202+ return v1::read_concern{std::move (v)};
203+ }
177204
178205} // namespace v_noabi
179206} // namespace mongocxx
@@ -184,3 +211,6 @@ class read_concern {
184211// / @file
185212// / Provides @ref mongocxx::v_noabi::read_concern.
186213// /
214+ // / @par Includes
215+ // / - @ref mongocxx/v1/read_concern.hpp
216+ // /
0 commit comments