DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
Assert.h
1
16
17
#pragma once
18
29
30
#if defined(Assert_RECURSES)
31
#error Recursive header files inclusion detected in Assert.h
32
#else
// defined(Assert_RECURSES)
34
#define Assert_RECURSES
35
36
#if !defined Assert_h
38
#define Assert_h
39
41
// Inclusions
43
#include "DGtal/base/Trace.h"
44
#include <boost/current_function.hpp>
45
#include <string>
46
47
namespace
DGtal
48
{
49
57
58
extern
Trace
trace
;
59
60
#if defined(NDEBUG)
61
#define ASSERT(expr) ((void)0)
62
#else
63
inline
64
void
65
assert_failed
(
const
std::string& expr,
const
std::string& function,
const
std::string& file,
long
int
line)
66
{
67
trace
.
error
()
68
<<
" Assertion Error - assertion ("
<< expr <<
") failed in "
<< function <<
": "
69
<< file <<
'('
<< line <<
")"
<< std::endl;
70
std::abort();
71
}
72
#define ASSERT(expr) ((expr) ? ((void)0) : ::DGtal::assert_failed(#expr, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
73
#endif
74
75
76
#if defined(NDEBUG)
77
#define ASSERT_MSG(expr, msg) ((void)0)
78
#else
79
inline
80
void
81
assert_failed_message
(
const
std::string& expr,
const
std::string& message,
const
std::string& function,
const
std::string& file,
long
int
line)
82
{
83
trace
.
error
()
84
<<
" Assertion Error - assertion ("
<< expr <<
") failed in "
<< function <<
": "
85
<< file <<
'('
<< line <<
"): "
<< std::endl << message << std::endl;
86
std::abort();
87
}
88
#define ASSERT_MSG(expr,msg) ((expr) ? ((void)0) : ::DGtal::assert_failed_message(#expr, msg, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
89
#endif
90
91
inline
92
void
93
fatal_error_failed
(
const
std::string& expr,
const
std::string& function,
const
std::string& file,
long
int
line)
94
{
95
trace
.
error
()
96
<<
" Fatal Error - assertion ("
<< expr <<
") failed in "
<< function <<
": "
97
<< file <<
'('
<< line <<
")"
<< std::endl;
98
std::abort();
99
}
100
#define FATAL_ERROR(expr) ((expr) ? ((void)0) : ::DGtal::fatal_error_failed(#expr, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
101
102
inline
103
void
104
fatal_error_failed_message
(
const
std::string& expr,
const
std::string& message,
const
std::string& function,
const
std::string& file,
long
int
line)
105
{
106
trace
.
error
()
107
<<
" Fatal Error - assertion ("
<< expr <<
") failed in "
<< function <<
": "
108
<< file <<
'('
<< line <<
"): "
<< std::endl << message << std::endl;
109
std::abort();
110
}
111
#define FATAL_ERROR_MSG(expr,msg) ((expr) ? ((void)0) : ::DGtal::fatal_error_failed_message(#expr,msg, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
112
113
}
// namespace DGtal
114
115
#endif
// !defined Assert_h
116
117
#undef Assert_RECURSES
118
#endif
// else defined(Assert_RECURSES)
DGtal::Trace
implementation of basic methods to trace out messages with indentation levels.
Definition
Trace.h:74
DGtal::Trace::error
std::ostream & error()
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
DGtal::fatal_error_failed_message
void fatal_error_failed_message(const std::string &expr, const std::string &message, const std::string &function, const std::string &file, long int line)
Definition
Assert.h:104
DGtal::fatal_error_failed
void fatal_error_failed(const std::string &expr, const std::string &function, const std::string &file, long int line)
Definition
Assert.h:93
DGtal::assert_failed
void assert_failed(const std::string &expr, const std::string &function, const std::string &file, long int line)
Definition
Assert.h:65
DGtal::trace
Trace trace
DGtal::assert_failed_message
void assert_failed_message(const std::string &expr, const std::string &message, const std::string &function, const std::string &file, long int line)
Definition
Assert.h:81
src
DGtal
base
Assert.h
Generated on
for DGtal by
1.18.0