2009-04-07 03:02:15 +00:00
|
|
|
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
2008-03-04 01:41:17 +00:00
|
|
|
|
|
|
|
//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)
|
|
|
|
|
2019-12-21 14:15:17 -08:00
|
|
|
#ifndef BOOST_EXCEPTION_E788439ED9F011DCB181F25B55D89593
|
|
|
|
#define BOOST_EXCEPTION_E788439ED9F011DCB181F25B55D89593
|
2017-02-20 18:23:36 -08:00
|
|
|
|
|
|
|
#include <boost/exception/to_string.hpp>
|
|
|
|
#include <boost/exception/detail/object_hex_dump.hpp>
|
|
|
|
#include <boost/assert.hpp>
|
|
|
|
|
2020-04-06 18:23:52 -07:00
|
|
|
#ifndef BOOST_EXCEPTION_ENABLE_WARNINGS
|
|
|
|
#if __GNUC__*100+__GNUC_MINOR__>301
|
2009-12-01 02:16:50 +00:00
|
|
|
#pragma GCC system_header
|
|
|
|
#endif
|
2020-04-06 18:23:52 -07:00
|
|
|
#ifdef __clang__
|
|
|
|
#pragma clang system_header
|
|
|
|
#endif
|
|
|
|
#ifdef _MSC_VER
|
2009-12-04 06:33:47 +00:00
|
|
|
#pragma warning(push,1)
|
|
|
|
#endif
|
2020-04-06 18:23:52 -07:00
|
|
|
#endif
|
2009-12-01 02:16:50 +00:00
|
|
|
|
2008-03-04 01:41:17 +00:00
|
|
|
namespace
|
|
|
|
boost
|
2008-04-08 21:29:37 +00:00
|
|
|
{
|
|
|
|
namespace
|
|
|
|
exception_detail
|
|
|
|
{
|
|
|
|
template <bool ToStringAvailable>
|
|
|
|
struct
|
|
|
|
to_string_dispatcher
|
|
|
|
{
|
|
|
|
template <class T,class Stub>
|
|
|
|
static
|
|
|
|
std::string
|
|
|
|
convert( T const & x, Stub )
|
|
|
|
{
|
|
|
|
return to_string(x);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct
|
|
|
|
to_string_dispatcher<false>
|
|
|
|
{
|
|
|
|
template <class T,class Stub>
|
|
|
|
static
|
2008-04-12 03:27:57 +00:00
|
|
|
std::string
|
2008-04-08 21:29:37 +00:00
|
|
|
convert( T const & x, Stub s )
|
|
|
|
{
|
2008-04-11 03:51:06 +00:00
|
|
|
return s(x);
|
2008-04-08 21:29:37 +00:00
|
|
|
}
|
2008-06-25 23:27:56 +00:00
|
|
|
|
|
|
|
template <class T>
|
|
|
|
static
|
|
|
|
std::string
|
|
|
|
convert( T const & x, std::string s )
|
|
|
|
{
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
static
|
|
|
|
std::string
|
|
|
|
convert( T const & x, char const * s )
|
|
|
|
{
|
|
|
|
BOOST_ASSERT(s!=0);
|
|
|
|
return s;
|
|
|
|
}
|
2008-04-08 21:29:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
namespace
|
|
|
|
to_string_dispatch
|
|
|
|
{
|
|
|
|
template <class T,class Stub>
|
2008-07-09 00:18:09 +00:00
|
|
|
inline
|
2008-04-08 21:29:37 +00:00
|
|
|
std::string
|
|
|
|
dispatch( T const & x, Stub s )
|
|
|
|
{
|
2008-04-12 03:27:57 +00:00
|
|
|
return to_string_dispatcher<has_to_string<T>::value>::convert(x,s);
|
2008-04-08 21:29:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T>
|
2008-07-09 00:18:09 +00:00
|
|
|
inline
|
2008-04-08 21:29:37 +00:00
|
|
|
std::string
|
|
|
|
string_stub_dump( T const & x )
|
|
|
|
{
|
2008-06-25 23:27:56 +00:00
|
|
|
return "[ " + exception_detail::object_hex_dump(x) + " ]";
|
2008-04-08 21:29:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T>
|
2008-07-09 00:18:09 +00:00
|
|
|
inline
|
2008-04-08 21:29:37 +00:00
|
|
|
std::string
|
|
|
|
to_string_stub( T const & x )
|
|
|
|
{
|
|
|
|
return exception_detail::to_string_dispatch::dispatch(x,&exception_detail::string_stub_dump<T>);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T,class Stub>
|
2008-07-09 00:18:09 +00:00
|
|
|
inline
|
2008-04-08 21:29:37 +00:00
|
|
|
std::string
|
|
|
|
to_string_stub( T const & x, Stub s )
|
|
|
|
{
|
|
|
|
return exception_detail::to_string_dispatch::dispatch(x,s);
|
|
|
|
}
|
2012-07-03 23:41:52 +00:00
|
|
|
|
|
|
|
template <class T,class U,class Stub>
|
|
|
|
inline
|
|
|
|
std::string
|
|
|
|
to_string_stub( std::pair<T,U> const & x, Stub s )
|
|
|
|
{
|
|
|
|
return std::string("(") + to_string_stub(x.first,s) + ',' + to_string_stub(x.second,s) + ')';
|
|
|
|
}
|
2008-04-08 21:29:37 +00:00
|
|
|
}
|
2008-03-04 01:41:17 +00:00
|
|
|
|
2009-12-04 06:33:47 +00:00
|
|
|
#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
|
|
|
|
#pragma warning(pop)
|
|
|
|
#endif
|
2008-03-04 01:41:17 +00:00
|
|
|
#endif
|