summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorAndrew Morrow <acm@10gen.com>2013-05-17 11:18:55 -0400
committerAndrew Morrow <acm@10gen.com>2013-05-22 19:52:25 -0400
commitb7c80ec25658288217947e3d4aaf1e27826bb578 (patch)
treef2b3d1898f486bfe429931f6b92ed27abd83f686 /src/mongo
parent214697c86ed2b1cad2a485f7ff810199bd69d674 (diff)
downloadmongo-b7c80ec25658288217947e3d4aaf1e27826bb578.tar.gz
SERVER-9757 Move Status inlines to inline header
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/base/status-inl.h36
-rw-r--r--src/mongo/base/status.h51
2 files changed, 53 insertions, 34 deletions
diff --git a/src/mongo/base/status-inl.h b/src/mongo/base/status-inl.h
index 3d50308c176..22679707b6c 100644
--- a/src/mongo/base/status-inl.h
+++ b/src/mongo/base/status-inl.h
@@ -17,6 +17,10 @@
namespace mongo {
+ inline Status Status::OK() {
+ return Status();
+ }
+
inline Status::Status(const Status& other)
: _error(other._error) {
ref(_error);
@@ -33,6 +37,30 @@ namespace mongo {
unref(_error);
}
+ inline bool Status::isOK() const {
+ return code() == ErrorCodes::OK;
+ }
+
+ inline ErrorCodes::Error Status::code() const {
+ return _error ? _error->code : ErrorCodes::OK;
+ }
+
+ inline const char* Status::codeString() const {
+ return ErrorCodes::errorString(code());
+ }
+
+ inline std::string Status::reason() const {
+ return _error ? _error->reason : std::string();
+ }
+
+ inline int Status::location() const {
+ return _error ? _error->location : 0;
+ }
+
+ inline AtomicUInt32::WordType Status::refCount() const {
+ return _error ? _error->refs.load() : 0;
+ }
+
inline Status::Status()
: _error(NULL) {
}
@@ -47,4 +75,12 @@ namespace mongo {
delete error;
}
+ inline bool operator==(const ErrorCodes::Error lhs, const Status& rhs) {
+ return rhs == lhs;
+ }
+
+ inline bool operator!=(const ErrorCodes::Error lhs, const Status& rhs) {
+ return rhs != lhs;
+ }
+
} // namespace mongo
diff --git a/src/mongo/base/status.h b/src/mongo/base/status.h
index 4454913e725..d4d0ba0f9bf 100644
--- a/src/mongo/base/status.h
+++ b/src/mongo/base/status.h
@@ -49,9 +49,7 @@ namespace mongo {
class Status {
public:
// Short-hand for returning an OK status.
- static Status OK() {
- return Status();
- }
+ static inline Status OK();
/**
* Builds an error status given the error code, a textual description of what
@@ -60,9 +58,11 @@ namespace mongo {
*/
Status(ErrorCodes::Error code, const std::string& reason, int location = 0);
Status(ErrorCodes::Error code, const char* reason, int location = 0);
- Status(const Status& other);
- Status& operator=(const Status& other);
- ~Status();
+
+ inline Status(const Status& other);
+ inline Status& operator=(const Status& other);
+
+ inline ~Status();
/**
* Returns true if 'other's error code and location are equal/different to this
@@ -84,25 +84,15 @@ namespace mongo {
// accessors
//
- bool isOK() const {
- return code() == ErrorCodes::OK;
- }
+ inline bool isOK() const;
- ErrorCodes::Error code() const {
- return _error ? _error->code : ErrorCodes::OK;
- }
+ inline ErrorCodes::Error code() const;
- const char* codeString() const {
- return ErrorCodes::errorString(code());
- }
+ inline const char* codeString() const;
- std::string reason() const {
- return _error ? _error->reason : std::string();
- }
+ inline std::string reason() const;
- int location() const {
- return _error ? _error->location : 0;
- }
+ inline int location() const;
std::string toString() const;
@@ -110,12 +100,10 @@ namespace mongo {
// Below interface used for testing code only.
//
- AtomicUInt32::WordType refCount() const {
- return _error ? _error->refs.load() : 0;
- }
+ inline AtomicUInt32::WordType refCount() const;
private:
- Status();
+ inline Status();
struct ErrorInfo {
AtomicUInt32 refs; // reference counter
@@ -136,17 +124,13 @@ namespace mongo {
*
* @param error ErrorInfo to be incremented
*/
- static void ref(ErrorInfo* error);
- static void unref(ErrorInfo* error);
+ static inline void ref(ErrorInfo* error);
+ static inline void unref(ErrorInfo* error);
};
- inline bool operator==(const ErrorCodes::Error lhs, const Status& rhs) {
- return rhs == lhs;
- }
+ inline bool operator==(const ErrorCodes::Error lhs, const Status& rhs);
- inline bool operator!=(const ErrorCodes::Error lhs, const Status& rhs) {
- return rhs != lhs;
- }
+ inline bool operator!=(const ErrorCodes::Error lhs, const Status& rhs);
//
// Convenience method for unittest code. Please use accessors otherwise.
@@ -158,4 +142,3 @@ namespace mongo {
} // namespace mongo
#include "mongo/base/status-inl.h"
-