1 //Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
3 //Distributed under the Boost Software License, Version 1.0. (See accompanying
4 //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 #ifndef UUID_1A590226753311DD9E4CCF6156D89593
7 #define UUID_1A590226753311DD9E4CCF6156D89593
8 #if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
9 #pragma GCC system_header
11 #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
12 #pragma warning(push,1)
15 #include <boost/exception/exception.hpp>
16 #include <boost/exception/detail/error_info_impl.hpp>
17 #include <boost/exception/detail/type_info.hpp>
18 #include <boost/shared_ptr.hpp>
26 template <class ErrorInfo>
31 typename ErrorInfo::value_type *
32 get( exception const & x )
34 if( exception_detail::error_info_container * c=x.data_.get() )
35 if( shared_ptr<exception_detail::error_info_base> eib = c->get(BOOST_EXCEPTION_STATIC_TYPEID(ErrorInfo)) )
38 BOOST_ASSERT( 0!=dynamic_cast<ErrorInfo *>(eib.get()) );
40 ErrorInfo * w = static_cast<ErrorInfo *>(eib.get());
49 get_info<throw_function>
53 get( exception const & x )
55 return x.throw_function_ ? &x.throw_function_ : 0;
65 get( exception const & x )
67 return x.throw_file_ ? &x.throw_file_ : 0;
77 get( exception const & x )
79 return x.throw_line_!=-1 ? &x.throw_line_ : 0;
83 template <class T,class R>
85 get_error_info_return_type
90 template <class T,class R>
92 get_error_info_return_type<T const,R>
94 typedef R const * type;
99 template <class ErrorInfo>
101 typename ErrorInfo::value_type const *
102 get_error_info( boost::exception const & x )
104 return exception_detail::get_info<ErrorInfo>::get(x);
106 template <class ErrorInfo>
108 typename ErrorInfo::value_type *
109 get_error_info( boost::exception & x )
111 return exception_detail::get_info<ErrorInfo>::get(x);
114 template <class ErrorInfo,class E>
116 typename exception_detail::get_error_info_return_type<E,typename ErrorInfo::value_type>::type
117 get_error_info( E & some_exception )
119 if( exception const * x = dynamic_cast<exception const *>(&some_exception) )
120 return exception_detail::get_info<ErrorInfo>::get(*x);
127 #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)