From c857f3b36da32c91a66ed2ca0702d8af8d39547e Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Thu, 28 Aug 2008 23:49:55 +0000 Subject: [PATCH] Boost Exception now works with BOOST_NO_RTTI and/or BOOST_NO_TYPEID. [SVN r48429] --- include/boost/exception/exception.hpp | 50 +++++++++++++++------------ include/boost/throw_exception.hpp | 4 +-- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index 4670481..8ea1d7e 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -6,7 +6,7 @@ #ifndef UUID_274DA366004E11DCB1DDFE2E56D89593 #define UUID_274DA366004E11DCB1DDFE2E56D89593 -#include +#include #include #include #include @@ -15,6 +15,8 @@ namespace boost { + class exception; + template class shared_ptr; @@ -27,21 +29,17 @@ boost error_info_container: public exception_detail::counted_base { - virtual char const * diagnostic_information( char const *, std::type_info const & ) const = 0; - virtual shared_ptr get( std::type_info const & ) const = 0; - virtual void set( shared_ptr const & ) = 0; + virtual char const * diagnostic_information( char const *, char const * ) const = 0; + virtual shared_ptr get( type_info_ const & ) const = 0; + virtual void set( shared_ptr const &, type_info_ const & ) = 0; }; + + template + shared_ptr get_data( exception const & ); + + void set_data( exception const *, shared_ptr const &, exception_detail::type_info_ const & ); } - template - class error_info; - - template - E const & operator<<( E const &, error_info const & ); - - template - shared_ptr get_error_info( E const & ); - class exception { @@ -71,14 +69,14 @@ boost if( data_ ) try { - char const * w = data_->diagnostic_information(std_what,typeid(*this)); - BOOST_ASSERT(0!=w); + char const * w = data_->diagnostic_information(std_what,dynamic_type_name()); + BOOST_ASSERT(w!=0); return w; } catch(...) { } - return std_what ? std_what : typeid(*this).name(); + return std_what ? std_what : dynamic_type_name(); } #if BOOST_WORKAROUND( BOOST_MSVC, BOOST_TESTED_AT(1500) ) @@ -96,14 +94,22 @@ boost private: - shared_ptr get( std::type_info const & ) const; - void set( shared_ptr const & ) const; + friend void exception_detail::set_data( exception const *, shared_ptr const &, exception_detail::type_info_ const & ); - template - friend E const & operator<<( E const &, error_info const & ); + template + friend shared_ptr exception_detail::get_data( exception const & ); - template - friend shared_ptr get_error_info( E 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 data_; }; diff --git a/include/boost/throw_exception.hpp b/include/boost/throw_exception.hpp index dc468f2..ae5ea5a 100644 --- a/include/boost/throw_exception.hpp +++ b/include/boost/throw_exception.hpp @@ -24,8 +24,8 @@ #include #include -#if !defined( BOOST_EXCEPTION_DISABLE ) && defined( BOOST_NO_TYPEID ) -# define BOOST_EXCEPTION_DISABLE +#if !defined( BOOST_EXCEPTION_DISABLE ) +#define BOOST_EXCEPTION_DISABLE #endif #if !defined( BOOST_EXCEPTION_DISABLE ) && defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, < 0x590 )