Skip to content

Commit a9df1ab

Browse files
author
Steven Green
committed
SERVER-30166 Replace string with explicit std::string. Enables compulation when using --use-system-pcre which presusably used to do 'using std::string' in an earlier version of pcre
1 parent a1c6794 commit a9df1ab

File tree

3 files changed

+28
-28
lines changed

3 files changed

+28
-28
lines changed

src/mongo/db/matcher/expression_leaf.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ void ComparisonMatchExpression::debugString(StringBuilder& debug, int level) con
181181
}
182182

183183
void ComparisonMatchExpression::serialize(BSONObjBuilder* out) const {
184-
string opString = "";
184+
std::string opString = "";
185185
switch (matchType()) {
186186
case LT:
187187
opString = "$lt";
@@ -826,7 +826,7 @@ void BitTestMatchExpression::debugString(StringBuilder& debug, int level) const
826826
}
827827

828828
void BitTestMatchExpression::serialize(BSONObjBuilder* out) const {
829-
string opString = "";
829+
std::string opString = "";
830830

831831
switch (matchType()) {
832832
case BITS_ALL_SET:

src/mongo/db/repl/master_slave.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ BSONObj ReplSource::jsobj() {
170170

171171
BSONObjBuilder dbsNextPassBuilder;
172172
int n = 0;
173-
for (set<string>::iterator i = addDbNextPass.begin(); i != addDbNextPass.end(); i++) {
173+
for (set<std::string>::iterator i = addDbNextPass.begin(); i != addDbNextPass.end(); i++) {
174174
n++;
175175
dbsNextPassBuilder.appendBool(*i, 1);
176176
}
@@ -179,7 +179,7 @@ BSONObj ReplSource::jsobj() {
179179

180180
BSONObjBuilder incompleteCloneDbsBuilder;
181181
n = 0;
182-
for (set<string>::iterator i = incompleteCloneDbs.begin(); i != incompleteCloneDbs.end(); i++) {
182+
for (set<std::string>::iterator i = incompleteCloneDbs.begin(); i != incompleteCloneDbs.end(); i++) {
183183
n++;
184184
incompleteCloneDbsBuilder.appendBool(*i, 1);
185185
}
@@ -190,7 +190,7 @@ BSONObj ReplSource::jsobj() {
190190
}
191191

192192
void ReplSource::ensureMe(OperationContext* opCtx) {
193-
string myname = getHostName();
193+
std::string myname = getHostName();
194194

195195
// local.me is an identifier for a server for getLastError w:2+
196196
bool exists = Helpers::getSingleton(opCtx, "local.me", _me);
@@ -381,7 +381,7 @@ class HandshakeCmd : public BasicCommand {
381381
}
382382

383383
virtual bool run(OperationContext* opCtx,
384-
const string& ns,
384+
const std::string& ns,
385385
const BSONObj& cmdObj,
386386
BSONObjBuilder& result) {
387387
HandshakeArgs handshake;
@@ -399,7 +399,7 @@ class HandshakeCmd : public BasicCommand {
399399
} handshakeCmd;
400400

401401
bool replHandshake(DBClientConnection* conn, const OID& myRID) {
402-
string myname = getHostName();
402+
std::string myname = getHostName();
403403

404404
BSONObjBuilder cmd;
405405
cmd.append("handshake", myRID);
@@ -450,7 +450,7 @@ void ReplSource::forceResync(OperationContext* opCtx, const char* requester) {
450450
BSONElement e = i.next();
451451
if (e.eoo())
452452
break;
453-
string name = e.embeddedObject().getField("name").valuestr();
453+
std::string name = e.embeddedObject().getField("name").valuestr();
454454
if (!e.embeddedObject().getBoolField("empty")) {
455455
if (name != "local") {
456456
if (only.empty() || only == name) {
@@ -481,7 +481,7 @@ Status ReplSource::_updateIfDoneWithInitialSync() {
481481
return Status::OK();
482482
}
483483

484-
void ReplSource::resyncDrop(OperationContext* opCtx, const string& dbName) {
484+
void ReplSource::resyncDrop(OperationContext* opCtx, const std::string& dbName) {
485485
log() << "resync: dropping database " << dbName;
486486
invariant(opCtx->lockState()->isW());
487487

@@ -531,13 +531,13 @@ void ReplSource::resync(OperationContext* opCtx, const std::string& dbName) {
531531

532532
static DatabaseIgnorer ___databaseIgnorer;
533533

534-
void DatabaseIgnorer::doIgnoreUntilAfter(const string& db, const Timestamp& futureOplogTime) {
534+
void DatabaseIgnorer::doIgnoreUntilAfter(const std::string& db, const Timestamp& futureOplogTime) {
535535
if (futureOplogTime > _ignores[db]) {
536536
_ignores[db] = futureOplogTime;
537537
}
538538
}
539539

540-
bool DatabaseIgnorer::ignoreAt(const string& db, const Timestamp& currentOplogTime) {
540+
bool DatabaseIgnorer::ignoreAt(const std::string& db, const Timestamp& currentOplogTime) {
541541
if (_ignores[db].isNull()) {
542542
return false;
543543
}
@@ -627,7 +627,7 @@ bool ReplSource::handleDuplicateDbName(OperationContext* opCtx,
627627

628628
// The database is present on the master and no conflicting databases
629629
// are present on the master. Drop any local conflicts.
630-
for (set<string>::const_iterator i = duplicates.begin(); i != duplicates.end(); ++i) {
630+
for (set<std::string>::const_iterator i = duplicates.begin(); i != duplicates.end(); ++i) {
631631
___databaseIgnorer.doIgnoreUntilAfter(*i, lastTime);
632632
incompleteCloneDbs.erase(*i);
633633
addDbNextPass.erase(*i);
@@ -822,10 +822,10 @@ void ReplSource::_sync_pullOpLog_applyOperation(OperationContext* opCtx,
822822
}
823823

824824
void ReplSource::syncToTailOfRemoteLog() {
825-
string _ns = ns();
825+
std::string _ns = ns();
826826
BSONObjBuilder b;
827827
if (!only.empty()) {
828-
b.appendRegex("ns", string("^") + pcrecpp::RE::QuoteMeta(only));
828+
b.appendRegex("ns", std::string("^") + pcrecpp::RE::QuoteMeta(only));
829829
}
830830
BSONObj last = oplogReader.findOne(_ns.c_str(), Query(b.done()).sort(BSON("$natural" << -1)));
831831
if (!last.isEmpty()) {
@@ -873,7 +873,7 @@ class ReplApplyBatchSize
873873
*/
874874
int ReplSource::_sync_pullOpLog(OperationContext* opCtx, int& nApplied) {
875875
int okResultCode = restartSyncAfterSleep;
876-
string ns = string("local.oplog.$") + sourceName();
876+
std::string ns = std::string("local.oplog.$") + sourceName();
877877
LOG(2) << "sync_pullOpLog " << ns << " syncedTo:" << syncedTo.toStringLong() << '\n';
878878

879879
bool tailing = true;
@@ -893,7 +893,7 @@ int ReplSource::_sync_pullOpLog(OperationContext* opCtx, int& nApplied) {
893893
BSONElement e = i.next();
894894
if (e.eoo())
895895
break;
896-
string name = e.embeddedObject().getField("name").valuestr();
896+
std::string name = e.embeddedObject().getField("name").valuestr();
897897
if (!e.embeddedObject().getBoolField("empty")) {
898898
if (name != "local") {
899899
if (only.empty() || only == name) {
@@ -916,7 +916,7 @@ int ReplSource::_sync_pullOpLog(OperationContext* opCtx, int& nApplied) {
916916
if (!only.empty()) {
917917
// note we may here skip a LOT of data table scanning, a lot of work for the master.
918918
// maybe append "\\." here?
919-
query.appendRegex("ns", string("^") + pcrecpp::RE::QuoteMeta(only));
919+
query.appendRegex("ns", std::string("^") + pcrecpp::RE::QuoteMeta(only));
920920
}
921921
BSONObj queryObj = query.done();
922922
// e.g. queryObj = { ts: { $gte: syncedTo } }
@@ -935,7 +935,7 @@ int ReplSource::_sync_pullOpLog(OperationContext* opCtx, int& nApplied) {
935935

936936
// show any deferred database creates from a previous pass
937937
{
938-
set<string>::iterator i = addDbNextPass.begin();
938+
set<std::string>::iterator i = addDbNextPass.begin();
939939
if (i != addDbNextPass.end()) {
940940
BSONObjBuilder b;
941941
b.append("ns", *i + '.');
@@ -978,7 +978,7 @@ int ReplSource::_sync_pullOpLog(OperationContext* opCtx, int& nApplied) {
978978
BSONObj op = oplogReader.nextSafe();
979979
BSONElement ts = op.getField("ts");
980980
if (ts.type() != Date && ts.type() != bsonTimestamp) {
981-
string err = op.getStringField("$err");
981+
std::string err = op.getStringField("$err");
982982
if (!err.empty()) {
983983
// 13051 is "tailable cursor requested on non capped collection"
984984
if (op.getIntField("code") == 13051) {
@@ -1143,7 +1143,7 @@ int ReplSource::sync(OperationContext* opCtx, int& nApplied) {
11431143

11441144
// FIXME Handle cases where this db isn't on default port, or default port is spec'd in
11451145
// hostName.
1146-
if ((string("localhost") == hostName || string("127.0.0.1") == hostName) &&
1146+
if ((std::string("localhost") == hostName || std::string("127.0.0.1") == hostName) &&
11471147
serverGlobalParams.port == ServerGlobalParams::DefaultDBPort) {
11481148
log() << "can't sync from self (localhost). sources configuration may be wrong." << endl;
11491149
sleepsecs(5);
@@ -1283,7 +1283,7 @@ static void replMain(OperationContext* opCtx) {
12831283
if (s) {
12841284
stringstream ss;
12851285
ss << "sleep " << s << " sec before next pass";
1286-
string msg = ss.str();
1286+
std::string msg = ss.str();
12871287
if (!serverGlobalParams.quiet.load())
12881288
log() << msg << endl;
12891289
ReplInfo r(msg.c_str());

src/mongo/shell/bench.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ void BenchRunWorker::generateLoadOnConnection(DBClientBase* conn) {
683683
invariant(bsonTemplateEvaluator.setId(_id) == BsonTemplateEvaluator::StatusSuccess);
684684

685685
if (_config->username != "") {
686-
string errmsg;
686+
std::string errmsg;
687687
if (!conn->auth("admin", _config->username, _config->password, errmsg)) {
688688
uasserted(15931, "Authenticating to connection for _benchThread failed: " + errmsg);
689689
}
@@ -940,7 +940,7 @@ void BenchRunWorker::generateLoadOnConnection(DBClientBase* conn) {
940940

941941
if (!result["err"].eoo() && result["err"].type() == String &&
942942
(_config->throwGLE || op.throwGLE))
943-
throw DBException((string) "From benchRun GLE" +
943+
throw DBException((std::string) "From benchRun GLE" +
944944
causedBy(result["err"].String()),
945945
result["code"].eoo() ? 0 : result["code"].Int());
946946
}
@@ -1006,7 +1006,7 @@ void BenchRunWorker::generateLoadOnConnection(DBClientBase* conn) {
10061006

10071007
if (!result["err"].eoo() && result["err"].type() == String &&
10081008
(_config->throwGLE || op.throwGLE))
1009-
throw DBException((string) "From benchRun GLE" +
1009+
throw DBException((std::string) "From benchRun GLE" +
10101010
causedBy(result["err"].String()),
10111011
result["code"].eoo() ? 0 : result["code"].Int());
10121012
}
@@ -1053,7 +1053,7 @@ void BenchRunWorker::generateLoadOnConnection(DBClientBase* conn) {
10531053

10541054
if (!result["err"].eoo() && result["err"].type() == String &&
10551055
(_config->throwGLE || op.throwGLE))
1056-
throw DBException((string) "From benchRun GLE " +
1056+
throw DBException((std::string) "From benchRun GLE " +
10571057
causedBy(result["err"].String()),
10581058
result["code"].eoo() ? 0 : result["code"].Int());
10591059
}
@@ -1155,7 +1155,7 @@ void BenchRunWorker::run() {
11551155
try {
11561156
std::unique_ptr<DBClientBase> conn(_config->createConnection());
11571157
if (!_config->username.empty()) {
1158-
string errmsg;
1158+
std::string errmsg;
11591159
if (!conn->auth("admin", _config->username, _config->password, errmsg)) {
11601160
uasserted(15932, "Authenticating to connection for benchThread failed: " + errmsg);
11611161
}
@@ -1187,7 +1187,7 @@ void BenchRunner::start() {
11871187
std::unique_ptr<DBClientBase> conn(_config->createConnection());
11881188
// Must authenticate to admin db in order to run serverStatus command
11891189
if (_config->username != "") {
1190-
string errmsg;
1190+
std::string errmsg;
11911191
if (!conn->auth("admin", _config->username, _config->password, errmsg)) {
11921192
uasserted(
11931193
16704,
@@ -1223,7 +1223,7 @@ void BenchRunner::stop() {
12231223
{
12241224
std::unique_ptr<DBClientBase> conn(_config->createConnection());
12251225
if (_config->username != "") {
1226-
string errmsg;
1226+
std::string errmsg;
12271227
// this can only fail if admin access was revoked since start of run
12281228
if (!conn->auth("admin", _config->username, _config->password, errmsg)) {
12291229
uasserted(

0 commit comments

Comments
 (0)