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
36namespace itpp
37{
38
67
69ITPP_EXPORT void it_assert_f(std::string ass, std::string msg, std::string file, int line);
71ITPP_EXPORT void it_error_f(std::string msg, std::string file, int line);
73ITPP_EXPORT void it_info_f(std::string msg);
75ITPP_EXPORT void it_warning_f(std::string msg, std::string file, int line);
76
85
87enum error_msg_style { Full, Minimum };
88
90ITPP_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)
104# define it_assert_debug(t,s) ((void) (t))
105#else
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)
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)
155# define it_info_debug(s) ((void) 0)
160# define it_info_no_endl_debug(s) ((void) 0)
161#else
163# define it_info_debug(s) it_info(s)
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
General array class.
Definition array.h:105
void it_disable_warnings()
Disable warnings.
Definition itassert.cpp:109
error_msg_style
Style of assert, error and warning messages.
Definition itassert.h:87
void it_enable_warnings()
Enable warnings.
Definition itassert.cpp:104
void it_warning_f(std::string msg, std::string file, int line)
Helper function for the it_warning macro.
Definition itassert.cpp:91
void it_error_msg_style(error_msg_style style)
Set preferred style of assert, error and warning messages.
Definition itassert.cpp:119
void it_error_f(std::string msg, std::string file, int line)
Helper function for the it_error and it_error_if macros.
Definition itassert.cpp:68
void it_redirect_warnings(std::ostream *warn_stream)
Redirect warnings to the ostream warn_stream.
Definition itassert.cpp:114
ITPP_EXPORT void it_enable_exceptions(bool on)
Enable/disable using exceptions for error handling.
void it_assert_f(std::string ass, std::string msg, std::string file, int line)
Helper function for the it_assert and it_assert_debug macros.
Definition itassert.cpp:50
void it_info_f(std::string msg)
Helper function for the it_info and it_info_debug macros.
Definition itassert.cpp:86
itpp namespace
Definition itmex.h:37
SourceForge Logo

Generated on Mon Jun 10 2024 11:49:17 for IT++ by Doxygen 1.9.8