1 //Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
\r
3 //Distributed under the Boost Software License, Version 1.0. (See accompanying
\r
4 //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
\r
6 #ifndef UUID_1A590226753311DD9E4CCF6156D89593
\r
7 #define UUID_1A590226753311DD9E4CCF6156D89593
\r
9 #include <boost/exception/exception.hpp>
\r
10 #include <boost/exception/detail/error_info_impl.hpp>
\r
11 #include <boost/exception/detail/type_info.hpp>
\r
12 #include <boost/shared_ptr.hpp>
\r
20 template <class ErrorInfo>
\r
25 typename ErrorInfo::value_type *
\r
26 get( exception const & x )
\r
28 if( exception_detail::error_info_container * c=x.data_.get() )
\r
29 if( shared_ptr<exception_detail::error_info_base> eib = c->get(BOOST_EXCEPTION_STATIC_TYPEID(ErrorInfo)) )
\r
31 #ifndef BOOST_NO_RTTI
\r
32 BOOST_ASSERT( 0!=dynamic_cast<ErrorInfo *>(eib.get()) );
\r
34 ErrorInfo * w = static_cast<ErrorInfo *>(eib.get());
\r
43 get_info<throw_function>
\r
47 get( exception const & x )
\r
49 return x.throw_function_ ? &x.throw_function_ : 0;
\r
55 get_info<throw_file>
\r
59 get( exception const & x )
\r
61 return x.throw_file_ ? &x.throw_file_ : 0;
\r
67 get_info<throw_line>
\r
71 get( exception const & x )
\r
73 return x.throw_line_!=-1 ? &x.throw_line_ : 0;
\r
77 template <class T,class R>
\r
79 get_error_info_return_type
\r
84 template <class T,class R>
\r
86 get_error_info_return_type<T const,R>
\r
88 typedef R const * type;
\r
92 #ifdef BOOST_NO_RTTI
\r
93 template <class ErrorInfo>
\r
95 typename ErrorInfo::value_type const *
\r
96 get_error_info( boost::exception const & x )
\r
98 return exception_detail::get_info<ErrorInfo>::get(x);
\r
100 template <class ErrorInfo>
\r
102 typename ErrorInfo::value_type *
\r
103 get_error_info( boost::exception & x )
\r
105 return exception_detail::get_info<ErrorInfo>::get(x);
\r
108 template <class ErrorInfo,class E>
\r
110 typename exception_detail::get_error_info_return_type<E,typename ErrorInfo::value_type>::type
\r
111 get_error_info( E & some_exception )
\r
113 if( exception const * x = dynamic_cast<exception const *>(&some_exception) )
\r
114 return exception_detail::get_info<ErrorInfo>::get(*x);
\r