Line 0
Link Here
|
|
|
1 |
From 218a7b1d4ea3d3b04a5f6f54c66640b3a15586b0 Mon Sep 17 00:00:00 2001 |
2 |
From: Steven Green <steven@greenius.co.uk> |
3 |
Date: Tue, 22 Aug 2017 13:08:48 -0400 |
4 |
Subject: [PATCH] SERVER-30166 Replace string with explicit std::string. |
5 |
Enables compulation when using --use-system-pcre which presusably used to do |
6 |
'using std::string' in an earlier version of pcre |
7 |
|
8 |
Closes #1167 |
9 |
|
10 |
Signed-off-by: Mark Benvenuto <mark.benvenuto@mongodb.com> |
11 |
(cherry picked from commit b7cebf82bc5e5572308cc3a3fb958a825db91498) |
12 |
--- |
13 |
src/mongo/db/dbwebserver.cpp | 1 + |
14 |
src/mongo/db/matcher/expression_leaf.cpp | 4 ++-- |
15 |
src/mongo/db/repl/master_slave.cpp | 41 ++++++++++++++++---------------- |
16 |
src/mongo/shell/bench.cpp | 14 +++++------ |
17 |
src/mongo/util/net/miniwebserver.cpp | 1 + |
18 |
5 files changed, 32 insertions(+), 29 deletions(-) |
19 |
|
20 |
diff --git a/src/mongo/db/dbwebserver.cpp b/src/mongo/db/dbwebserver.cpp |
21 |
index b202e0500b9..50fa68a8176 100644 |
22 |
--- src/mongo/db/dbwebserver.cpp |
23 |
+++ src/mongo/db/dbwebserver.cpp |
24 |
@@ -65,6 +65,7 @@ |
25 |
namespace mongo { |
26 |
|
27 |
using std::map; |
28 |
+using std::string; |
29 |
using std::stringstream; |
30 |
using std::vector; |
31 |
|
32 |
diff --git a/src/mongo/db/matcher/expression_leaf.cpp b/src/mongo/db/matcher/expression_leaf.cpp |
33 |
index 33356317816..0bf8d8685bc 100644 |
34 |
--- src/mongo/db/matcher/expression_leaf.cpp |
35 |
+++ src/mongo/db/matcher/expression_leaf.cpp |
36 |
@@ -202,7 +202,7 @@ void ComparisonMatchExpression::debugString(StringBuilder& debug, int level) con |
37 |
} |
38 |
|
39 |
void ComparisonMatchExpression::serialize(BSONObjBuilder* out) const { |
40 |
- string opString = ""; |
41 |
+ std::string opString = ""; |
42 |
switch (matchType()) { |
43 |
case LT: |
44 |
opString = "$lt"; |
45 |
@@ -886,7 +886,7 @@ void BitTestMatchExpression::debugString(StringBuilder& debug, int level) const |
46 |
} |
47 |
|
48 |
void BitTestMatchExpression::serialize(BSONObjBuilder* out) const { |
49 |
- string opString = ""; |
50 |
+ std::string opString = ""; |
51 |
|
52 |
switch (matchType()) { |
53 |
case BITS_ALL_SET: |
54 |
diff --git a/src/mongo/db/repl/master_slave.cpp b/src/mongo/db/repl/master_slave.cpp |
55 |
index 96cfe58efdc..6929d5be297 100644 |
56 |
--- src/mongo/db/repl/master_slave.cpp |
57 |
+++ src/mongo/db/repl/master_slave.cpp |
58 |
@@ -168,7 +168,7 @@ BSONObj ReplSource::jsobj() { |
59 |
|
60 |
BSONObjBuilder dbsNextPassBuilder; |
61 |
int n = 0; |
62 |
- for (set<string>::iterator i = addDbNextPass.begin(); i != addDbNextPass.end(); i++) { |
63 |
+ for (set<std::string>::iterator i = addDbNextPass.begin(); i != addDbNextPass.end(); i++) { |
64 |
n++; |
65 |
dbsNextPassBuilder.appendBool(*i, 1); |
66 |
} |
67 |
@@ -177,7 +177,8 @@ BSONObj ReplSource::jsobj() { |
68 |
|
69 |
BSONObjBuilder incompleteCloneDbsBuilder; |
70 |
n = 0; |
71 |
- for (set<string>::iterator i = incompleteCloneDbs.begin(); i != incompleteCloneDbs.end(); i++) { |
72 |
+ for (set<std::string>::iterator i = incompleteCloneDbs.begin(); i != incompleteCloneDbs.end(); |
73 |
+ i++) { |
74 |
n++; |
75 |
incompleteCloneDbsBuilder.appendBool(*i, 1); |
76 |
} |
77 |
@@ -188,7 +189,7 @@ BSONObj ReplSource::jsobj() { |
78 |
} |
79 |
|
80 |
void ReplSource::ensureMe(OperationContext* txn) { |
81 |
- string myname = getHostName(); |
82 |
+ std::string myname = getHostName(); |
83 |
|
84 |
// local.me is an identifier for a server for getLastError w:2+ |
85 |
bool exists = Helpers::getSingleton(txn, "local.me", _me); |
86 |
@@ -378,10 +379,10 @@ class HandshakeCmd : public Command { |
87 |
} |
88 |
|
89 |
virtual bool run(OperationContext* txn, |
90 |
- const string& ns, |
91 |
+ const std::string& ns, |
92 |
BSONObj& cmdObj, |
93 |
int options, |
94 |
- string& errmsg, |
95 |
+ std::string& errmsg, |
96 |
BSONObjBuilder& result) { |
97 |
HandshakeArgs handshake; |
98 |
Status status = handshake.initialize(cmdObj); |
99 |
@@ -398,7 +399,7 @@ class HandshakeCmd : public Command { |
100 |
} handshakeCmd; |
101 |
|
102 |
bool replHandshake(DBClientConnection* conn, const OID& myRID) { |
103 |
- string myname = getHostName(); |
104 |
+ std::string myname = getHostName(); |
105 |
|
106 |
BSONObjBuilder cmd; |
107 |
cmd.append("handshake", myRID); |
108 |
@@ -450,7 +451,7 @@ void ReplSource::forceResync(OperationContext* txn, const char* requester) { |
109 |
BSONElement e = i.next(); |
110 |
if (e.eoo()) |
111 |
break; |
112 |
- string name = e.embeddedObject().getField("name").valuestr(); |
113 |
+ std::string name = e.embeddedObject().getField("name").valuestr(); |
114 |
if (!e.embeddedObject().getBoolField("empty")) { |
115 |
if (name != "local") { |
116 |
if (only.empty() || only == name) { |
117 |
@@ -481,7 +482,7 @@ Status ReplSource::_updateIfDoneWithInitialSync() { |
118 |
return Status::OK(); |
119 |
} |
120 |
|
121 |
-void ReplSource::resyncDrop(OperationContext* txn, const string& dbName) { |
122 |
+void ReplSource::resyncDrop(OperationContext* txn, const std::string& dbName) { |
123 |
log() << "resync: dropping database " << dbName; |
124 |
invariant(txn->lockState()->isW()); |
125 |
|
126 |
@@ -531,13 +532,13 @@ void ReplSource::resync(OperationContext* txn, const std::string& dbName) { |
127 |
|
128 |
static DatabaseIgnorer ___databaseIgnorer; |
129 |
|
130 |
-void DatabaseIgnorer::doIgnoreUntilAfter(const string& db, const Timestamp& futureOplogTime) { |
131 |
+void DatabaseIgnorer::doIgnoreUntilAfter(const std::string& db, const Timestamp& futureOplogTime) { |
132 |
if (futureOplogTime > _ignores[db]) { |
133 |
_ignores[db] = futureOplogTime; |
134 |
} |
135 |
} |
136 |
|
137 |
-bool DatabaseIgnorer::ignoreAt(const string& db, const Timestamp& currentOplogTime) { |
138 |
+bool DatabaseIgnorer::ignoreAt(const std::string& db, const Timestamp& currentOplogTime) { |
139 |
if (_ignores[db].isNull()) { |
140 |
return false; |
141 |
} |
142 |
@@ -627,7 +628,7 @@ bool ReplSource::handleDuplicateDbName(OperationContext* txn, |
143 |
|
144 |
// The database is present on the master and no conflicting databases |
145 |
// are present on the master. Drop any local conflicts. |
146 |
- for (set<string>::const_iterator i = duplicates.begin(); i != duplicates.end(); ++i) { |
147 |
+ for (set<std::string>::const_iterator i = duplicates.begin(); i != duplicates.end(); ++i) { |
148 |
___databaseIgnorer.doIgnoreUntilAfter(*i, lastTime); |
149 |
incompleteCloneDbs.erase(*i); |
150 |
addDbNextPass.erase(*i); |
151 |
@@ -822,10 +823,10 @@ void ReplSource::_sync_pullOpLog_applyOperation(OperationContext* txn, |
152 |
} |
153 |
|
154 |
void ReplSource::syncToTailOfRemoteLog() { |
155 |
- string _ns = ns(); |
156 |
+ std::string _ns = ns(); |
157 |
BSONObjBuilder b; |
158 |
if (!only.empty()) { |
159 |
- b.appendRegex("ns", string("^") + pcrecpp::RE::QuoteMeta(only)); |
160 |
+ b.appendRegex("ns", std::string("^") + pcrecpp::RE::QuoteMeta(only)); |
161 |
} |
162 |
BSONObj last = oplogReader.findOne(_ns.c_str(), Query(b.done()).sort(BSON("$natural" << -1))); |
163 |
if (!last.isEmpty()) { |
164 |
@@ -873,7 +874,7 @@ class ReplApplyBatchSize |
165 |
*/ |
166 |
int ReplSource::_sync_pullOpLog(OperationContext* txn, int& nApplied) { |
167 |
int okResultCode = restartSyncAfterSleep; |
168 |
- string ns = string("local.oplog.$") + sourceName(); |
169 |
+ std::string ns = std::string("local.oplog.$") + sourceName(); |
170 |
LOG(2) << "sync_pullOpLog " << ns << " syncedTo:" << syncedTo.toStringLong() << '\n'; |
171 |
|
172 |
bool tailing = true; |
173 |
@@ -893,7 +894,7 @@ int ReplSource::_sync_pullOpLog(OperationContext* txn, int& nApplied) { |
174 |
BSONElement e = i.next(); |
175 |
if (e.eoo()) |
176 |
break; |
177 |
- string name = e.embeddedObject().getField("name").valuestr(); |
178 |
+ std::string name = e.embeddedObject().getField("name").valuestr(); |
179 |
if (!e.embeddedObject().getBoolField("empty")) { |
180 |
if (name != "local") { |
181 |
if (only.empty() || only == name) { |
182 |
@@ -917,7 +918,7 @@ int ReplSource::_sync_pullOpLog(OperationContext* txn, int& nApplied) { |
183 |
if (!only.empty()) { |
184 |
// note we may here skip a LOT of data table scanning, a lot of work for the master. |
185 |
// maybe append "\\." here? |
186 |
- query.appendRegex("ns", string("^") + pcrecpp::RE::QuoteMeta(only)); |
187 |
+ query.appendRegex("ns", std::string("^") + pcrecpp::RE::QuoteMeta(only)); |
188 |
} |
189 |
BSONObj queryObj = query.done(); |
190 |
// e.g. queryObj = { ts: { $gte: syncedTo } } |
191 |
@@ -936,7 +937,7 @@ int ReplSource::_sync_pullOpLog(OperationContext* txn, int& nApplied) { |
192 |
|
193 |
// show any deferred database creates from a previous pass |
194 |
{ |
195 |
- set<string>::iterator i = addDbNextPass.begin(); |
196 |
+ set<std::string>::iterator i = addDbNextPass.begin(); |
197 |
if (i != addDbNextPass.end()) { |
198 |
BSONObjBuilder b; |
199 |
b.append("ns", *i + '.'); |
200 |
@@ -980,7 +981,7 @@ int ReplSource::_sync_pullOpLog(OperationContext* txn, int& nApplied) { |
201 |
BSONObj op = oplogReader.nextSafe(); |
202 |
BSONElement ts = op.getField("ts"); |
203 |
if (ts.type() != Date && ts.type() != bsonTimestamp) { |
204 |
- string err = op.getStringField("$err"); |
205 |
+ std::string err = op.getStringField("$err"); |
206 |
if (!err.empty()) { |
207 |
// 13051 is "tailable cursor requested on non capped collection" |
208 |
if (op.getIntField("code") == 13051) { |
209 |
@@ -1148,7 +1149,7 @@ int ReplSource::sync(OperationContext* txn, int& nApplied) { |
210 |
|
211 |
// FIXME Handle cases where this db isn't on default port, or default port is spec'd in |
212 |
// hostName. |
213 |
- if ((string("localhost") == hostName || string("127.0.0.1") == hostName) && |
214 |
+ if ((std::string("localhost") == hostName || std::string("127.0.0.1") == hostName) && |
215 |
serverGlobalParams.port == ServerGlobalParams::DefaultDBPort) { |
216 |
log() << "can't sync from self (localhost). sources configuration may be wrong." << endl; |
217 |
sleepsecs(5); |
218 |
@@ -1293,7 +1294,7 @@ static void replMain(OperationContext* txn) { |
219 |
if (s) { |
220 |
stringstream ss; |
221 |
ss << "sleep " << s << " sec before next pass"; |
222 |
- string msg = ss.str(); |
223 |
+ std::string msg = ss.str(); |
224 |
if (!serverGlobalParams.quiet) |
225 |
log() << msg << endl; |
226 |
ReplInfo r(msg.c_str()); |
227 |
diff --git a/src/mongo/shell/bench.cpp b/src/mongo/shell/bench.cpp |
228 |
index 040002f5c6e..338477ebe56 100644 |
229 |
--- src/mongo/shell/bench.cpp |
230 |
+++ src/mongo/shell/bench.cpp |
231 |
@@ -674,7 +674,7 @@ void BenchRunWorker::generateLoadOnConnection(DBClientBase* conn) { |
232 |
invariant(bsonTemplateEvaluator.setId(_id) == BsonTemplateEvaluator::StatusSuccess); |
233 |
|
234 |
if (_config->username != "") { |
235 |
- string errmsg; |
236 |
+ std::string errmsg; |
237 |
if (!conn->auth("admin", _config->username, _config->password, errmsg)) { |
238 |
uasserted(15931, "Authenticating to connection for _benchThread failed: " + errmsg); |
239 |
} |
240 |
@@ -918,7 +918,7 @@ void BenchRunWorker::generateLoadOnConnection(DBClientBase* conn) { |
241 |
|
242 |
if (!result["err"].eoo() && result["err"].type() == String && |
243 |
(_config->throwGLE || op.throwGLE)) |
244 |
- throw DBException((string) "From benchRun GLE" + |
245 |
+ throw DBException((std::string) "From benchRun GLE" + |
246 |
causedBy(result["err"].String()), |
247 |
result["code"].eoo() ? 0 : result["code"].Int()); |
248 |
} |
249 |
@@ -984,7 +984,7 @@ void BenchRunWorker::generateLoadOnConnection(DBClientBase* conn) { |
250 |
|
251 |
if (!result["err"].eoo() && result["err"].type() == String && |
252 |
(_config->throwGLE || op.throwGLE)) |
253 |
- throw DBException((string) "From benchRun GLE" + |
254 |
+ throw DBException((std::string) "From benchRun GLE" + |
255 |
causedBy(result["err"].String()), |
256 |
result["code"].eoo() ? 0 : result["code"].Int()); |
257 |
} |
258 |
@@ -1031,7 +1031,7 @@ void BenchRunWorker::generateLoadOnConnection(DBClientBase* conn) { |
259 |
|
260 |
if (!result["err"].eoo() && result["err"].type() == String && |
261 |
(_config->throwGLE || op.throwGLE)) |
262 |
- throw DBException((string) "From benchRun GLE " + |
263 |
+ throw DBException((std::string) "From benchRun GLE " + |
264 |
causedBy(result["err"].String()), |
265 |
result["code"].eoo() ? 0 : result["code"].Int()); |
266 |
} |
267 |
@@ -1133,7 +1133,7 @@ void BenchRunWorker::run() { |
268 |
try { |
269 |
std::unique_ptr<DBClientBase> conn(_config->createConnection()); |
270 |
if (!_config->username.empty()) { |
271 |
- string errmsg; |
272 |
+ std::string errmsg; |
273 |
if (!conn->auth("admin", _config->username, _config->password, errmsg)) { |
274 |
uasserted(15932, "Authenticating to connection for benchThread failed: " + errmsg); |
275 |
} |
276 |
@@ -1165,7 +1165,7 @@ void BenchRunner::start() { |
277 |
std::unique_ptr<DBClientBase> conn(_config->createConnection()); |
278 |
// Must authenticate to admin db in order to run serverStatus command |
279 |
if (_config->username != "") { |
280 |
- string errmsg; |
281 |
+ std::string errmsg; |
282 |
if (!conn->auth("admin", _config->username, _config->password, errmsg)) { |
283 |
uasserted( |
284 |
16704, |
285 |
@@ -1201,7 +1201,7 @@ void BenchRunner::stop() { |
286 |
{ |
287 |
std::unique_ptr<DBClientBase> conn(_config->createConnection()); |
288 |
if (_config->username != "") { |
289 |
- string errmsg; |
290 |
+ std::string errmsg; |
291 |
// this can only fail if admin access was revoked since start of run |
292 |
if (!conn->auth("admin", _config->username, _config->password, errmsg)) { |
293 |
uasserted( |
294 |
diff --git a/src/mongo/util/net/miniwebserver.cpp b/src/mongo/util/net/miniwebserver.cpp |
295 |
index 5f4165d42f4..9fe847168ee 100644 |
296 |
--- src/mongo/util/net/miniwebserver.cpp |
297 |
+++ src/mongo/util/net/miniwebserver.cpp |
298 |
@@ -45,6 +45,7 @@ |
299 |
namespace mongo { |
300 |
|
301 |
using std::shared_ptr; |
302 |
+using std::string; |
303 |
using std::stringstream; |
304 |
using std::vector; |
305 |
|