KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Assert.h
Go to the documentation of this file.
1 
2 #include <stdexcept>
3 #include <sstream>
4 #include <assert.h>
5 
6 #ifndef ASSERT_H
7 #define ASSERT_H
8 
10 #define RASSERT(condition, message)\
11  EXCEPTION_ASSERT(std::runtime_error, condition, message)
12 
14 #define LASSERT(condition, message)\
15  EXCEPTION_ASSERT(std::logic_error, condition, message)
16 
18 #define RVASSERT(condition, message)\
19  VERBOSE_EXCEPTION_ASSERT(std::runtime_error, condition, message)
20 
22 #define LVASSERT(condition, message)\
23  VERBOSE_EXCEPTION_ASSERT(std::logic_error, condition, message)
24 
26 #define EXCEPTION_ASSERT(type, condition, message){\
27  if((condition) == false){\
28  std::ostringstream buffer;\
29  buffer << "ERROR in file " << __FILE__ << " line " << __LINE__ << ": " << message;\
30  throw type(buffer.str());\
31  }\
32 }\
33 
34 
35 #define VERBOSE_EXCEPTION_ASSERT(type, condition, message){\
36  if((condition) == false){\
37  std::ostringstream buffer;\
38  buffer << "ERROR in file " << __FILE__ << " line " << __LINE__ << ": " << message;\
39  std::cerr << buffer.str() << endl;\
40  throw type(buffer.str());\
41  }\
42 }\
43 
44 
45 #define ASSERT(condition, message) assert(condition)
46 
47 #endif