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
9 #include <boost/config.hpp>
10 #include <boost/exception/exception.hpp>
11 #include <boost/exception/detail/error_info_impl.hpp>
12 #include <boost/exception/detail/type_info.hpp>
13 #include <boost/exception/detail/shared_ptr.hpp>
14 #include <boost/assert.hpp>
16 #if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
17 #pragma GCC system_header
19 #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
20 #pragma warning(push,1)
29 template <class ErrorInfo>
34 typename ErrorInfo::value_type *
35 get( exception const & x )
37 if( exception_detail::error_info_container * c=x.data_.get() )
38 if( shared_ptr<exception_detail::error_info_base> eib = c->get(BOOST_EXCEPTION_STATIC_TYPEID(ErrorInfo)) )
41 BOOST_ASSERT( 0!=dynamic_cast<ErrorInfo *>(eib.get()) );
43 ErrorInfo * w = static_cast<ErrorInfo *>(eib.get());
52 get_info<throw_function>
56 get( exception const & x )
58 return x.throw_function_ ? &x.throw_function_ : 0;
68 get( exception const & x )
70 return x.throw_file_ ? &x.throw_file_ : 0;
80 get( exception const & x )
82 return x.throw_line_!=-1 ? &x.throw_line_ : 0;
86 template <class T,class R>
88 get_error_info_return_type
93 template <class T,class R>
95 get_error_info_return_type<T const,R>
97 typedef R const * type;
102 template <class ErrorInfo>
104 typename ErrorInfo::value_type const *
105 get_error_info( boost::exception const & x )
107 return exception_detail::get_info<ErrorInfo>::get(x);
109 template <class ErrorInfo>
111 typename ErrorInfo::value_type *
112 get_error_info( boost::exception & x )
114 return exception_detail::get_info<ErrorInfo>::get(x);
117 template <class ErrorInfo,class E>
119 typename exception_detail::get_error_info_return_type<E,typename ErrorInfo::value_type>::type
120 get_error_info( E & some_exception )
122 if( exception const * x = dynamic_cast<exception const *>(&some_exception) )
123 return exception_detail::get_info<ErrorInfo>::get(*x);
130 #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)