IT++ Logo
itassert.h
Go to the documentation of this file.
1 
29 #ifndef ITASSERT_H
30 #define ITASSERT_H
31 
32 #include <sstream>
33 #include <string>
34 #include <itpp/itexports.h>
35 
36 namespace itpp
37 {
38 
66 
67 
69 ITPP_EXPORT void it_assert_f(std::string ass, std::string msg, std::string file, int line);
71 ITPP_EXPORT void it_error_f(std::string msg, std::string file, int line);
73 ITPP_EXPORT void it_info_f(std::string msg);
75 ITPP_EXPORT void it_warning_f(std::string msg, std::string file, int line);
76 
78 ITPP_EXPORT void it_enable_exceptions(bool on);
80 ITPP_EXPORT void it_enable_warnings();
82 ITPP_EXPORT void it_disable_warnings();
84 ITPP_EXPORT void it_redirect_warnings(std::ostream *warn_stream);
85 
87 enum error_msg_style { Full, Minimum };
88 
90 ITPP_EXPORT void it_error_msg_style(error_msg_style style);
91 
92 
94 #define it_assert(t,s) \
95  if (!(t)) { \
96  std::ostringstream m_sout; \
97  m_sout << s; \
98  itpp::it_assert_f(#t,m_sout.str(),__FILE__,__LINE__); \
99  } else \
100  ((void) 0)
101 
102 #if defined(NDEBUG)
103 
104 # define it_assert_debug(t,s) ((void) (t))
105 #else
106 
107 # define it_assert_debug(t,s) it_assert(t,s)
108 #endif // if defined(NDEBUG)
109 
111 #define it_assert0(t,s) it_assert_debug(t,s)
112 
113 #define it_assert1(t,s) it_assert_debug(t,s)
114 
115 
117 #define it_error_if(t,s) \
118  if((t)) { \
119  std::ostringstream m_sout; \
120  m_sout << s; \
121  itpp::it_error_f(m_sout.str(),__FILE__,__LINE__); \
122  } else \
123  ((void) 0)
124 
126 #define it_error(s) \
127  if (true) { \
128  std::ostringstream m_sout; \
129  m_sout << s; \
130  itpp::it_error_f(m_sout.str(),__FILE__,__LINE__); \
131  } else \
132  ((void) 0)
133 
134 
136 #define it_info(s) \
137  if (true) { \
138  std::ostringstream m_sout; \
139  m_sout << s << std::endl; \
140  itpp::it_info_f(m_sout.str()); \
141  } else \
142  ((void) 0)
143 
145 #define it_info_no_endl(s) \
146  if (true) { \
147  std::ostringstream m_sout; \
148  m_sout << s; \
149  itpp::it_info_f(m_sout.str()); \
150  } else \
151  ((void) 0)
152 
153 #if defined(NDEBUG)
154 
155 # define it_info_debug(s) ((void) 0)
156 
160 # define it_info_no_endl_debug(s) ((void) 0)
161 #else
162 
163 # define it_info_debug(s) it_info(s)
164 
168 # define it_info_no_endl_debug(s) it_info_no_endl(s)
169 #endif // if defined(NDEBUG)
170 
171 
173 #define it_warning(s) \
174  if (true) { \
175  std::ostringstream m_sout; \
176  m_sout << s; \
177  itpp::it_warning_f(m_sout.str(),__FILE__,__LINE__); \
178  } else \
179  ((void) 0)
180 
182 
183 } // namespace itpp
184 
185 #endif // #ifndef ITASSERT_H
SourceForge Logo

Generated on Sat Jul 6 2013 10:54:20 for IT++ by Doxygen 1.8.2