1616
1717#include < mongocxx/options/delete-fwd.hpp> // IWYU pragma: export
1818
19+ //
20+
21+ #include < bsoncxx/v1/document/value.hpp>
22+ #include < bsoncxx/v1/types/value.hpp>
23+
24+ #include < mongocxx/v1/delete_many_options.hpp> // IWYU pragma: export
25+ #include < mongocxx/v1/delete_one_options.hpp> // IWYU pragma: export
26+
27+ #include < utility>
28+
29+ #include < bsoncxx/document/view.hpp>
1930#include < bsoncxx/document/view_or_value.hpp>
2031#include < bsoncxx/stdx/optional.hpp>
32+ #include < bsoncxx/types/bson_value/view.hpp>
2133#include < bsoncxx/types/bson_value/view_or_value.hpp>
2234
2335#include < mongocxx/hint.hpp>
@@ -34,6 +46,85 @@ namespace options {
3446// /
3547class delete_options {
3648 public:
49+ // /
50+ // / Default initialization.
51+ // /
52+ delete_options () = default ;
53+
54+ // /
55+ // / Construct with the @ref mongocxx::v1 equivalent.
56+ // /
57+ /* explicit(false) */ MONGOCXX_ABI_EXPORT_CDECL() delete_options(v1::delete_many_options opts);
58+
59+ // /
60+ // / Construct with the @ref mongocxx::v1 equivalent.
61+ // /
62+ /* explicit(false) */ MONGOCXX_ABI_EXPORT_CDECL() delete_options(v1::delete_one_options opts);
63+
64+ // /
65+ // / Convert to the @ref mongocxx::v1 equivalent.
66+ // /
67+ explicit operator v1::delete_many_options () const {
68+ using bsoncxx::v_noabi::to_v1;
69+ using mongocxx::v_noabi::to_v1;
70+
71+ v1::delete_many_options ret;
72+
73+ if (_collation) {
74+ ret.collation (bsoncxx::v1::document::value{to_v1 (_collation->view ())});
75+ }
76+
77+ if (_write_concern) {
78+ ret.write_concern (to_v1 (*_write_concern));
79+ }
80+
81+ if (_hint) {
82+ ret.hint (to_v1 (*_hint));
83+ }
84+
85+ if (_let) {
86+ ret.let (bsoncxx::v1::document::value{to_v1 (_let->view ())});
87+ }
88+
89+ if (_comment) {
90+ ret.comment (bsoncxx::v1::types::value{to_v1 (_comment->view ())});
91+ }
92+
93+ return ret;
94+ }
95+
96+ // /
97+ // / Convert to the @ref mongocxx::v1 equivalent.
98+ // /
99+ explicit operator v1::delete_one_options () const {
100+ using bsoncxx::v_noabi::to_v1;
101+ using mongocxx::v_noabi::to_v1;
102+
103+ v1::delete_one_options ret;
104+
105+ if (_collation) {
106+ ret.collation (bsoncxx::v1::document::value{to_v1 (_collation->view ())});
107+ }
108+
109+ if (_write_concern) {
110+ ret.write_concern (to_v1 (*_write_concern));
111+ }
112+
113+ if (_hint) {
114+ ret.hint (to_v1 (*_hint));
115+ }
116+
117+ if (_let) {
118+ ret.let (bsoncxx::v1::document::value{to_v1 (_let->view ())});
119+ }
120+
121+ if (_comment) {
122+ ret.comment (bsoncxx::v1::types::value{to_v1 (_comment->view ())});
123+ }
124+
125+ return ret;
126+ }
127+
37128 // /
38129 // / Sets the collation for this operation.
39130 // /
@@ -47,8 +138,10 @@ class delete_options {
47138 // / @see
48139 // / - https://www.mongodb.com/docs/manual/reference/collation/
49140 // /
50- MONGOCXX_ABI_EXPORT_CDECL (delete_options&)
51- collation (bsoncxx::v_noabi::document::view_or_value collation);
141+ delete_options& collation (bsoncxx::v_noabi::document::view_or_value collation) {
142+ _collation = std::move (collation);
143+ return *this ;
144+ }
52145
53146 // /
54147 // / Retrieves the current collation for this operation.
@@ -59,8 +152,9 @@ class delete_options {
59152 // / @see
60153 // / - https://www.mongodb.com/docs/manual/reference/collation/
61154 // /
62- MONGOCXX_ABI_EXPORT_CDECL (bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::view_or_value> const &)
63- collation () const ;
155+ bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::view_or_value> const & collation () const {
156+ return _collation;
157+ }
64158
65159 // /
66160 // / Sets the write_concern for this operation.
@@ -75,7 +169,10 @@ class delete_options {
75169 // / @see
76170 // / - https://www.mongodb.com/docs/manual/core/write-concern/
77171 // /
78- MONGOCXX_ABI_EXPORT_CDECL (delete_options&) write_concern(write_concern wc);
172+ delete_options& write_concern (write_concern wc) {
173+ _write_concern = std::move (wc);
174+ return *this ;
175+ }
79176
80177 // /
81178 // / The current write_concern for this operation.
@@ -86,8 +183,9 @@ class delete_options {
86183 // / @see
87184 // / - https://www.mongodb.com/docs/manual/core/write-concern/
88185 // /
89- MONGOCXX_ABI_EXPORT_CDECL (bsoncxx::v_noabi::stdx::optional<mongocxx::v_noabi::write_concern> const &)
90- write_concern () const ;
186+ bsoncxx::v_noabi::stdx::optional<v_noabi::write_concern> const & write_concern () const {
187+ return _write_concern;
188+ }
91189
92190 // /
93191 // / Sets the index to use for this operation.
@@ -102,15 +200,19 @@ class delete_options {
102200 // / A reference to the object on which this member function is being called. This facilitates
103201 // / method chaining.
104202 // /
105- MONGOCXX_ABI_EXPORT_CDECL (delete_options&) hint(mongocxx::v_noabi::hint index_hint);
203+ delete_options& hint (v_noabi::hint index_hint) {
204+ _hint = std::move (index_hint);
205+ return *this ;
206+ }
106207
107208 // /
108209 // / Gets the current hint.
109210 // /
110211 // / @return The current hint, if one is set.
111212 // /
112- MONGOCXX_ABI_EXPORT_CDECL (bsoncxx::v_noabi::stdx::optional<mongocxx::v_noabi::hint> const &)
113- hint () const ;
213+ bsoncxx::v_noabi::stdx::optional<v_noabi::hint> const & hint () const {
214+ return _hint;
215+ }
114216
115217 // /
116218 // / Set the value of the let option.
@@ -122,16 +224,20 @@ class delete_options {
122224 // / A reference to the object on which this member function is being called. This facilitates
123225 // / method chaining.
124226 // /
125- MONGOCXX_ABI_EXPORT_CDECL (delete_options&) let(bsoncxx::v_noabi::document::view_or_value let);
227+ delete_options& let (bsoncxx::v_noabi::document::view_or_value let) {
228+ _let = std::move (let);
229+ return *this ;
230+ }
126231
127232 // /
128233 // / Gets the current value of the let option.
129234 // /
130235 // / @return
131236 // / The current let option.
132237 // /
133- MONGOCXX_ABI_EXPORT_CDECL (bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::view_or_value> const )
134- let () const ;
238+ bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::view_or_value> const let () const {
239+ return _let;
240+ }
135241
136242 // /
137243 // / Set the value of the comment option.
@@ -143,22 +249,25 @@ class delete_options {
143249 // / A reference to the object on which this member function is being called. This facilitates
144250 // / method chaining.
145251 // /
146- MONGOCXX_ABI_EXPORT_CDECL (delete_options&)
147- comment (bsoncxx::v_noabi::types::bson_value::view_or_value comment);
252+ delete_options& comment (bsoncxx::v_noabi::types::bson_value::view_or_value comment) {
253+ _comment = std::move (comment);
254+ return *this ;
255+ }
148256
149257 // /
150258 // / Gets the current value of the comment option.
151259 // /
152260 // / @return
153261 // / The current comment option.
154262 // /
155- MONGOCXX_ABI_EXPORT_CDECL (bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::types::bson_value::view_or_value> const )
156- comment () const ;
263+ bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::types::bson_value::view_or_value> const comment () const {
264+ return _comment;
265+ }
157266
158267 private:
159268 bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::view_or_value> _collation;
160- bsoncxx::v_noabi::stdx::optional<mongocxx:: v_noabi::write_concern> _write_concern;
161- bsoncxx::v_noabi::stdx::optional<mongocxx:: v_noabi::hint> _hint;
269+ bsoncxx::v_noabi::stdx::optional<v_noabi::write_concern> _write_concern;
270+ bsoncxx::v_noabi::stdx::optional<v_noabi::hint> _hint;
162271 bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::view_or_value> _let;
163272 bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::types::bson_value::view_or_value> _comment;
164273};
@@ -167,9 +276,39 @@ class delete_options {
167276} // namespace v_noabi
168277} // namespace mongocxx
169278
279+ namespace mongocxx {
280+ namespace v_noabi {
281+
282+ // /
283+ // / Convert to the @ref mongocxx::v_noabi equivalent of `v`.
284+ // /
285+ inline v_noabi::options::delete_options from_v1 (v1::delete_many_options v) {
286+ return {std::move (v)};
287+ }
288+
289+ // /
290+ // / Convert to the @ref mongocxx::v_noabi equivalent of `v`.
291+ // /
292+ inline v_noabi::options::delete_options from_v1 (v1::delete_one_options v) {
293+ return {std::move (v)};
294+ }
295+
296+ // Ambiguous whether `v_noabi::options::delete_options` should be converted to `v1::delete_many_options` or
297+ // `v1::delete_one_options`. Require users to explicitly cast to the expected type instead.
298+ //
299+ // v1::delete_many_options to_v1(v_noabi::options::delete_options const& v);
300+ // v1::delete_one_options to_v1(v_noabi::options::delete_options const& v);
301+
302+ } // namespace v_noabi
303+ } // namespace mongocxx
304+
170305#include < mongocxx/config/postlude.hpp>
171306
172307// /
173308// / @file
174309// / Provides @ref mongocxx::v_noabi::options::delete_options.
175310// /
311+ // / @par Includes
312+ // / - @ref mongocxx/v1/delete_many_options.hpp
313+ // / - @ref mongocxx/v1/delete_one_options.hpp
314+ // /
0 commit comments