convert massert and uassert back to macros

This commit is contained in:
Mathias Stearn
2010-05-14 13:33:16 -04:00
parent e8a8a31b18
commit d060bfb595
6 changed files with 10 additions and 35 deletions

View File

@@ -29,6 +29,8 @@
#define assert MONGO_assert
#define dassert MONGO_dassert
#define wassert MONGO_wassert
#define massert MONGO_massert
#define uassert MONGO_uassert
#define BOOST_CHECK_EXCEPTION MONGO_BOOST_CHECK_EXCEPTION
#define DESTRUCTOR_GUARD MONGO_DESTRUCTOR_GUARD

View File

@@ -33,6 +33,8 @@
#undef assert
#undef dassert
#undef wassert
#undef massert
#undef uassert
#undef BOOST_CHECK_EXCEPTION
#undef DESTRUCTOR_GUARD

View File

@@ -417,7 +417,7 @@ namespace mongo {
uassert( 13068 , "geo field only has 1 element" , i.more() );
BSONElement y = i.next();
uassert( 13026 , "geo values have to be numbers" , o , x.isNumber() && y.isNumber() );
uassert( 13026 , "geo values have to be numbers: " + o.toString() , x.isNumber() && y.isNumber() );
return _hash( x.number() , y.number() );
}

View File

@@ -1065,7 +1065,7 @@ namespace mongo {
BSONObj last = conn->findOne( _ns.c_str(), Query( b.done() ).sort( BSON( "$natural" << -1 ) ) );
if ( !last.isEmpty() ) {
BSONElement ts = last.getField( "ts" );
massert( 10386 , "non Date ts found", last, ts.type() == Date || ts.type() == Timestamp );
massert( 10386 , "non Date ts found: " + last.toString(), ts.type() == Date || ts.type() == Timestamp );
syncedTo = OpTime( ts.date() );
}
}

View File

@@ -68,7 +68,6 @@ using mongo::BufBuilder;
using mongo::DBClientConnection;
using mongo::QueryResult;
using mongo::MemoryMappedFile;
using mongo::uassert;
#define SNAP_LEN 65535

View File

@@ -166,23 +166,8 @@ namespace mongo {
#define assert MONGO_assert
/* "user assert". if asserts, user did something wrong, not our code */
inline void uassert(unsigned msgid, string msg, bool expr) {
if( !expr ) uasserted(msgid, msg.c_str());
}
template<class T>
inline void uassert(unsigned msgid, string msg, const T&t , bool expr) {
if( !expr ){
stringstream ss;
ss << msg << " " << t.toString();
uasserted(msgid, ss.str());
}
}
inline void uassert(unsigned msgid, const char * msg, bool expr) {
if( !expr ) uasserted(msgid, msg);
}
#define MONGO_uassert(msgid, msg, expr) (void)( (!!(expr)) || (mongo::uasserted(msgid, msg), 0) )
#define uassert MONGO_uassert
/* warning only - keeps going */
#define MONGO_wassert(_Expression) (void)( (!!(_Expression)) || (mongo::wasserted(#_Expression, __FILE__, __LINE__), 0) )
@@ -193,21 +178,8 @@ namespace mongo {
easy way to throw an exception and log something without our stack trace
display happening.
*/
inline void massert(unsigned msgid, string msg, bool expr) {
if( !expr) msgasserted(msgid, msg.c_str());
}
inline void massert(unsigned msgid, const char * msg, bool expr) {
if( !expr) msgasserted(msgid, msg);
}
template<typename T>
inline void massert(unsigned msgid, const string& msg, const T& t, bool expr) {
if ( ! expr ){
stringstream ss;
ss << msg << " " << (string)t;
string s = ss.str();
msgasserted( msgid, s.c_str() );
}
}
#define MONGO_massert(msgid, msg, expr) (void)( (!!(expr)) || (mongo::msgasserted(msgid, msg), 0) )
#define massert MONGO_massert
/* dassert is 'debug assert' -- might want to turn off for production as these
could be slow.