MongoDB C++ Driver  mongocxx-3.0.2
write.hpp
1 // Copyright 2014 MongoDB Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #pragma once
16 
17 #include <cstdint>
18 
19 #include <bsoncxx/stdx/optional.hpp>
20 #include <mongocxx/write_type.hpp>
21 #include <mongocxx/model/insert_one.hpp>
22 #include <mongocxx/model/delete_one.hpp>
23 #include <mongocxx/model/delete_many.hpp>
24 #include <mongocxx/model/update_one.hpp>
25 #include <mongocxx/model/update_many.hpp>
26 #include <mongocxx/model/replace_one.hpp>
27 
28 #include <mongocxx/config/prelude.hpp>
29 
30 namespace mongocxx {
31 MONGOCXX_INLINE_NAMESPACE_BEGIN
32 namespace model {
33 
37 class MONGOCXX_API write {
38  public:
42  write(insert_one value);
43 
47  write(update_one value);
48 
52  write(update_many value);
53 
57  write(delete_one value);
58 
62  write(delete_many value);
63 
67  write(replace_one value);
68 
72  write(write&& rhs) noexcept;
73 
77  write& operator=(write&& rhs) noexcept;
78 
79  write(const write& rhs) = delete;
80  write& operator=(const write& rhs) = delete;
81 
85  ~write();
86 
91  write_type type() const;
92 
98  const insert_one& get_insert_one() const;
99 
105  const update_one& get_update_one() const;
106 
112  const update_many& get_update_many() const;
113 
119  const delete_one& get_delete_one() const;
120 
126  const delete_many& get_delete_many() const;
127 
133  const replace_one& get_replace_one() const;
134 
135  private:
136  MONGOCXX_PRIVATE void destroy_member() noexcept;
137 
138  write_type _type;
139 
140  union {
141  insert_one _insert_one;
142  update_one _update_one;
143  update_many _update_many;
144  delete_one _delete_one;
145  delete_many _delete_many;
146  replace_one _replace_one;
147  };
148 };
149 
150 } // namespace model
151 MONGOCXX_INLINE_NAMESPACE_END
152 } // namespace mongocxx
153 
154 #include <mongocxx/config/postlude.hpp>
Definition: bulk_write.hpp:22
Class representing a MongoDB update operation that replaces a single document.
Definition: replace_one.hpp:30
Class representing a MongoDB update operation that modifies multiple documents.
Definition: update_many.hpp:30
Class representing a MongoDB delete operation that removes multiple documents.
Definition: delete_many.hpp:28
Class representing a MongoDB update operation that modifies a single document.
Definition: update_one.hpp:30
Models a single write operation within a .
Definition: write.hpp:37
Class representing a MongoDB insert operation that creates a single document.
Definition: insert_one.hpp:28
Class representing a MongoDB delete operation that removes a single document.
Definition: delete_one.hpp:28