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
8 #if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
\r
9 #pragma GCC system_header
\r
11 #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
\r
12 #pragma warning(push,1)
\r
15 #include <boost/exception/exception.hpp>
\r
16 #include <boost/exception/detail/error_info_impl.hpp>
\r
17 #include <boost/exception/detail/type_info.hpp>
\r
18 #include <boost/shared_ptr.hpp>
\r
26 template <class ErrorInfo>
\r
31 typename ErrorInfo::value_type *
\r
32 get( exception const & x )
\r
34 if( exception_detail::error_info_container * c=x.data_.get() )
\r
35 if( shared_ptr<exception_detail::error_info_base> eib = c->get(BOOST_EXCEPTION_STATIC_TYPEID(ErrorInfo)) )
\r
37 #ifndef BOOST_NO_RTTI
\r
38 BOOST_ASSERT( 0!=dynamic_cast<ErrorInfo *>(eib.get()) );
\r
40 ErrorInfo * w = static_cast<ErrorInfo *>(eib.get());
\r
49 get_info<throw_function>
\r
53 get( exception const & x )
\r
55 return x.throw_function_ ? &x.throw_function_ : 0;
\r
61 get_info<throw_file>
\r
65 get( exception const & x )
\r
67 return x.throw_file_ ? &x.throw_file_ : 0;
\r
73 get_info<throw_line>
\r
77 get( exception const & x )
\r
79 return x.throw_line_!=-1 ? &x.throw_line_ : 0;
\r
83 template <class T,class R>
\r
85 get_error_info_return_type
\r
90 template <class T,class R>
\r
92 get_error_info_return_type<T const,R>
\r
94 typedef R const * type;
\r
98 #ifdef BOOST_NO_RTTI
\r
99 template <class ErrorInfo>
\r
101 typename ErrorInfo::value_type const *
\r
102 get_error_info( boost::exception const & x )
\r
104 return exception_detail::get_info<ErrorInfo>::get(x);
\r
106 template <class ErrorInfo>
\r
108 typename ErrorInfo::value_type *
\r
109 get_error_info( boost::exception & x )
\r
111 return exception_detail::get_info<ErrorInfo>::get(x);
\r
114 template <class ErrorInfo,class E>
\r
116 typename exception_detail::get_error_info_return_type<E,typename ErrorInfo::value_type>::type
\r
117 get_error_info( E & some_exception )
\r
119 if( exception const * x = dynamic_cast<exception const *>(&some_exception) )
\r
120 return exception_detail::get_info<ErrorInfo>::get(*x);
\r
127 #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
\r
128 #pragma warning(pop)
\r