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 {
00045 
00073 
00074 
00076 void it_assert_f(std::string ass, std::string msg, std::string file, int line);
00078 void it_error_f(std::string msg, std::string file, int line);
00080 void it_info_f(std::string msg);
00082 void it_warning_f(std::string msg, std::string file, int line);
00083 
00085 void it_enable_exceptions(bool on);
00087 void it_enable_warnings();
00089 void it_disable_warnings();
00091 void it_redirect_warnings(std::ostream *warn_stream);
00092 
00094 enum error_msg_style { Full, Minimum };
00095 
00097 void it_error_msg_style(error_msg_style style);
00098 
00099 
00101 #define it_assert(t,s)      \
00102   if (!(t)) {       \
00103     std::ostringstream m_sout;     \
00104     m_sout << s;      \
00105     itpp::it_assert_f(#t,m_sout.str(),__FILE__,__LINE__); \
00106   } else       \
00107     ((void) 0)
00108 
00109 #if defined(NDEBUG)
00111 #  define it_assert_debug(t,s) ((void) 0)
00112 #else
00114 #  define it_assert_debug(t,s) it_assert(t,s)
00115 #endif // if defined(NDEBUG)
00116 
00118 #define it_assert0(t,s) it_assert_debug(t,s)
00120 #define it_assert1(t,s) it_assert_debug(t,s)
00121 
00122 
00124 #define it_error_if(t,s)    \
00125   if((t)) {      \
00126     std::ostringstream m_sout;    \
00127     m_sout << s;     \
00128     itpp::it_error_f(m_sout.str(),__FILE__,__LINE__); \
00129   } else      \
00130     ((void) 0)
00131 
00133 #define it_error(s)     \
00134   if (true) {      \
00135     std::ostringstream m_sout;    \
00136     m_sout << s;     \
00137     itpp::it_error_f(m_sout.str(),__FILE__,__LINE__); \
00138   } else      \
00139     ((void) 0)
00140 
00141 
00143 #define it_info(s)    \
00144   if (true) {     \
00145     std::ostringstream m_sout;   \
00146     m_sout << s << std::endl;   \
00147     itpp::it_info_f(m_sout.str());  \
00148   } else     \
00149     ((void) 0)
00150 
00152 #define it_info_no_endl(s)   \
00153   if (true) {     \
00154     std::ostringstream m_sout;   \
00155     m_sout << s;    \
00156     itpp::it_info_f(m_sout.str());  \
00157   } else     \
00158     ((void) 0)
00159 
00160 #if defined(NDEBUG)
00162 #  define it_info_debug(s) ((void) 0)
00163 
00167 #  define it_info_no_endl_debug(s) ((void) 0)
00168 #else
00170 #  define it_info_debug(s) it_info(s)
00171 
00175 #  define it_info_no_endl_debug(s) it_info_no_endl(s)
00176 #endif // if defined(NDEBUG)
00177 
00178 
00180 #define it_warning(s)     \
00181   if (true) {      \
00182     std::ostringstream m_sout;    \
00183     m_sout << s;     \
00184     itpp::it_warning_f(m_sout.str(),__FILE__,__LINE__); \
00185   } else      \
00186     ((void) 0)
00187 
00189 
00190 } // namespace itpp
00191 
00192 #endif // #ifndef ITASSERT_H
SourceForge Logo

Generated on Fri Jul 25 12:42:57 2008 for IT++ by Doxygen 1.5.4