MongoDB C++ Driver  legacy-1.1.2
command_writer.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/dbclient_writer.h"
19 
20 namespace mongo {
21 
22 class DBClientBase;
23 
24 class CommandWriter : public DBClientWriter {
25 public:
26  explicit CommandWriter(DBClientBase* client);
27 
28  virtual void write(const StringData& ns,
29  const std::vector<WriteOperation*>& write_operations,
30  bool ordered,
31  bool bypassDocumentValidation,
32  const WriteConcern* writeConcern,
33  WriteResult* writeResult);
34 
35 private:
36  void _endCommand(BSONArrayBuilder* batch,
37  WriteOperation* op,
38  bool ordered,
39  bool bypassDocumentValidation,
40  BSONObjBuilder* command);
41 
42  BSONObj _send(BSONObjBuilder* command, const WriteConcern* writeConcern, const StringData& ns);
43 
44  bool _fits(BSONArrayBuilder* builder, WriteOperation* operation);
45 
46  DBClientBase* const _client;
47 };
48 
49 } // namespace mongo
Represents a single server side write operation and encapsulates the process for encoding the operati...
Definition: write_operation.h:31
A StringData object wraps a 'const string&' or a 'const char*' without copying its contents...
Definition: string_data.h:43
Utility functions for parsing numbers from strings.
Definition: compare_numbers.h:20
Utility for creating a BSONObj.
Definition: bsonobjbuilder.h:53
Class representing the result of a write operations sent to the server.
Definition: write_result.h:33
Class to encapsulate client side "Write Concern" concept.
Definition: write_concern.h:35
Definition: dbclient_writer.h:27
Definition: command_writer.h:24
abstract class that implements the core db operations
Definition: dbclientinterface.h:1422
Definition: bsonobjbuilder.h:765
C++ representation of a "BSON" object – that is, an extended JSON-style object in a binary represent...
Definition: bsonobj.h:78