| 1 |
sf-pippijn |
1.1 |
/* assert.hh |
| 2 |
|
|
* This file is part of ncursesxx library |
| 3 |
|
|
* Copyright (c) 2003,2004 by Stanislav Ievlev |
| 4 |
|
|
* |
| 5 |
|
|
* This file is covered by the GNU Library General Public License, |
| 6 |
|
|
* which should be included with libncursesxx as the file COPYING. |
| 7 |
|
|
*/ |
| 8 |
|
|
#ifndef NCURSESXX_ASSERT_HH__ |
| 9 |
|
|
#define NCURSESXX_ASSERT_HH__ |
| 10 |
|
|
|
| 11 |
|
|
#include <stdexcept> |
| 12 |
|
|
|
| 13 |
|
|
namespace ncurses |
| 14 |
|
|
{ |
| 15 |
|
|
/** |
| 16 |
|
|
* library runtime exception |
| 17 |
|
|
*/ |
| 18 |
|
|
struct runtime_error |
| 19 |
|
|
: std::runtime_error |
| 20 |
|
|
{ |
| 21 |
|
|
explicit runtime_error (const std::string &descr) |
| 22 |
|
|
: std::runtime_error (descr) |
| 23 |
|
|
{ |
| 24 |
|
|
} |
| 25 |
|
|
}; |
| 26 |
|
|
|
| 27 |
|
|
/** |
| 28 |
|
|
* generate exception if assert failed |
| 29 |
|
|
* @param expr failed expression |
| 30 |
|
|
* @param file file name where assert failed |
| 31 |
|
|
* @param line line where assert failed |
| 32 |
|
|
*/ |
| 33 |
|
|
void make_ncurses_assert (char const *expr, char const *file, int line); |
| 34 |
|
|
|
| 35 |
|
|
/** |
| 36 |
|
|
* simple assertion for all ncurses like falls (!=OK) |
| 37 |
|
|
*/ |
| 38 |
|
|
#define NCURSES_ASSERT(expr) \ |
| 39 |
|
|
if ((expr) != OK) ncurses::make_ncurses_assert (# expr, __FILE__, __LINE__) |
| 40 |
|
|
} |
| 41 |
|
|
|
| 42 |
|
|
#endif |