@@ -23,47 +23,49 @@ namespace Poco {
23
23
namespace MongoDB {
24
24
25
25
// Query and write
26
- const std::string OpMsgMessage::CMD_INSERT { " insert" };
27
- const std::string OpMsgMessage::CMD_DELETE { " delete" };
28
- const std::string OpMsgMessage::CMD_UPDATE { " update" };
29
- const std::string OpMsgMessage::CMD_FIND { " find" };
30
- const std::string OpMsgMessage::CMD_FIND_AND_MODIFY { " findAndModify" };
31
- const std::string OpMsgMessage::CMD_GET_MORE { " getMore" };
26
+ const std::string OpMsgMessage::CMD_INSERT { " insert" s };
27
+ const std::string OpMsgMessage::CMD_DELETE { " delete" s };
28
+ const std::string OpMsgMessage::CMD_UPDATE { " update" s };
29
+ const std::string OpMsgMessage::CMD_FIND { " find" s };
30
+ const std::string OpMsgMessage::CMD_FIND_AND_MODIFY { " findAndModify" s };
31
+ const std::string OpMsgMessage::CMD_GET_MORE { " getMore" s };
32
32
33
33
// Aggregation
34
- const std::string OpMsgMessage::CMD_AGGREGATE { " aggregate" };
35
- const std::string OpMsgMessage::CMD_COUNT { " count" };
36
- const std::string OpMsgMessage::CMD_DISTINCT { " distinct" };
37
- const std::string OpMsgMessage::CMD_MAP_REDUCE { " mapReduce" };
34
+ const std::string OpMsgMessage::CMD_AGGREGATE { " aggregate" s };
35
+ const std::string OpMsgMessage::CMD_COUNT { " count" s };
36
+ const std::string OpMsgMessage::CMD_DISTINCT { " distinct" s };
37
+ const std::string OpMsgMessage::CMD_MAP_REDUCE { " mapReduce" s };
38
38
39
39
// Replication and administration
40
- const std::string OpMsgMessage::CMD_HELLO { " hello" };
41
- const std::string OpMsgMessage::CMD_REPL_SET_GET_STATUS { " replSetGetStatus" };
42
- const std::string OpMsgMessage::CMD_REPL_SET_GET_CONFIG { " replSetGetConfig" };
43
-
44
- const std::string OpMsgMessage::CMD_CREATE { " create" };
45
- const std::string OpMsgMessage::CMD_CREATE_INDEXES { " createIndexes" };
46
- const std::string OpMsgMessage::CMD_DROP { " drop" };
47
- const std::string OpMsgMessage::CMD_DROP_DATABASE { " dropDatabase" };
48
- const std::string OpMsgMessage::CMD_KILL_CURSORS { " killCursors" };
49
- const std::string OpMsgMessage::CMD_LIST_DATABASES { " listDatabases" };
50
- const std::string OpMsgMessage::CMD_LIST_INDEXES { " listIndexes" };
40
+ const std::string OpMsgMessage::CMD_HELLO { " hello" s };
41
+ const std::string OpMsgMessage::CMD_REPL_SET_GET_STATUS { " replSetGetStatus" s };
42
+ const std::string OpMsgMessage::CMD_REPL_SET_GET_CONFIG { " replSetGetConfig" s };
43
+
44
+ const std::string OpMsgMessage::CMD_CREATE { " create" s };
45
+ const std::string OpMsgMessage::CMD_CREATE_INDEXES { " createIndexes" s };
46
+ const std::string OpMsgMessage::CMD_DROP { " drop" s };
47
+ const std::string OpMsgMessage::CMD_DROP_DATABASE { " dropDatabase" s };
48
+ const std::string OpMsgMessage::CMD_KILL_CURSORS { " killCursors" s };
49
+ const std::string OpMsgMessage::CMD_LIST_DATABASES { " listDatabases" s };
50
+ const std::string OpMsgMessage::CMD_LIST_INDEXES { " listIndexes" s };
51
51
52
52
// Diagnostic
53
- const std::string OpMsgMessage::CMD_BUILD_INFO { " buildInfo" };
54
- const std::string OpMsgMessage::CMD_COLL_STATS { " collStats" };
55
- const std::string OpMsgMessage::CMD_DB_STATS { " dbStats" };
56
- const std::string OpMsgMessage::CMD_HOST_INFO { " hostInfo" };
53
+ const std::string OpMsgMessage::CMD_BUILD_INFO { " buildInfo" s };
54
+ const std::string OpMsgMessage::CMD_COLL_STATS { " collStats" s };
55
+ const std::string OpMsgMessage::CMD_DB_STATS { " dbStats" s };
56
+ const std::string OpMsgMessage::CMD_HOST_INFO { " hostInfo" s };
57
57
58
58
59
59
static const std::string& commandIdentifier (const std::string& command);
60
60
// / Commands have different names for the payload that is sent in a separate section
61
61
62
62
63
- static const std::string keyCursor {" cursor" };
64
- static const std::string keyFirstBatch {" firstBatch" };
65
- static const std::string keyNextBatch {" nextBatch" };
63
+ static const std::string keyCursor { " cursor" s };
64
+ static const std::string keyFirstBatch { " firstBatch" s };
65
+ static const std::string keyNextBatch { " nextBatch" s };
66
66
67
+ constexpr static Poco::UInt8 PAYLOAD_TYPE_0 { 0 };
68
+ constexpr static Poco::UInt8 PAYLOAD_TYPE_1 { 1 };
67
69
68
70
OpMsgMessage::OpMsgMessage () :
69
71
Message (MessageHeader::OP_MSG)
@@ -112,7 +114,7 @@ void OpMsgMessage::setCommandName(const std::string& command)
112
114
{
113
115
_body.add (_commandName, _collectionName);
114
116
}
115
- _body.add (" $db" , _databaseName);
117
+ _body.add (" $db" s , _databaseName);
116
118
}
117
119
118
120
@@ -123,11 +125,11 @@ void OpMsgMessage::setCursor(Poco::Int64 cursorID, Poco::Int32 batchSize)
123
125
124
126
// IMPORTANT: Command name must be first
125
127
_body.add (_commandName, cursorID);
126
- _body.add (" $db" , _databaseName);
127
- _body.add (" collection" , _collectionName);
128
+ _body.add (" $db" s , _databaseName);
129
+ _body.add (" collection" s , _collectionName);
128
130
if (batchSize > 0 )
129
131
{
130
- _body.add (" batchSize" , batchSize);
132
+ _body.add (" batchSize" s , batchSize);
131
133
}
132
134
}
133
135
@@ -146,7 +148,7 @@ void OpMsgMessage::setAcknowledgedRequest(bool ack)
146
148
147
149
_acknowledged = ack;
148
150
149
- auto writeConcern = _body.get <Document::Ptr>(" writeConcern" , nullptr );
151
+ auto writeConcern = _body.get <Document::Ptr>(" writeConcern" s , nullptr );
150
152
if (writeConcern)
151
153
writeConcern->remove (" w" );
152
154
@@ -158,9 +160,9 @@ void OpMsgMessage::setAcknowledgedRequest(bool ack)
158
160
{
159
161
_flags = _flags | MSG_MORE_TO_COME;
160
162
if (!writeConcern)
161
- _body.addNewDocument (" writeConcern" ).add (" w" , 0 );
163
+ _body.addNewDocument (" writeConcern" s ).add (" w" s , 0 );
162
164
else
163
- writeConcern->add (" w" , 0 );
165
+ writeConcern->add (" w" s , 0 );
164
166
}
165
167
166
168
}
@@ -205,9 +207,9 @@ const Document::Vector& OpMsgMessage::documents() const
205
207
bool OpMsgMessage::responseOk () const
206
208
{
207
209
Poco::Int64 ok {false };
208
- if (_body.exists (" ok" ))
210
+ if (_body.exists (" ok" s ))
209
211
{
210
- ok = _body.getInteger (" ok" );
212
+ ok = _body.getInteger (" ok" s );
211
213
}
212
214
return (ok != 0 );
213
215
}
@@ -387,13 +389,13 @@ const std::string& commandIdentifier(const std::string& command)
387
389
{
388
390
// Names of identifiers for commands that send bulk documents in the request
389
391
// The identifier is set in the section type 1.
390
- static std::map<std::string, std::string> identifiers {
391
- { OpMsgMessage::CMD_INSERT, " documents" },
392
- { OpMsgMessage::CMD_DELETE, " deletes" },
393
- { OpMsgMessage::CMD_UPDATE, " updates" },
392
+ static const std::map<std::string, std::string> identifiers {
393
+ { OpMsgMessage::CMD_INSERT, " documents" s },
394
+ { OpMsgMessage::CMD_DELETE, " deletes" s },
395
+ { OpMsgMessage::CMD_UPDATE, " updates" s },
394
396
395
397
// Not sure if create index can send document section
396
- { OpMsgMessage::CMD_CREATE_INDEXES, " indexes" }
398
+ { OpMsgMessage::CMD_CREATE_INDEXES, " indexes" s }
397
399
};
398
400
399
401
const auto i = identifiers.find (command);
0 commit comments