MongoDB C++ Driver legacy-1.1.1
Loading...
Searching...
No Matches
insert_write_operation.h
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
16#pragma once
17
18#include "mongo/client/write_operation_base.h"
19
20namespace mongo {
21
23public:
24 explicit InsertWriteOperation(const BSONObj& doc);
25
26 virtual WriteOpType operationType() const;
27 virtual const char* batchName() const;
28 virtual int incrementalSize() const;
29
30 virtual void startRequest(const std::string& ns, bool ordered, BufBuilder* builder) const;
31 virtual void appendSelfToRequest(BufBuilder* builder) const;
32
33 virtual void startCommand(const std::string& ns, BSONObjBuilder* command) const;
34 virtual void appendSelfToCommand(BSONArrayBuilder* batch) const;
35
36 virtual void appendSelfToBSONObj(BSONObjBuilder* obj) const;
37
38private:
39 static BSONObj _ensureId(const BSONObj& doc);
40
41 const BSONObj _doc;
42};
43
44} // namespace mongo
Definition bsonobjbuilder.h:765
Utility for creating a BSONObj.
Definition bsonobjbuilder.h:53
C++ representation of a "BSON" object – that is, an extended JSON-style object in a binary representa...
Definition bsonobj.h:78
Definition insert_write_operation.h:22
virtual void startCommand(const std::string &ns, BSONObjBuilder *command) const
Appends the preamble for a write command into the supplied BSONObjBuilder.
virtual void startRequest(const std::string &ns, bool ordered, BufBuilder *builder) const
Appends the preamble for a wire protocol message into the supplied BufBuilder.
virtual void appendSelfToBSONObj(BSONObjBuilder *obj) const
Appends the data represented by an instance of this class to a BSONObjBuilder.
virtual int incrementalSize() const
Returns the incremental size (in bytes) required to add this write operation to a batch.
virtual WriteOpType operationType() const
Returns the MongoDB wire protocol operation type represented by an instance of this particular write ...
virtual void appendSelfToCommand(BSONArrayBuilder *batch) const
Appends a single document that describes the write operation represented by an instance of this class...
virtual const char * batchName() const
Returns the name for a batch of this type of write operation.
virtual void appendSelfToRequest(BufBuilder *builder) const
Appends a document (or documents in the case of update) which describe the write operation represente...
Definition write_operation_base.h:24
Utility functions for parsing numbers from strings.
Definition compare_numbers.h:32