summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2016-05-06 14:09:50 -0400
committerMathias Stearn <mathias@10gen.com>2016-05-09 17:52:12 -0400
commit26586d84484c16f3d5aa7ab4cad87552e4b8bc5f (patch)
treefbfd4e3fd4e3280cc28914d0664e9469a775e96f /src
parentfb439046f73ce10b862750df853746c41e9e2e81 (diff)
downloadmongo-26586d84484c16f3d5aa7ab4cad87552e4b8bc5f.tar.gz
SERVER-24082 Move std::string construction into Status constructor
Previously it was done at every call site that used string literals.
Diffstat (limited to 'src')
-rw-r--r--src/mongo/base/status.cpp7
-rw-r--r--src/mongo/base/status.h12
-rw-r--r--src/mongo/base/status_with.h8
3 files changed, 27 insertions, 0 deletions
diff --git a/src/mongo/base/status.cpp b/src/mongo/base/status.cpp
index b3014ccf2fa..ca78c051261 100644
--- a/src/mongo/base/status.cpp
+++ b/src/mongo/base/status.cpp
@@ -26,6 +26,7 @@
*/
#include "mongo/base/status.h"
+#include "mongo/util/mongoutils/str.h"
#include <ostream>
#include <sstream>
@@ -45,6 +46,12 @@ Status::Status(ErrorCodes::Error code, std::string reason, int location)
ref(_error);
}
+Status::Status(ErrorCodes::Error code, const char* reason, int location)
+ : Status(code, std::string(reason), location) {}
+
+Status::Status(ErrorCodes::Error code, const mongoutils::str::stream& reason, int location)
+ : Status(code, std::string(reason), location) {}
+
bool Status::compare(const Status& other) const {
return code() == other.code() && location() == other.location();
}
diff --git a/src/mongo/base/status.h b/src/mongo/base/status.h
index 63ef2785913..b54031a04d4 100644
--- a/src/mongo/base/status.h
+++ b/src/mongo/base/status.h
@@ -34,6 +34,12 @@
#include "mongo/base/error_codes.h"
#include "mongo/platform/atomic_word.h"
+namespace mongoutils {
+namespace str {
+class stream;
+}
+}
+
namespace mongo {
/**
@@ -72,6 +78,12 @@ public:
MONGO_COMPILER_COLD_FUNCTION Status(ErrorCodes::Error code,
std::string reason,
int location = 0);
+ MONGO_COMPILER_COLD_FUNCTION Status(ErrorCodes::Error code,
+ const char* reason,
+ int location = 0);
+ MONGO_COMPILER_COLD_FUNCTION Status(ErrorCodes::Error code,
+ const mongoutils::str::stream& reason,
+ int location = 0);
inline Status(const Status& other);
inline Status& operator=(const Status& other);
diff --git a/src/mongo/base/status_with.h b/src/mongo/base/status_with.h
index 2b2dff99d28..66880385ab4 100644
--- a/src/mongo/base/status_with.h
+++ b/src/mongo/base/status_with.h
@@ -71,6 +71,14 @@ public:
std::string reason,
int location = 0)
: _status(code, std::move(reason), location) {}
+ MONGO_COMPILER_COLD_FUNCTION StatusWith(ErrorCodes::Error code,
+ const char* reason,
+ int location = 0)
+ : _status(code, reason, location) {}
+ MONGO_COMPILER_COLD_FUNCTION StatusWith(ErrorCodes::Error code,
+ const mongoutils::str::stream& reason,
+ int location = 0)
+ : _status(code, reason, location) {}
/**
* for the error case