]> git.lyx.org Git - lyx.git/blob - src/support/LAssert.h
Fix the texinfo dialog and associated cleanup.
[lyx.git] / src / support / LAssert.h
1 // -*- C++ -*-
2 /**
3  * \file LAssert.C
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjønnes
8  *
9  * Full author contact details are available in file CREDITS
10  */
11
12 #ifndef LASSERT_H
13 #define LASSERT_H
14
15 #include "support/lyxlib.h"
16
17 extern void emergencyCleanup();
18
19 namespace lyx {
20
21 #ifdef ENABLE_ASSERTIONS
22
23 /** Live assertion.
24     This is a debug tool to ensure that the assertion holds. If it don't hole
25     we run #emergencyCleanup()# and then #lyx::abort".
26     @param assertion this should evaluate to true unless you want an abort.
27 */
28 template<class A>
29 inline
30 void Assert(A assertion)
31 {
32         if (!assertion) {
33                 ::emergencyCleanup();
34                 lyx::abort();
35         }
36 }
37
38 #else
39
40 /** Dummy assertion.
41     When compiling without assertions we use this no-op function.
42 */
43 template<class A>
44 inline
45 void Assert(A /*assertion*/) {}
46
47 #endif /* ENABLE_ASSERTIONS */
48
49 } // end of namespace LyX
50
51 #endif /* LASSERT_H */