/Src/Dependencies/Boost/boost/spirit/home/classic/core/assert.hpp

http://hadesmem.googlecode.com/ · C++ Header · 38 lines · 19 code · 3 blank · 16 comment · 2 complexity · 9f61c0d135032ee8a56d35d32ae05d9a MD5 · raw file

  1. /*=============================================================================
  2. Copyright (c) 2001-2003 Joel de Guzman
  3. Copyright (c) 2002-2003 Hartmut Kaiser
  4. http://spirit.sourceforge.net/
  5. Distributed under the Boost Software License, Version 1.0. (See accompanying
  6. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  7. =============================================================================*/
  8. #if !defined(BOOST_SPIRIT_ASSERT_HPP)
  9. #define BOOST_SPIRIT_ASSERT_HPP
  10. #include <boost/config.hpp>
  11. #include <boost/throw_exception.hpp>
  12. ///////////////////////////////////////////////////////////////////////////////
  13. //
  14. // BOOST_SPIRIT_ASSERT is used throughout the framework. It can be
  15. // overridden by the user. If BOOST_SPIRIT_ASSERT_EXCEPTION is defined,
  16. // then that will be thrown, otherwise, BOOST_SPIRIT_ASSERT simply turns
  17. // into a plain BOOST_ASSERT()
  18. //
  19. ///////////////////////////////////////////////////////////////////////////////
  20. #if !defined(BOOST_SPIRIT_ASSERT)
  21. #if defined(NDEBUG)
  22. #define BOOST_SPIRIT_ASSERT(x)
  23. #elif defined (BOOST_SPIRIT_ASSERT_EXCEPTION)
  24. #define BOOST_SPIRIT_ASSERT_AUX(f, l, x) BOOST_SPIRIT_ASSERT_AUX2(f, l, x)
  25. #define BOOST_SPIRIT_ASSERT_AUX2(f, l, x) \
  26. do{ if (!(x)) boost::throw_exception( \
  27. BOOST_SPIRIT_ASSERT_EXCEPTION(f "(" #l "): " #x)); } while(0)
  28. #define BOOST_SPIRIT_ASSERT(x) BOOST_SPIRIT_ASSERT_AUX(__FILE__, __LINE__, x)
  29. #else
  30. #include <boost/assert.hpp>
  31. #define BOOST_SPIRIT_ASSERT(x) BOOST_ASSERT(x)
  32. #endif
  33. #endif // !defined(BOOST_SPIRIT_ASSERT)
  34. #endif // BOOST_SPIRIT_ASSERT_HPP