Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:30:47

0001 //Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
0002 
0003 //Distributed under the Boost Software License, Version 1.0. (See accompanying
0004 //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0005 
0006 #ifndef BOOST_EXCEPTION_E788439ED9F011DCB181F25B55D89593
0007 #define BOOST_EXCEPTION_E788439ED9F011DCB181F25B55D89593
0008 
0009 #include <boost/exception/to_string.hpp>
0010 #include <boost/exception/detail/object_hex_dump.hpp>
0011 #include <boost/assert.hpp>
0012 
0013 #ifndef BOOST_EXCEPTION_ENABLE_WARNINGS
0014 #if __GNUC__*100+__GNUC_MINOR__>301
0015 #pragma GCC system_header
0016 #endif
0017 #ifdef __clang__
0018 #pragma clang system_header
0019 #endif
0020 #ifdef _MSC_VER
0021 #pragma warning(push,1)
0022 #endif
0023 #endif
0024 
0025 namespace
0026 boost
0027     {
0028     namespace
0029     exception_detail
0030         {
0031         template <bool ToStringAvailable>
0032         struct
0033         to_string_dispatcher
0034             {
0035             template <class T,class Stub>
0036             static
0037             std::string
0038             convert( T const & x, Stub )
0039                 {
0040                 return to_string(x);
0041                 }
0042             };
0043 
0044         template <>
0045         struct
0046         to_string_dispatcher<false>
0047             {
0048             template <class T,class Stub>
0049             static
0050             std::string
0051             convert( T const & x, Stub s )
0052                 {
0053                 return s(x);
0054                 }
0055 
0056             template <class T>
0057             static
0058             std::string
0059             convert( T const & x, std::string s )
0060                 {
0061                 return s;
0062                 }
0063 
0064             template <class T>
0065             static
0066             std::string
0067             convert( T const & x, char const * s )
0068                 {
0069                 BOOST_ASSERT(s!=0);
0070                 return s;
0071                 }
0072             };
0073 
0074         namespace
0075         to_string_dispatch
0076             {
0077             template <class T,class Stub>
0078             inline
0079             std::string
0080             dispatch( T const & x, Stub s )
0081                 {
0082                 return to_string_dispatcher<has_to_string<T>::value>::convert(x,s);
0083                 }
0084             }
0085 
0086         template <class T>
0087         inline
0088         std::string
0089         string_stub_dump( T const & x )
0090             {
0091             return "[ " + exception_detail::object_hex_dump(x) + " ]";
0092             }
0093         }
0094 
0095     template <class T>
0096     inline
0097     std::string
0098     to_string_stub( T const & x )
0099         {
0100         return exception_detail::to_string_dispatch::dispatch(x,&exception_detail::string_stub_dump<T>);
0101         }
0102 
0103     template <class T,class Stub>
0104     inline
0105     std::string
0106     to_string_stub( T const & x, Stub s )
0107         {
0108         return exception_detail::to_string_dispatch::dispatch(x,s);
0109         }
0110 
0111     template <class T,class U,class Stub>
0112     inline
0113     std::string
0114     to_string_stub( std::pair<T,U> const & x, Stub s )
0115         {
0116         return std::string("(") + to_string_stub(x.first,s) + ',' + to_string_stub(x.second,s) + ')';
0117         }
0118     }
0119 
0120 #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
0121 #pragma warning(pop)
0122 #endif
0123 #endif