File indexing completed on 2025-01-18 09:30:47
0001
0002
0003
0004
0005
0006 #ifndef BOOST_EXCEPTION_1A590226753311DD9E4CCF6156D89593
0007 #define BOOST_EXCEPTION_1A590226753311DD9E4CCF6156D89593
0008
0009 #include <boost/config.hpp>
0010 #include <boost/exception/exception.hpp>
0011 #include <boost/exception/detail/error_info_impl.hpp>
0012 #include <boost/exception/detail/type_info.hpp>
0013 #include <boost/exception/detail/shared_ptr.hpp>
0014 #include <boost/assert.hpp>
0015
0016 #ifndef BOOST_EXCEPTION_ENABLE_WARNINGS
0017 #if __GNUC__*100+__GNUC_MINOR__>301
0018 #pragma GCC system_header
0019 #endif
0020 #ifdef __clang__
0021 #pragma clang system_header
0022 #endif
0023 #ifdef _MSC_VER
0024 #pragma warning(push,1)
0025 #endif
0026 #endif
0027
0028 namespace
0029 boost
0030 {
0031 namespace
0032 exception_detail
0033 {
0034 template <class ErrorInfo>
0035 struct
0036 get_info
0037 {
0038 static
0039 typename ErrorInfo::value_type *
0040 get( exception const & x )
0041 {
0042 if( exception_detail::error_info_container * c=x.data_.get() )
0043 if( shared_ptr<exception_detail::error_info_base> eib = c->get(BOOST_EXCEPTION_STATIC_TYPEID(ErrorInfo)) )
0044 {
0045 #ifndef BOOST_NO_RTTI
0046 BOOST_ASSERT( 0!=dynamic_cast<ErrorInfo *>(eib.get()) );
0047 #endif
0048 ErrorInfo * w = static_cast<ErrorInfo *>(eib.get());
0049 return &w->value();
0050 }
0051 return 0;
0052 }
0053 };
0054
0055 template <>
0056 struct
0057 get_info<throw_function>
0058 {
0059 static
0060 char const * *
0061 get( exception const & x )
0062 {
0063 return x.throw_function_ ? &x.throw_function_ : 0;
0064 }
0065 };
0066
0067 template <>
0068 struct
0069 get_info<throw_file>
0070 {
0071 static
0072 char const * *
0073 get( exception const & x )
0074 {
0075 return x.throw_file_ ? &x.throw_file_ : 0;
0076 }
0077 };
0078
0079 template <>
0080 struct
0081 get_info<throw_line>
0082 {
0083 static
0084 int *
0085 get( exception const & x )
0086 {
0087 return x.throw_line_!=-1 ? &x.throw_line_ : 0;
0088 }
0089 };
0090
0091 template <class T,class R>
0092 struct
0093 get_error_info_return_type
0094 {
0095 typedef R * type;
0096 };
0097
0098 template <class T,class R>
0099 struct
0100 get_error_info_return_type<T const,R>
0101 {
0102 typedef R const * type;
0103 };
0104 }
0105
0106 #ifdef BOOST_NO_RTTI
0107 template <class ErrorInfo>
0108 inline
0109 typename ErrorInfo::value_type const *
0110 get_error_info( boost::exception const & x )
0111 {
0112 return exception_detail::get_info<ErrorInfo>::get(x);
0113 }
0114 template <class ErrorInfo>
0115 inline
0116 typename ErrorInfo::value_type *
0117 get_error_info( boost::exception & x )
0118 {
0119 return exception_detail::get_info<ErrorInfo>::get(x);
0120 }
0121 #else
0122 template <class ErrorInfo,class E>
0123 inline
0124 typename exception_detail::get_error_info_return_type<E,typename ErrorInfo::value_type>::type
0125 get_error_info( E & some_exception )
0126 {
0127 if( exception const * x = dynamic_cast<exception const *>(&some_exception) )
0128 return exception_detail::get_info<ErrorInfo>::get(*x);
0129 else
0130 return 0;
0131 }
0132 #endif
0133 }
0134
0135 #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
0136 #pragma warning(pop)
0137 #endif
0138 #endif