Jeff Thompson | 2491bd6 | 2013-10-15 17:10:24 -0700 | [diff] [blame^] | 1 | #ifndef NDNBOOST_UUID_AA15E74A856F11E08B8D93F24824019B |
| 2 | #define NDNBOOST_UUID_AA15E74A856F11E08B8D93F24824019B |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 3 | #if defined(__GNUC__) && !defined(NDNBOOST_EXCEPTION_ENABLE_WARNINGS) |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 4 | #pragma GCC system_header |
| 5 | #endif |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 6 | #if defined(_MSC_VER) && !defined(NDNBOOST_EXCEPTION_ENABLE_WARNINGS) |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 7 | #pragma warning(push,1) |
| 8 | #endif |
| 9 | |
| 10 | // MS compatible compilers support #pragma once |
| 11 | |
| 12 | #if defined(_MSC_VER) && (_MSC_VER >= 1020) |
| 13 | # pragma once |
| 14 | #endif |
| 15 | |
| 16 | // |
Jeff Thompson | 9939dcd | 2013-10-15 15:12:24 -0700 | [diff] [blame] | 17 | // ndnboost/throw_exception.hpp |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 18 | // |
| 19 | // Copyright (c) 2002 Peter Dimov and Multi Media Ltd. |
| 20 | // Copyright (c) 2008-2009 Emil Dotchevski and Reverge Studios, Inc. |
| 21 | // |
| 22 | // Distributed under the Boost Software License, Version 1.0. (See |
| 23 | // accompanying file LICENSE_1_0.txt or copy at |
| 24 | // http://www.boost.org/LICENSE_1_0.txt) |
| 25 | // |
| 26 | // http://www.boost.org/libs/utility/throw_exception.html |
| 27 | // |
| 28 | |
Jeff Thompson | 2277ce5 | 2013-08-01 17:34:11 -0700 | [diff] [blame] | 29 | #include <ndnboost/exception/detail/attribute_noreturn.hpp> |
| 30 | #include <ndnboost/detail/workaround.hpp> |
| 31 | #include <ndnboost/config.hpp> |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 32 | #include <exception> |
| 33 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 34 | #if !defined( NDNBOOST_EXCEPTION_DISABLE ) && defined( __BORLANDC__ ) && NDNBOOST_WORKAROUND( __BORLANDC__, NDNBOOST_TESTED_AT(0x593) ) |
| 35 | # define NDNBOOST_EXCEPTION_DISABLE |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 36 | #endif |
| 37 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 38 | #if !defined( NDNBOOST_EXCEPTION_DISABLE ) && defined( NDNBOOST_MSVC ) && NDNBOOST_WORKAROUND( NDNBOOST_MSVC, < 1310 ) |
| 39 | # define NDNBOOST_EXCEPTION_DISABLE |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 40 | #endif |
| 41 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 42 | #if !defined( NDNBOOST_EXCEPTION_DISABLE ) |
Jeff Thompson | 2277ce5 | 2013-08-01 17:34:11 -0700 | [diff] [blame] | 43 | # include <ndnboost/exception/exception.hpp> |
| 44 | # include <ndnboost/current_function.hpp> |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 45 | # define NDNBOOST_THROW_EXCEPTION(x) ::ndnboost::exception_detail::throw_exception_(x,NDNBOOST_CURRENT_FUNCTION,__FILE__,__LINE__) |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 46 | #else |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 47 | # define NDNBOOST_THROW_EXCEPTION(x) ::ndnboost::throw_exception(x) |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 48 | #endif |
| 49 | |
| 50 | namespace ndnboost |
| 51 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 52 | #ifdef NDNBOOST_NO_EXCEPTIONS |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 53 | |
| 54 | void throw_exception( std::exception const & e ); // user defined |
| 55 | |
| 56 | #else |
| 57 | |
| 58 | inline void throw_exception_assert_compatibility( std::exception const & ) { } |
| 59 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 60 | template<class E> NDNBOOST_ATTRIBUTE_NORETURN inline void throw_exception( E const & e ) |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 61 | { |
| 62 | //All boost exceptions are required to derive from std::exception, |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 63 | //to ensure compatibility with NDNBOOST_NO_EXCEPTIONS. |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 64 | throw_exception_assert_compatibility(e); |
| 65 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 66 | #ifndef NDNBOOST_EXCEPTION_DISABLE |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 67 | throw enable_current_exception(enable_error_info(e)); |
| 68 | #else |
| 69 | throw e; |
| 70 | #endif |
| 71 | } |
| 72 | |
| 73 | #endif |
| 74 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 75 | #if !defined( NDNBOOST_EXCEPTION_DISABLE ) |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 76 | namespace |
| 77 | exception_detail |
| 78 | { |
| 79 | template <class E> |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 80 | NDNBOOST_ATTRIBUTE_NORETURN |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 81 | void |
| 82 | throw_exception_( E const & x, char const * current_function, char const * file, int line ) |
| 83 | { |
| 84 | ndnboost::throw_exception( |
| 85 | set_info( |
| 86 | set_info( |
| 87 | set_info( |
| 88 | enable_error_info(x), |
| 89 | throw_function(current_function)), |
| 90 | throw_file(file)), |
| 91 | throw_line(line))); |
| 92 | } |
| 93 | } |
| 94 | #endif |
| 95 | } // namespace ndnboost |
| 96 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 97 | #if defined(_MSC_VER) && !defined(NDNBOOST_EXCEPTION_ENABLE_WARNINGS) |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 98 | #pragma warning(pop) |
| 99 | #endif |
| 100 | #endif |