Chris@16: //Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc. Chris@16: Chris@16: //Distributed under the Boost Software License, Version 1.0. (See accompanying Chris@16: //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: #ifndef UUID_1A590226753311DD9E4CCF6156D89593 Chris@16: #define UUID_1A590226753311DD9E4CCF6156D89593 Chris@16: #if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) Chris@16: #pragma GCC system_header Chris@16: #endif Chris@16: #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) Chris@16: #pragma warning(push,1) Chris@16: #endif Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace Chris@16: boost Chris@16: { Chris@16: namespace Chris@16: exception_detail Chris@16: { Chris@16: template Chris@16: struct Chris@16: get_info Chris@16: { Chris@16: static Chris@16: typename ErrorInfo::value_type * Chris@16: get( exception const & x ) Chris@16: { Chris@16: if( exception_detail::error_info_container * c=x.data_.get() ) Chris@16: if( shared_ptr eib = c->get(BOOST_EXCEPTION_STATIC_TYPEID(ErrorInfo)) ) Chris@16: { Chris@16: #ifndef BOOST_NO_RTTI Chris@16: BOOST_ASSERT( 0!=dynamic_cast(eib.get()) ); Chris@16: #endif Chris@16: ErrorInfo * w = static_cast(eib.get()); Chris@16: return &w->value(); Chris@16: } Chris@16: return 0; Chris@16: } Chris@16: }; Chris@16: Chris@16: template <> Chris@16: struct Chris@16: get_info Chris@16: { Chris@16: static Chris@16: char const * * Chris@16: get( exception const & x ) Chris@16: { Chris@16: return x.throw_function_ ? &x.throw_function_ : 0; Chris@16: } Chris@16: }; Chris@16: Chris@16: template <> Chris@16: struct Chris@16: get_info Chris@16: { Chris@16: static Chris@16: char const * * Chris@16: get( exception const & x ) Chris@16: { Chris@16: return x.throw_file_ ? &x.throw_file_ : 0; Chris@16: } Chris@16: }; Chris@16: Chris@16: template <> Chris@16: struct Chris@16: get_info Chris@16: { Chris@16: static Chris@16: int * Chris@16: get( exception const & x ) Chris@16: { Chris@16: return x.throw_line_!=-1 ? &x.throw_line_ : 0; Chris@16: } Chris@16: }; Chris@16: Chris@16: template Chris@16: struct Chris@16: get_error_info_return_type Chris@16: { Chris@16: typedef R * type; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct Chris@16: get_error_info_return_type Chris@16: { Chris@16: typedef R const * type; Chris@16: }; Chris@16: } Chris@16: Chris@16: #ifdef BOOST_NO_RTTI Chris@16: template Chris@16: inline Chris@16: typename ErrorInfo::value_type const * Chris@16: get_error_info( boost::exception const & x ) Chris@16: { Chris@16: return exception_detail::get_info::get(x); Chris@16: } Chris@16: template Chris@16: inline Chris@16: typename ErrorInfo::value_type * Chris@16: get_error_info( boost::exception & x ) Chris@16: { Chris@16: return exception_detail::get_info::get(x); Chris@16: } Chris@16: #else Chris@16: template Chris@16: inline Chris@16: typename exception_detail::get_error_info_return_type::type Chris@16: get_error_info( E & some_exception ) Chris@16: { Chris@16: if( exception const * x = dynamic_cast(&some_exception) ) Chris@16: return exception_detail::get_info::get(*x); Chris@16: else Chris@16: return 0; Chris@16: } Chris@16: #endif Chris@16: } Chris@16: Chris@16: #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) Chris@16: #pragma warning(pop) Chris@16: #endif Chris@16: #endif