mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
less defines - use inlines instead. uassert etc.
This commit is contained in:
parent
07757ed88a
commit
66039bd827
@ -28,10 +28,7 @@
|
||||
// util/assert_util.h
|
||||
#define assert MONGO_assert
|
||||
#define dassert MONGO_dassert
|
||||
#define massert MONGO_massert
|
||||
#define uassert MONGO_uassert
|
||||
#define wassert MONGO_wassert
|
||||
#define ASSERT_STREAM_GOOD MONGO_ASSERT_STREAM_GOOD
|
||||
#define BOOST_CHECK_EXCEPTION MONGO_BOOST_CHECK_EXCEPTION
|
||||
#define DESTRUCTOR_GUARD MONGO_DESTRUCTOR_GUARD
|
||||
|
||||
|
@ -1010,6 +1010,10 @@
|
||||
RelativePath="..\client\model.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\client\redef_macros.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\client\syncclusterconnection.cpp"
|
||||
>
|
||||
|
@ -126,7 +126,7 @@ namespace mongo {
|
||||
|
||||
ofstream out;
|
||||
out.open( file.c_str() , ios_base::out | ios_base::binary );
|
||||
ASSERT_STREAM_GOOD( 10051 , (string)"couldn't open file: " + file , out );
|
||||
assertStreamGood( 10051 , (string)"couldn't open file: " + file , out );
|
||||
|
||||
int num = 0;
|
||||
for ( InMemory::iterator i=_cur->begin(); i != _cur->end(); ++i ){
|
||||
|
@ -108,11 +108,10 @@ namespace mongo {
|
||||
stringstream ss;
|
||||
// errno might not work on all systems for streams
|
||||
// if it doesn't for a system should deal with here
|
||||
ss << msg << " stream invalie: " << errnoWithDescription();
|
||||
ss << msg << " stream invalid: " << errnoWithDescription();
|
||||
throw UserException( code , ss.str() );
|
||||
}
|
||||
|
||||
|
||||
mongo::mutex *Assertion::_mutex = new mongo::mutex();
|
||||
|
||||
string Assertion::toString() {
|
||||
|
@ -162,8 +162,12 @@ namespace mongo {
|
||||
#define assert MONGO_assert
|
||||
|
||||
/* "user assert". if asserts, user did something wrong, not our code */
|
||||
#define MONGO_uassert(msgid, msg,_Expression) (void)( (!!(_Expression)) || (mongo::uasserted(msgid, msg), 0) )
|
||||
#define uassert MONGO_uassert
|
||||
inline void uassert(unsigned msgid, string msg, bool expr) {
|
||||
if( !expr ) uasserted(msgid, msg.c_str());
|
||||
}
|
||||
inline void uassert(unsigned msgid, const char * msg, bool expr) {
|
||||
if( !expr ) uasserted(msgid, msg);
|
||||
}
|
||||
|
||||
/* warning only - keeps going */
|
||||
#define MONGO_wassert(_Expression) (void)( (!!(_Expression)) || (mongo::wasserted(#_Expression, __FILE__, __LINE__), 0) )
|
||||
@ -174,8 +178,12 @@ namespace mongo {
|
||||
easy way to throw an exception and log something without our stack trace
|
||||
display happening.
|
||||
*/
|
||||
#define MONGO_massert(msgid, msg,_Expression) (void)( (!!(_Expression)) || (mongo::msgasserted(msgid, msg), 0) )
|
||||
#define massert MONGO_massert
|
||||
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);
|
||||
}
|
||||
|
||||
/* dassert is 'debug assert' -- might want to turn off for production as these
|
||||
could be slow.
|
||||
@ -194,10 +202,12 @@ namespace mongo {
|
||||
|
||||
enum { ASSERT_ID_DUPKEY = 11000 };
|
||||
|
||||
/* throws a uassertion with an appropriate msg */
|
||||
void streamNotGood( int code , string msg , std::ios& myios );
|
||||
|
||||
#define MONGO_ASSERT_STREAM_GOOD(msgid,msg,stream) (void)( (!!((stream).good())) || (mongo::streamNotGood(msgid, msg, stream), 0) )
|
||||
#define ASSERT_STREAM_GOOD MONGO_ASSERT_STREAM_GOOD
|
||||
inline void assertStreamGood(unsigned msgid, string msg, std::ios& myios) {
|
||||
if( !myios.good() ) streamNotGood(msgid, msg, myios);
|
||||
}
|
||||
|
||||
} // namespace mongo
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user