//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc. //Distributed under the Boost Software License, Version 1.0. (See accompanying //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #ifndef UUID_1A590226753311DD9E4CCF6156D89593 #define UUID_1A590226753311DD9E4CCF6156D89593 #include #include #include #include namespace boost { namespace exception_detail { struct strwrap { std::string str; char const * ptr; explicit strwrap( char const * s ): str(s), ptr(&str[0]) { } private: strwrap( strwrap const & ); strwrap & operator=( strwrap const & ); }; template <> struct get_info { static shared_ptr get( exception const & x ) { if( x.throw_function_ && *x.throw_function_ ) { shared_ptr s(new strwrap(x.throw_function_)); return shared_ptr(s,&s->ptr); } else return shared_ptr(); } }; template <> struct get_info { static shared_ptr get( exception const & x ) { if( x.throw_file_ && *x.throw_file_ ) { shared_ptr s(new strwrap(x.throw_file_)); return shared_ptr(s,&s->ptr); } else return shared_ptr(); } }; template <> struct get_info { static shared_ptr get( exception const & x ) { if( x.throw_line_!=-1 ) return boost::shared_ptr(new int(x.throw_line_)); else return shared_ptr(); } }; template struct get_info { static shared_ptr get( exception const & x ) { if( exception_detail::error_info_container * c=x.data_.get() ) if( shared_ptr eib = c->get(BOOST_EXCEPTION_STATIC_TYPEID(ErrorInfo)) ) { #ifndef BOOST_NO_RTTI BOOST_ASSERT( 0!=dynamic_cast(eib.get()) ); #endif ErrorInfo const * w = static_cast(eib.get()); return shared_ptr(eib,&w->value()); } return shared_ptr(); } }; } #ifdef BOOST_NO_RTTI template inline shared_ptr get_error_info( boost::exception const & x ) { return exception_detail::get_info::get(x); } #else template inline shared_ptr get_error_info( E const & some_exception ) { if( exception const * x = dynamic_cast(&some_exception) ) return exception_detail::get_info::get(*x); else return shared_ptr(); } #endif } #endif