source: NonGTP/Boost/boost/spirit/core/assert.hpp @ 857

Revision 857, 1.7 KB checked in by igarcia, 19 years ago (diff)
Line 
1/*=============================================================================
2    Copyright (c) 2001-2003 Joel de Guzman
3    Copyright (c) 2002-2003 Hartmut Kaiser
4    http://spirit.sourceforge.net/
5
6    Use, modification and distribution is subject to the Boost Software
7    License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8    http://www.boost.org/LICENSE_1_0.txt)
9=============================================================================*/
10#if !defined(BOOST_SPIRIT_ASSERT_HPP)
11#define BOOST_SPIRIT_ASSERT_HPP
12
13#include <boost/config.hpp>
14#include <boost/throw_exception.hpp>
15
16///////////////////////////////////////////////////////////////////////////////
17//
18//  BOOST_SPIRIT_ASSERT is used throughout the framework.  It can be
19//  overridden by the user. If BOOST_SPIRIT_ASSERT_EXCEPTION is defined,
20//  then that will be thrown, otherwise, BOOST_SPIRIT_ASSERT simply turns
21//  into a plain assert()
22//
23///////////////////////////////////////////////////////////////////////////////
24#if !defined(BOOST_SPIRIT_ASSERT)
25#if defined(NDEBUG)
26    #define BOOST_SPIRIT_ASSERT(x)
27#elif defined (BOOST_SPIRIT_ASSERT_EXCEPTION)
28    #define BOOST_SPIRIT_ASSERT_AUX(f, l, x) BOOST_SPIRIT_ASSERT_AUX2(f, l, x)
29    #define BOOST_SPIRIT_ASSERT_AUX2(f, l, x)                                   \
30    do{ if (!(x)) boost::throw_exception(                                       \
31        BOOST_SPIRIT_ASSERT_EXCEPTION(f "(" #l "): " #x)); } while(0)
32    #define BOOST_SPIRIT_ASSERT(x) BOOST_SPIRIT_ASSERT_AUX(__FILE__, __LINE__, x)
33#else
34    #include <cassert>
35    #define BOOST_SPIRIT_ASSERT(x) assert(x)
36#endif
37#endif // !defined(BOOST_SPIRIT_ASSERT)
38
39#endif // BOOST_SPIRIT_ASSERT_HPP
Note: See TracBrowser for help on using the repository browser.