MongoDB C++ Driver  mongocxx-3.10.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 <mongocxx/model/write-fwd.hpp>
20 
21 #include <bsoncxx/stdx/optional.hpp>
22 #include <mongocxx/model/delete_many.hpp>
23 #include <mongocxx/model/delete_one.hpp>
24 #include <mongocxx/model/insert_one.hpp>
25 #include <mongocxx/model/replace_one.hpp>
26 #include <mongocxx/model/update_many.hpp>
27 #include <mongocxx/model/update_one.hpp>
28 #include <mongocxx/write_type.hpp>
29 
30 #include <mongocxx/config/prelude.hpp>
31 
32 namespace mongocxx {
33 namespace v_noabi {
34 namespace model {
35 
39 class write {
40  public:
44  write(insert_one value);
45 
49  write(update_one value);
50 
55 
59  write(delete_one value);
60 
65 
70 
74  write(write&& rhs) noexcept;
75 
79  write& operator=(write&& rhs) noexcept;
80 
81  write(const write& rhs) = delete;
82  write& operator=(const write& rhs) = delete;
83 
87  ~write();
88 
93  write_type type() const;
94 
100  const insert_one& get_insert_one() const;
101 
107  const update_one& get_update_one() const;
108 
114  const update_many& get_update_many() const;
115 
121  const delete_one& get_delete_one() const;
122 
128  const delete_many& get_delete_many() const;
129 
135  const replace_one& get_replace_one() const;
136 
137  private:
138  MONGOCXX_PRIVATE void destroy_member() noexcept;
139 
140  write_type _type;
141 
142  union {
143  insert_one _insert_one;
144  update_one _update_one;
145  update_many _update_many;
146  delete_one _delete_one;
147  delete_many _delete_many;
148  replace_one _replace_one;
149  };
150 };
151 
152 } // namespace model
153 } // namespace v_noabi
154 } // namespace mongocxx
155 
156 #include <mongocxx/config/postlude.hpp>
Class representing a MongoDB delete operation that removes multiple documents.
Definition: delete_many.hpp:33
Class representing a MongoDB delete operation that removes a single document.
Definition: delete_one.hpp:33
Class representing a MongoDB insert operation that creates a single document.
Definition: insert_one.hpp:30
Class representing a MongoDB update operation that replaces a single document.
Definition: replace_one.hpp:33
Class representing a MongoDB update operation that modifies multiple documents.
Definition: update_many.hpp:35
Class representing a MongoDB update operation that modifies a single document.
Definition: update_one.hpp:35
Models a single write operation within a mongocxx::v_noabi::bulk_write.
Definition: write.hpp:39
write(write &&rhs) noexcept
Move constructs a write.
const insert_one & get_insert_one() const
Accesses the write as a model::insert_one.
write(insert_one value)
Constructs a write from a model::insert_one.
write(replace_one value)
Constructs a write from a model::replace_one.
write(update_many value)
Constructs a write from a model::update_many.
const update_many & get_update_many() const
Accesses the write as an model::update_many.
write(delete_many value)
Constructs a write from a model::delete_many.
const delete_many & get_delete_many() const
Accesses the write as a model::delete_many.
const update_one & get_update_one() const
Accesses the write as an model::update_one.
const delete_one & get_delete_one() const
Accesses the write as a model::delete_one.
write(delete_one value)
Constructs a write from a model::delete_one.
write & operator=(write &&rhs) noexcept
Move assigns a write.
const replace_one & get_replace_one() const
Accesses the write as a model::replace_one.
write_type type() const
Returns the current type of this write.
write(update_one value)
Constructs a write from a model::update_one.
write_type
Enum representing the the types of write operations that can be performed.
Definition: write_type.hpp:27
The top-level namespace for mongocxx library entities.
Definition: bulk_write-fwd.hpp:19