00001 
00013 #ifndef bdmerror_h
00014 #define bdmerror_h
00015 
00016 
00017 
00018 #include <sstream>
00019 #include <string>
00020 
00021 namespace bdm {
00022 
00024 void bdm_assert_f(const std::string &ass, const std::string &msg, const std::string &file, int line);
00025 
00027 void bdm_error_f(const std::string &msg, const std::string &file, int line);
00028 
00030 void bdm_warning_f(const std::string &msg, const std::string &file, int line);
00031 
00032 }
00033 
00035 #define bdm_assert(t, s) \
00036         if (!(t)) { \
00037                 std::ostringstream bdm_out; \
00038                 bdm_out << s; \
00039                 bdm::bdm_assert_f(#t, bdm_out.str(), __FILE__, __LINE__); \
00040         } else ((void) 0)
00041 
00042 #if defined(NDEBUG)
00044 #define bdm_assert_debug(t, s) ((void) 0)
00045 #else
00047 #define bdm_assert_debug(t, s) bdm_assert(t, s)
00048 #endif // if defined(NDEBUG)
00049 
00051 #define bdm_error(s) \
00052         if (true) { \
00053                 std::ostringstream bdm_out; \
00054                 bdm_out << s; \
00055                 bdm::bdm_error_f(bdm_out.str(), __FILE__, __LINE__); \
00056         } else ((void) 0)
00057 
00059 #define bdm_warning(s) \
00060         if (true) { \
00061                 std::ostringstream bdm_out; \
00062                 bdm_out << s; \
00063                 bdm::bdm_warning_f(bdm_out.str(), __FILE__, __LINE__); \
00064         } else ((void) 0)
00065 
00066 #endif
00067