00001 00030 #ifndef ITASSERT_H 00031 #define ITASSERT_H 00032 00033 #include <sstream> 00034 #include <string> 00035 00036 00037 namespace itpp 00038 { 00039 00067 00068 00070 void it_assert_f(std::string ass, std::string msg, std::string file, int line); 00072 void it_error_f(std::string msg, std::string file, int line); 00074 void it_info_f(std::string msg); 00076 void it_warning_f(std::string msg, std::string file, int line); 00077 00079 void it_enable_exceptions(bool on); 00081 void it_enable_warnings(); 00083 void it_disable_warnings(); 00085 void it_redirect_warnings(std::ostream *warn_stream); 00086 00088 enum error_msg_style { Full, Minimum }; 00089 00091 void it_error_msg_style(error_msg_style style); 00092 00093 00095 #define it_assert(t,s) \ 00096 if (!(t)) { \ 00097 std::ostringstream m_sout; \ 00098 m_sout << s; \ 00099 itpp::it_assert_f(#t,m_sout.str(),__FILE__,__LINE__); \ 00100 } else \ 00101 ((void) 0) 00102 00103 #if defined(NDEBUG) 00105 # define it_assert_debug(t,s) ((void) 0) 00106 #else 00108 # define it_assert_debug(t,s) it_assert(t,s) 00109 #endif // if defined(NDEBUG) 00110 00112 #define it_assert0(t,s) it_assert_debug(t,s) 00114 #define it_assert1(t,s) it_assert_debug(t,s) 00115 00116 00118 #define it_error_if(t,s) \ 00119 if((t)) { \ 00120 std::ostringstream m_sout; \ 00121 m_sout << s; \ 00122 itpp::it_error_f(m_sout.str(),__FILE__,__LINE__); \ 00123 } else \ 00124 ((void) 0) 00125 00127 #define it_error(s) \ 00128 if (true) { \ 00129 std::ostringstream m_sout; \ 00130 m_sout << s; \ 00131 itpp::it_error_f(m_sout.str(),__FILE__,__LINE__); \ 00132 } else \ 00133 ((void) 0) 00134 00135 00137 #define it_info(s) \ 00138 if (true) { \ 00139 std::ostringstream m_sout; \ 00140 m_sout << s << std::endl; \ 00141 itpp::it_info_f(m_sout.str()); \ 00142 } else \ 00143 ((void) 0) 00144 00146 #define it_info_no_endl(s) \ 00147 if (true) { \ 00148 std::ostringstream m_sout; \ 00149 m_sout << s; \ 00150 itpp::it_info_f(m_sout.str()); \ 00151 } else \ 00152 ((void) 0) 00153 00154 #if defined(NDEBUG) 00156 # define it_info_debug(s) ((void) 0) 00157 00161 # define it_info_no_endl_debug(s) ((void) 0) 00162 #else 00164 # define it_info_debug(s) it_info(s) 00165 00169 # define it_info_no_endl_debug(s) it_info_no_endl(s) 00170 #endif // if defined(NDEBUG) 00171 00172 00174 #define it_warning(s) \ 00175 if (true) { \ 00176 std::ostringstream m_sout; \ 00177 m_sout << s; \ 00178 itpp::it_warning_f(m_sout.str(),__FILE__,__LINE__); \ 00179 } else \ 00180 ((void) 0) 00181 00183 00184 } // namespace itpp 00185 00186 #endif // #ifndef ITASSERT_H
Generated on Thu Apr 23 20:07:42 2009 for IT++ by Doxygen 1.5.8