IT++ Logo

itassert.h

Go to the documentation of this file.
00001 
00030 #ifndef ITASSERT_H
00031 #define ITASSERT_H
00032 
00033 #ifndef _MSC_VER
00034 #  include <itpp/config.h>
00035 #else
00036 #  include <itpp/config_msvc.h>
00037 #endif
00038 
00039 #include <sstream>
00040 #include <string>
00041 
00042 
00043 namespace itpp {
00044 
00072 
00073 
00075   void it_assert_f(std::string ass, std::string msg, std::string file, int line);
00077   void it_error_f(std::string msg, std::string file, int line);
00079   void it_info_f(std::string msg);
00081   void it_warning_f(std::string msg, std::string file, int line);
00082 
00084   void it_enable_exceptions(bool on);
00086   void it_enable_warnings();
00088   void it_disable_warnings();
00090   void it_redirect_warnings(std::ostream *warn_stream);
00091 
00093   enum error_msg_style { Full, Minimum };
00094 
00096   void it_error_msg_style(error_msg_style style);
00097 
00098 
00100 #define it_assert(t,s)                                          \
00101   if (!(t)) {                                                   \
00102     std::ostringstream m_sout;                                  \
00103     m_sout << s;                                                \
00104     itpp::it_assert_f(#t,m_sout.str(),__FILE__,__LINE__);       \
00105   } else                                                        \
00106     ((void) 0)
00107 
00108 #if defined(NDEBUG)
00110 #  define it_assert_debug(t,s) ((void) 0)
00111 #else
00113 #  define it_assert_debug(t,s) it_assert(t,s)
00114 #endif // if defined(NDEBUG)
00115 
00117 #define it_assert0(t,s) it_assert_debug(t,s)
00119 #define it_assert1(t,s) it_assert_debug(t,s)
00120 
00121 
00123 #define it_error_if(t,s)                                \
00124   if((t)) {                                             \
00125     std::ostringstream m_sout;                          \
00126     m_sout << s;                                        \
00127     itpp::it_error_f(m_sout.str(),__FILE__,__LINE__);   \
00128   } else                                                \
00129     ((void) 0)
00130 
00132 #define it_error(s)                                     \
00133   if (true) {                                           \
00134     std::ostringstream m_sout;                          \
00135     m_sout << s;                                        \
00136     itpp::it_error_f(m_sout.str(),__FILE__,__LINE__);   \
00137   } else                                                \
00138     ((void) 0)
00139 
00140 
00142 #define it_info(s)                              \
00143   if (true) {                                   \
00144     std::ostringstream m_sout;                  \
00145     m_sout << s << std::endl;                   \
00146     itpp::it_info_f(m_sout.str());              \
00147   } else                                        \
00148     ((void) 0)
00149 
00151 #define it_info_no_endl(s)                      \
00152   if (true) {                                   \
00153     std::ostringstream m_sout;                  \
00154     m_sout << s;                                \
00155     itpp::it_info_f(m_sout.str());              \
00156   } else                                        \
00157     ((void) 0)
00158 
00159 #if defined(NDEBUG)
00161 #  define it_info_debug(s) ((void) 0)
00162 
00166 #  define it_info_no_endl_debug(s) ((void) 0)
00167 #else
00169 #  define it_info_debug(s) it_info(s)
00170 
00174 #  define it_info_no_endl_debug(s) it_info_no_endl(s)
00175 #endif // if defined(NDEBUG)
00176 
00177 
00179 #define it_warning(s)                                   \
00180   if (true) {                                           \
00181     std::ostringstream m_sout;                          \
00182     m_sout << s;                                        \
00183     itpp::it_warning_f(m_sout.str(),__FILE__,__LINE__); \
00184   } else                                                \
00185     ((void) 0)
00186 
00188 
00189 } // namespace itpp
00190 
00191 #endif // #ifndef ITASSERT_H
SourceForge Logo

Generated on Mon Jan 7 22:28:55 2008 for IT++ by Doxygen 1.5.4