Merging long-standing changes from Trunk, including the slightly more sophisticated handling of the to_string conversion done in boost::diagnostic_information.

[SVN r83354]
This commit is contained in:
Emil Dotchevski
2013-03-08 02:01:44 +00:00
parent 7e116a36b9
commit a0d47fea34
37 changed files with 181 additions and 200 deletions

View File

@ -5,7 +5,7 @@
#ifndef UUID_0552D49838DD11DD90146B8956D89593
#define UUID_0552D49838DD11DD90146B8956D89593
#if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
#pragma GCC system_header
#endif
#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
@ -31,17 +31,17 @@ boost
namespace
exception_detail
{
std::string diagnostic_information_impl( boost::exception const *, std::exception const *, bool );
std::string diagnostic_information_impl( boost::exception const *, std::exception const *, bool, bool );
}
inline
std::string
current_exception_diagnostic_information()
current_exception_diagnostic_information( bool verbose=true)
{
boost::exception const * be=current_exception_cast<boost::exception const>();
std::exception const * se=current_exception_cast<std::exception const>();
if( be || se )
return exception_detail::diagnostic_information_impl(be,se,true);
return exception_detail::diagnostic_information_impl(be,se,true,verbose);
else
return "No diagnostic information available.";
}
@ -107,7 +107,7 @@ boost
inline
std::string
diagnostic_information_impl( boost::exception const * be, std::exception const * se, bool with_what )
diagnostic_information_impl( boost::exception const * be, std::exception const * se, bool with_what, bool verbose )
{
if( !be && !se )
return "Unknown exception.";
@ -125,7 +125,7 @@ boost
return wh;
}
std::ostringstream tmp;
if( be )
if( be && verbose )
{
char const * const * f=get_error_info<throw_file>(*be);
int const * l=get_error_info<throw_line>(*be);
@ -149,36 +149,37 @@ boost
}
}
#ifndef BOOST_NO_RTTI
tmp << std::string("Dynamic exception type: ") <<
units::detail::demangle((be?(BOOST_EXCEPTION_DYNAMIC_TYPEID(*be)):(BOOST_EXCEPTION_DYNAMIC_TYPEID(*se))).type_->name()) << '\n';
if ( verbose )
tmp << std::string("Dynamic exception type: ") <<
units::detail::demangle((be?(BOOST_EXCEPTION_DYNAMIC_TYPEID(*be)):(BOOST_EXCEPTION_DYNAMIC_TYPEID(*se))).type_->name()) << '\n';
#endif
if( with_what && se )
if( with_what && se && verbose )
tmp << "std::exception::what: " << wh << '\n';
if( be )
if( char const * s=exception_detail::get_diagnostic_information(*be,tmp.str().c_str()) )
if( *s )
return s;
return std::string(s);
return tmp.str();
}
}
template <class T>
std::string
diagnostic_information( T const & e )
diagnostic_information( T const & e, bool verbose=true )
{
return exception_detail::diagnostic_information_impl(exception_detail::get_boost_exception(&e),exception_detail::get_std_exception(&e),true);
return exception_detail::diagnostic_information_impl(exception_detail::get_boost_exception(&e),exception_detail::get_std_exception(&e),true,verbose);
}
inline
char const *
diagnostic_information_what( exception const & e ) throw()
diagnostic_information_what( exception const & e, bool verbose=true ) throw()
{
char const * w=0;
#ifndef BOOST_NO_EXCEPTIONS
try
{
#endif
(void) exception_detail::diagnostic_information_impl(&e,0,false);
(void) exception_detail::diagnostic_information_impl(&e,0,false,verbose);
if( char const * di=exception_detail::get_diagnostic_information(e,0) )
return di;
else