00001
00029 #ifndef ITASSERT_H
00030 #define ITASSERT_H
00031
00032 #include <sstream>
00033 #include <string>
00034
00035
00036 namespace itpp
00037 {
00038
00066
00067
00069 void it_assert_f(std::string ass, std::string msg, std::string file, int line);
00071 void it_error_f(std::string msg, std::string file, int line);
00073 void it_info_f(std::string msg);
00075 void it_warning_f(std::string msg, std::string file, int line);
00076
00078 void it_enable_exceptions(bool on);
00080 void it_enable_warnings();
00082 void it_disable_warnings();
00084 void it_redirect_warnings(std::ostream *warn_stream);
00085
00087 enum error_msg_style { Full, Minimum };
00088
00090 void it_error_msg_style(error_msg_style style);
00091
00092
00094 #define it_assert(t,s) \
00095 if (!(t)) { \
00096 std::ostringstream m_sout; \
00097 m_sout << s; \
00098 itpp::it_assert_f(#t,m_sout.str(),__FILE__,__LINE__); \
00099 } else \
00100 ((void) 0)
00101
00102 #if defined(NDEBUG)
00104 # define it_assert_debug(t,s) ((void) 0)
00105 #else
00107 # define it_assert_debug(t,s) it_assert(t,s)
00108 #endif // if defined(NDEBUG)
00109
00111 #define it_assert0(t,s) it_assert_debug(t,s)
00113 #define it_assert1(t,s) it_assert_debug(t,s)
00114
00115
00117 #define it_error_if(t,s) \
00118 if((t)) { \
00119 std::ostringstream m_sout; \
00120 m_sout << s; \
00121 itpp::it_error_f(m_sout.str(),__FILE__,__LINE__); \
00122 } else \
00123 ((void) 0)
00124
00126 #define it_error(s) \
00127 if (true) { \
00128 std::ostringstream m_sout; \
00129 m_sout << s; \
00130 itpp::it_error_f(m_sout.str(),__FILE__,__LINE__); \
00131 } else \
00132 ((void) 0)
00133
00134
00136 #define it_info(s) \
00137 if (true) { \
00138 std::ostringstream m_sout; \
00139 m_sout << s << std::endl; \
00140 itpp::it_info_f(m_sout.str()); \
00141 } else \
00142 ((void) 0)
00143
00145 #define it_info_no_endl(s) \
00146 if (true) { \
00147 std::ostringstream m_sout; \
00148 m_sout << s; \
00149 itpp::it_info_f(m_sout.str()); \
00150 } else \
00151 ((void) 0)
00152
00153 #if defined(NDEBUG)
00155 # define it_info_debug(s) ((void) 0)
00156
00160 # define it_info_no_endl_debug(s) ((void) 0)
00161 #else
00163 # define it_info_debug(s) it_info(s)
00164
00168 # define it_info_no_endl_debug(s) it_info_no_endl(s)
00169 #endif // if defined(NDEBUG)
00170
00171
00173 #define it_warning(s) \
00174 if (true) { \
00175 std::ostringstream m_sout; \
00176 m_sout << s; \
00177 itpp::it_warning_f(m_sout.str(),__FILE__,__LINE__); \
00178 } else \
00179 ((void) 0)
00180
00182
00183 }
00184
00185 #endif // #ifndef ITASSERT_H