Merging from trunk: new function diagnostic_information_what, and mutable error info access.

[SVN r56477]
This commit is contained in:
Emil Dotchevski
2009-09-29 20:38:11 +00:00
parent d32fff4fb2
commit 6434a2031c
32 changed files with 9991 additions and 9480 deletions

View File

@ -22,16 +22,16 @@ boost
get_info
{
static
typename ErrorInfo::value_type const *
typename ErrorInfo::value_type *
get( exception const & x )
{
if( exception_detail::error_info_container * c=x.data_.get() )
if( shared_ptr<exception_detail::error_info_base const> eib = c->get(BOOST_EXCEPTION_STATIC_TYPEID(ErrorInfo)) )
if( shared_ptr<exception_detail::error_info_base> eib = c->get(BOOST_EXCEPTION_STATIC_TYPEID(ErrorInfo)) )
{
#ifndef BOOST_NO_RTTI
BOOST_ASSERT( 0!=dynamic_cast<ErrorInfo const *>(eib.get()) );
BOOST_ASSERT( 0!=dynamic_cast<ErrorInfo *>(eib.get()) );
#endif
ErrorInfo const * w = static_cast<ErrorInfo const *>(eib.get());
ErrorInfo * w = static_cast<ErrorInfo *>(eib.get());
return &w->value();
}
return 0;
@ -43,7 +43,7 @@ boost
get_info<throw_function>
{
static
char const * const *
char const * *
get( exception const & x )
{
return x.throw_function_ ? &x.throw_function_ : 0;
@ -55,7 +55,7 @@ boost
get_info<throw_file>
{
static
char const * const *
char const * *
get( exception const & x )
{
return x.throw_file_ ? &x.throw_file_ : 0;
@ -67,12 +67,26 @@ boost
get_info<throw_line>
{
static
int const *
int *
get( exception const & x )
{
return x.throw_line_!=-1 ? &x.throw_line_ : 0;
}
};
template <class T,class R>
struct
get_error_info_return_type
{
typedef R * type;
};
template <class T,class R>
struct
get_error_info_return_type<T const,R>
{
typedef R const * type;
};
}
#ifdef BOOST_NO_RTTI
@ -83,11 +97,18 @@ boost
{
return exception_detail::get_info<ErrorInfo>::get(x);
}
template <class ErrorInfo>
inline
typename ErrorInfo::value_type *
get_error_info( boost::exception & x )
{
return exception_detail::get_info<ErrorInfo>::get(x);
}
#else
template <class ErrorInfo,class E>
inline
typename ErrorInfo::value_type const *
get_error_info( E const & some_exception )
typename exception_detail::get_error_info_return_type<E,typename ErrorInfo::value_type>::type
get_error_info( E & some_exception )
{
if( exception const * x = dynamic_cast<exception const *>(&some_exception) )
return exception_detail::get_info<ErrorInfo>::get(*x);