MongoDB C++ Driver mongocxx-3.6.7
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/model/delete_many.hpp>
21#include <mongocxx/model/delete_one.hpp>
22#include <mongocxx/model/insert_one.hpp>
23#include <mongocxx/model/replace_one.hpp>
24#include <mongocxx/model/update_many.hpp>
25#include <mongocxx/model/update_one.hpp>
26#include <mongocxx/write_type.hpp>
27
28#include <mongocxx/config/prelude.hpp>
29
30namespace mongocxx {
31MONGOCXX_INLINE_NAMESPACE_BEGIN
32namespace model {
33
37class MONGOCXX_API write {
38 public:
43
48
53
58
63
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
86
92
98 const insert_one& get_insert_one() const;
99
106
113
120
127
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
151MONGOCXX_INLINE_NAMESPACE_END
152} // namespace mongocxx
153
154#include <mongocxx/config/postlude.hpp>
Class representing a MongoDB delete operation that removes multiple documents.
Definition: delete_many.hpp:31
Class representing a MongoDB delete operation that removes a single document.
Definition: delete_one.hpp:31
Class representing a MongoDB insert operation that creates a single document.
Definition: insert_one.hpp:28
Class representing a MongoDB update operation that replaces a single document.
Definition: replace_one.hpp:31
Class representing a MongoDB update operation that modifies multiple documents.
Definition: update_many.hpp:34
Class representing a MongoDB update operation that modifies a single document.
Definition: update_one.hpp:34
Models a single write operation within a mongocxx::bulk_write.
Definition: write.hpp:37
write_type type() const
Returns the current type of this write.
write(replace_one value)
Constructs a write from a model::replace_one.
write(update_one value)
Constructs a write from a model::update_one.
write(update_many value)
Constructs a write from a model::update_many.
const delete_one & get_delete_one() const
Accesses the write as a model::delete_one.
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 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()
Destroys a write.
const update_one & get_update_one() const
Accesses the write as an model::update_one.
write(write &&rhs) noexcept
Move constructs a write.
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.
const update_many & get_update_many() const
Accesses the write as an model::update_many.
Top level namespace for the MongoDB C++ driver.
Definition: bulk_write.hpp:24
write_type
Enum representing the the types of write operations that can be performed.
Definition: write_type.hpp:25