]> AND Private Git Repository - canny.git/blob - stc/exp/ml_stc_linux_make_v1.0/include/boost/exception/get_error_info.hpp
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
c3cf137d0729cf3bd97d48fd9d1d408346544f18
[canny.git] / stc / exp / ml_stc_linux_make_v1.0 / include / boost / exception / get_error_info.hpp
1 //Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.\r
2 \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
5 \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
10 #endif\r
11 #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)\r
12 #pragma warning(push,1)\r
13 #endif\r
14 \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
19 \r
20 namespace\r
21 boost\r
22     {\r
23     namespace\r
24     exception_detail\r
25         {\r
26         template <class ErrorInfo>\r
27         struct\r
28         get_info\r
29             {\r
30             static\r
31             typename ErrorInfo::value_type *\r
32             get( exception const & x )\r
33                 {\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
36                         {\r
37 #ifndef BOOST_NO_RTTI\r
38                         BOOST_ASSERT( 0!=dynamic_cast<ErrorInfo *>(eib.get()) );\r
39 #endif\r
40                         ErrorInfo * w = static_cast<ErrorInfo *>(eib.get());\r
41                         return &w->value();\r
42                         }\r
43                 return 0;\r
44                 }\r
45             };\r
46 \r
47         template <>\r
48         struct\r
49         get_info<throw_function>\r
50             {\r
51             static\r
52             char const * *\r
53             get( exception const & x )\r
54                 {\r
55                 return x.throw_function_ ? &x.throw_function_ : 0;\r
56                 }\r
57             };\r
58 \r
59         template <>\r
60         struct\r
61         get_info<throw_file>\r
62             {\r
63             static\r
64             char const * *\r
65             get( exception const & x )\r
66                 {\r
67                 return x.throw_file_ ? &x.throw_file_ : 0;\r
68                 }\r
69             };\r
70 \r
71         template <>\r
72         struct\r
73         get_info<throw_line>\r
74             {\r
75             static\r
76             int *\r
77             get( exception const & x )\r
78                 {\r
79                 return x.throw_line_!=-1 ? &x.throw_line_ : 0;\r
80                 }\r
81             };\r
82 \r
83         template <class T,class R>\r
84         struct\r
85         get_error_info_return_type\r
86             {\r
87             typedef R * type;\r
88             };\r
89 \r
90         template <class T,class R>\r
91         struct\r
92         get_error_info_return_type<T const,R>\r
93             {\r
94             typedef R const * type;\r
95             };\r
96         }\r
97 \r
98 #ifdef BOOST_NO_RTTI\r
99     template <class ErrorInfo>\r
100     inline\r
101     typename ErrorInfo::value_type const *\r
102     get_error_info( boost::exception const & x )\r
103         {\r
104         return exception_detail::get_info<ErrorInfo>::get(x);\r
105         }\r
106     template <class ErrorInfo>\r
107     inline\r
108     typename ErrorInfo::value_type *\r
109     get_error_info( boost::exception & x )\r
110         {\r
111         return exception_detail::get_info<ErrorInfo>::get(x);\r
112         }\r
113 #else\r
114     template <class ErrorInfo,class E>\r
115     inline\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
118         {\r
119         if( exception const * x = dynamic_cast<exception const *>(&some_exception) )\r
120             return exception_detail::get_info<ErrorInfo>::get(*x);\r
121         else\r
122             return 0;\r
123         }\r
124 #endif\r
125     }\r
126 \r
127 #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)\r
128 #pragma warning(pop)\r
129 #endif\r
130 #endif\r