1 //Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
3 //Distributed under the Boost Software License, Version 1.0. (See accompanying
4 //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 #ifndef UUID_274DA366004E11DCB1DDFE2E56D89593
7 #define UUID_274DA366004E11DCB1DDFE2E56D89593
9 #include <boost/config.hpp>
10 #include <boost/detail/workaround.hpp>
11 #include <boost/exception/detail/counted_base.hpp>
12 #include <boost/intrusive_ptr.hpp>
24 class error_info_base;
28 public exception_detail::counted_base
30 virtual char const * diagnostic_information( char const *, std::type_info const & ) const = 0;
31 virtual shared_ptr<error_info_base const> get( std::type_info const & ) const = 0;
32 virtual void set( shared_ptr<error_info_base const> const & ) = 0;
36 template <class Tag,class T>
39 template <class E,class Tag,class T>
40 E const & operator<<( E const &, error_info<Tag,T> const & );
42 template <class ErrorInfo,class E>
43 shared_ptr<typename ErrorInfo::value_type const> get_error_info( E const & );
52 diagnostic_information() const throw()
54 return _diagnostic_information(0);
63 exception( exception const & e ):
69 _diagnostic_information( char const * std_what ) const throw()
74 char const * w = data_->diagnostic_information(std_what,typeid(*this));
81 return std_what ? std_what : typeid(*this).name();
84 #if BOOST_WORKAROUND( BOOST_MSVC, BOOST_TESTED_AT(1500) )
85 //Force class exception to be abstract.
86 //Otherwise, MSVC bug allows throw exception(), even though the copy constructor is protected.
87 virtual ~exception() throw()=0;
89 #if BOOST_WORKAROUND( __GNUC__, BOOST_TESTED_AT(4) )
90 virtual //Disable bogus GCC warning.
99 shared_ptr<exception_detail::error_info_base const> get( std::type_info const & ) const;
100 void set( shared_ptr<exception_detail::error_info_base const> const & ) const;
102 template <class E,class Tag,class T>
103 friend E const & operator<<( E const &, error_info<Tag,T> const & );
105 template <class ErrorInfo,class E>
106 friend shared_ptr<typename ErrorInfo::value_type const> get_error_info( E const & );
108 intrusive_ptr<exception_detail::error_info_container> mutable data_;
111 #if BOOST_WORKAROUND( BOOST_MSVC, BOOST_TESTED_AT(1500) ) //See above.