1999-10-02 16:21:10 +00:00
|
|
|
// -*- C++ -*-
|
1999-11-22 16:19:48 +00:00
|
|
|
#ifndef LASSERT_H
|
|
|
|
#define LASSERT_H
|
1999-10-02 16:21:10 +00:00
|
|
|
|
2000-01-17 21:01:30 +00:00
|
|
|
#include "support/lyxlib.h"
|
|
|
|
|
2001-04-24 15:25:26 +00:00
|
|
|
extern void emergencySave();
|
1999-10-02 16:21:10 +00:00
|
|
|
|
2001-04-24 15:25:26 +00:00
|
|
|
namespace lyx {
|
1999-12-16 14:16:42 +00:00
|
|
|
|
2001-04-24 15:25:26 +00:00
|
|
|
#ifdef ENABLE_ASSERTIONS
|
2000-06-12 11:27:15 +00:00
|
|
|
|
2000-08-07 20:58:24 +00:00
|
|
|
/** Live assertion.
|
|
|
|
This is a debug tool to ensure that the assertion holds. If it don't hole
|
|
|
|
we run #emergencySave()# and then #lyx::abort".
|
|
|
|
@param assertion this should evaluate to true unless you want an abort.
|
|
|
|
*/
|
2000-03-07 01:14:37 +00:00
|
|
|
template<class A>
|
|
|
|
inline
|
|
|
|
void Assert(A assertion)
|
1999-10-02 16:21:10 +00:00
|
|
|
{
|
|
|
|
if (!assertion) {
|
2000-06-12 11:27:15 +00:00
|
|
|
::emergencySave();
|
2000-01-17 21:01:30 +00:00
|
|
|
lyx::abort();
|
1999-10-02 16:21:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2000-08-07 20:58:24 +00:00
|
|
|
/** Dummy assertion.
|
|
|
|
When compiling without assertions we use this no-op function.
|
|
|
|
*/
|
2000-03-07 01:14:37 +00:00
|
|
|
template<class A>
|
|
|
|
inline
|
|
|
|
void Assert(A /*assertion*/) {}
|
1999-12-16 14:16:42 +00:00
|
|
|
|
|
|
|
#endif /* ENABLE_ASSERTIONS */
|
1999-10-02 16:21:10 +00:00
|
|
|
|
2001-04-24 15:25:26 +00:00
|
|
|
} // end of namespace LyX
|
|
|
|
|
1999-12-16 14:16:42 +00:00
|
|
|
#endif /* LASSERT_H */
|