forked from boostorg/throw_exception
decoupled boost/exception/exception.hpp from boost/exception/detail/type_info.hpp diagnostic_information improvements documentation update
[SVN r48469]
This commit is contained in:
committed by
Peter Dimov
parent
c857f3b36d
commit
95b0ce06a5
@ -6,11 +6,8 @@
|
|||||||
#ifndef UUID_274DA366004E11DCB1DDFE2E56D89593
|
#ifndef UUID_274DA366004E11DCB1DDFE2E56D89593
|
||||||
#define UUID_274DA366004E11DCB1DDFE2E56D89593
|
#define UUID_274DA366004E11DCB1DDFE2E56D89593
|
||||||
|
|
||||||
#include <boost/exception/detail/type_info.hpp>
|
|
||||||
#include <boost/detail/workaround.hpp>
|
|
||||||
#include <boost/exception/detail/counted_base.hpp>
|
#include <boost/exception/detail/counted_base.hpp>
|
||||||
#include <boost/intrusive_ptr.hpp>
|
#include <boost/intrusive_ptr.hpp>
|
||||||
#include <typeinfo>
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
boost
|
boost
|
||||||
@ -24,12 +21,13 @@ boost
|
|||||||
exception_detail
|
exception_detail
|
||||||
{
|
{
|
||||||
class error_info_base;
|
class error_info_base;
|
||||||
|
struct type_info_;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
error_info_container:
|
error_info_container:
|
||||||
public exception_detail::counted_base
|
public exception_detail::counted_base
|
||||||
{
|
{
|
||||||
virtual char const * diagnostic_information( char const *, char const * ) const = 0;
|
virtual char const * diagnostic_information() const = 0;
|
||||||
virtual shared_ptr<error_info_base const> get( type_info_ const & ) const = 0;
|
virtual shared_ptr<error_info_base const> get( type_info_ const & ) const = 0;
|
||||||
virtual void set( shared_ptr<error_info_base const> const &, type_info_ const & ) = 0;
|
virtual void set( shared_ptr<error_info_base const> const &, type_info_ const & ) = 0;
|
||||||
};
|
};
|
||||||
@ -37,7 +35,7 @@ boost
|
|||||||
template <class ErrorInfo>
|
template <class ErrorInfo>
|
||||||
shared_ptr<typename ErrorInfo::value_type const> get_data( exception const & );
|
shared_ptr<typename ErrorInfo::value_type const> get_data( exception const & );
|
||||||
|
|
||||||
void set_data( exception const *, shared_ptr<exception_detail::error_info_base const> const &, exception_detail::type_info_ const & );
|
void set_data( exception const *, shared_ptr<exception_detail::error_info_base const> const &, type_info_ const & );
|
||||||
}
|
}
|
||||||
|
|
||||||
class
|
class
|
||||||
@ -49,7 +47,7 @@ boost
|
|||||||
char const *
|
char const *
|
||||||
diagnostic_information() const throw()
|
diagnostic_information() const throw()
|
||||||
{
|
{
|
||||||
return _diagnostic_information(0);
|
return _diagnostic_information();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -63,22 +61,6 @@ boost
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
char const *
|
|
||||||
_diagnostic_information( char const * std_what ) const throw()
|
|
||||||
{
|
|
||||||
if( data_ )
|
|
||||||
try
|
|
||||||
{
|
|
||||||
char const * w = data_->diagnostic_information(std_what,dynamic_type_name());
|
|
||||||
BOOST_ASSERT(w!=0);
|
|
||||||
return w;
|
|
||||||
}
|
|
||||||
catch(...)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
return std_what ? std_what : dynamic_type_name();
|
|
||||||
}
|
|
||||||
|
|
||||||
#if BOOST_WORKAROUND( BOOST_MSVC, BOOST_TESTED_AT(1500) )
|
#if BOOST_WORKAROUND( BOOST_MSVC, BOOST_TESTED_AT(1500) )
|
||||||
//Force class exception to be abstract.
|
//Force class exception to be abstract.
|
||||||
//Otherwise, MSVC bug allows throw exception(), even though the copy constructor is protected.
|
//Otherwise, MSVC bug allows throw exception(), even though the copy constructor is protected.
|
||||||
@ -92,6 +74,22 @@ boost
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
char const *
|
||||||
|
_diagnostic_information() const throw()
|
||||||
|
{
|
||||||
|
if( data_ )
|
||||||
|
try
|
||||||
|
{
|
||||||
|
char const * w = data_->diagnostic_information();
|
||||||
|
BOOST_ASSERT(w!=0);
|
||||||
|
return w;
|
||||||
|
}
|
||||||
|
catch(...)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
friend void exception_detail::set_data( exception const *, shared_ptr<exception_detail::error_info_base const> const &, exception_detail::type_info_ const & );
|
friend void exception_detail::set_data( exception const *, shared_ptr<exception_detail::error_info_base const> const &, exception_detail::type_info_ const & );
|
||||||
@ -99,18 +97,6 @@ boost
|
|||||||
template <class ErrorInfo>
|
template <class ErrorInfo>
|
||||||
friend shared_ptr<typename ErrorInfo::value_type const> exception_detail::get_data( exception const & );
|
friend shared_ptr<typename ErrorInfo::value_type const> exception_detail::get_data( exception const & );
|
||||||
|
|
||||||
char const *
|
|
||||||
dynamic_type_name() const
|
|
||||||
{
|
|
||||||
return
|
|
||||||
#if defined(BOOST_NO_RTTI) || defined(BOOST_NO_TYPEID)
|
|
||||||
"Unknown type deriving from boost::exception"
|
|
||||||
#else
|
|
||||||
typeid(*this).name()
|
|
||||||
#endif
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
mutable intrusive_ptr<exception_detail::error_info_container> data_;
|
mutable intrusive_ptr<exception_detail::error_info_container> data_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user