Boost Exception now works with BOOST_NO_RTTI and/or BOOST_NO_TYPEID.

[SVN r48429]
This commit is contained in:
Emil Dotchevski
2008-08-28 23:49:55 +00:00
parent 14765312e2
commit 850b7d9618
20 changed files with 369 additions and 148 deletions

View File

@ -0,0 +1,38 @@
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
//Distributed under the Boost Software License, Version 1.0. (See accompanying
//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef UUID_CE6983AC753411DDA764247956D89593
#define UUID_CE6983AC753411DDA764247956D89593
#include <boost/detail/workaround.hpp>
#include <string>
namespace
boost
{
namespace
exception_detail
{
class
error_info_base
{
public:
virtual char const * tag_typeid_name() const = 0;
virtual std::string value_as_string() const = 0;
protected:
#if BOOST_WORKAROUND( __GNUC__, BOOST_TESTED_AT(4) )
virtual //Disable bogus GCC warning.
#endif
~error_info_base()
{
}
};
}
}
#endif

View File

@ -0,0 +1,47 @@
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
//Distributed under the Boost Software License, Version 1.0. (See accompanying
//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef UUID_B9A8291074CA11DD94BFC77156D89593
#define UUID_B9A8291074CA11DD94BFC77156D89593
#include <boost/exception/exception.hpp>
namespace
boost
{
namespace
exception_detail
{
#ifdef BOOST_NO_RTTI
template <class T>
exception const *
get_boost_exception( T const * )
{
try
{
throw;
}
catch(
exception & x )
{
return &x;
}
catch(...)
{
return 0;
}
}
#else
template <class T>
exception const *
get_boost_exception( T const * x )
{
return dynamic_cast<exception const *>(x);
}
#endif
}
}
#endif

View File

@ -6,6 +6,7 @@
#ifndef UUID_6F463AC838DF11DDA3E6909F56D89593
#define UUID_6F463AC838DF11DDA3E6909F56D89593
#include <boost/exception/detail/type_info.hpp>
#include <iomanip>
#include <typeinfo>
#include <ios>
@ -24,7 +25,7 @@ boost
object_hex_dump( T const & x, size_t max_size=16 )
{
std::ostringstream s;
s << "type: " << typeid(x).name() << ", size: " << sizeof(T) << ", dump: ";
s << "type: " << type_name<T>() << ", size: " << sizeof(T) << ", dump: ";
size_t n=sizeof(T)>max_size?max_size:sizeof(T);
s.fill('0');
s.width(2);

View File

@ -0,0 +1,62 @@
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
//Distributed under the Boost Software License, Version 1.0. (See accompanying
//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef UUID_C3E1741C754311DDB2834CCA55D89593
#define UUID_C3E1741C754311DDB2834CCA55D89593
#include <boost/detail/sp_typeinfo.hpp>
#include <boost/current_function.hpp>
namespace
boost
{
template <class ErrorInfoTag>
inline
char const *
error_info_value()
{
return BOOST_CURRENT_FUNCTION;
}
namespace
exception_detail
{
typedef detail::sp_typeinfo type_info_;
#ifdef BOOST_NO_TYPEID
typedef type_info_ type_info_wrapper;
#else
struct
type_info_wrapper
{
type_info_ const * type;
explicit
type_info_wrapper( type_info_ const & t ):
type(&t)
{
}
bool
operator<( type_info_wrapper const & b ) const
{
return 0!=(type->before(*b.type));
}
};
#endif
template <class ErrorInfoTag>
inline
char const *
type_name()
{
return error_info_value<ErrorInfoTag>();
}
}
}
#define BOOST_EXCEPTION_STATIC_TYPEID(T) BOOST_SP_TYPEID(T)
#endif