os/ossrv/ossrv_pub/boost_apis/boost/detail/catch_exceptions.hpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/detail/catch_exceptions.hpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,146 @@
     1.4 +//  boost/catch_exceptions.hpp -----------------------------------------------//
     1.5 +
     1.6 +//  Copyright Beman Dawes 1995-2001.  Distributed under the Boost
     1.7 +//  Software License, Version 1.0. (See accompanying file
     1.8 +//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
     1.9 +
    1.10 +//  See http://www.boost.org/libs/test for documentation.
    1.11 +
    1.12 +//  Revision History
    1.13 +//   13 Jun 01 report_exception() made inline. (John Maddock, Jesse Jones)
    1.14 +//   26 Feb 01 Numerous changes suggested during formal review. (Beman)
    1.15 +//   25 Jan 01 catch_exceptions.hpp code factored out of cpp_main.cpp.
    1.16 +//   22 Jan 01 Remove test_tools dependencies to reduce coupling.
    1.17 +//    5 Nov 00 Initial boost version (Beman Dawes)
    1.18 +
    1.19 +#ifndef BOOST_CATCH_EXCEPTIONS_HPP
    1.20 +#define BOOST_CATCH_EXCEPTIONS_HPP
    1.21 +
    1.22 +//  header dependencies are deliberately restricted to the standard library
    1.23 +//  to reduce coupling to other boost libraries.
    1.24 +#include <string>             // for string
    1.25 +#include <new>                // for bad_alloc
    1.26 +#include <typeinfo>           // for bad_cast, bad_typeid
    1.27 +#include <exception>          // for exception, bad_exception
    1.28 +#include <stdexcept>          // for std exception hierarchy
    1.29 +#include <boost/cstdlib.hpp>  // for exit codes
    1.30 +# if __GNUC__ != 2 || __GNUC_MINOR__ > 96
    1.31 +#   include <ostream>         // for ostream
    1.32 +# else
    1.33 +#   include <iostream> // workaround GNU missing ostream header
    1.34 +# endif
    1.35 +
    1.36 +# if defined(__BORLANDC__) && (__BORLANDC__ <= 0x0551)
    1.37 +#   define BOOST_BUILT_IN_EXCEPTIONS_MISSING_WHAT 
    1.38 +# endif
    1.39 +
    1.40 +#if defined(MPW_CPLUS) && (MPW_CPLUS <= 0x890)
    1.41 +#   define BOOST_BUILT_IN_EXCEPTIONS_MISSING_WHAT 
    1.42 +    namespace std { class bad_typeid { }; }
    1.43 +# endif
    1.44 +
    1.45 +namespace boost
    1.46 +{
    1.47 +
    1.48 +  namespace detail
    1.49 +  {
    1.50 +    //  A separate reporting function was requested during formal review.
    1.51 +    inline void report_exception( std::ostream & os, 
    1.52 +                                  const char * name, const char * info )
    1.53 +      { os << "\n** uncaught exception: " << name << " " << info << std::endl; }
    1.54 +  }
    1.55 +
    1.56 +  //  catch_exceptions  ------------------------------------------------------//
    1.57 +
    1.58 +  template< class Generator >  // Generator is function object returning int
    1.59 +  int catch_exceptions( Generator function_object,
    1.60 +                        std::ostream & out, std::ostream & err )
    1.61 +  {
    1.62 +    int result = 0;               // quiet compiler warnings
    1.63 +    bool exception_thrown = true; // avoid setting result for each excptn type
    1.64 +
    1.65 +#ifndef BOOST_NO_EXCEPTIONS
    1.66 +    try
    1.67 +    {
    1.68 +#endif
    1.69 +      result = function_object();
    1.70 +      exception_thrown = false;
    1.71 +#ifndef BOOST_NO_EXCEPTIONS
    1.72 +    }
    1.73 +
    1.74 +    //  As a result of hard experience with strangely interleaved output
    1.75 +    //  under some compilers, there is a lot of use of endl in the code below
    1.76 +    //  where a simple '\n' might appear to do.
    1.77 +
    1.78 +    //  The rules for catch & arguments are a bit different from function 
    1.79 +    //  arguments (ISO 15.3 paragraphs 18 & 19). Apparently const isn't
    1.80 +    //  required, but it doesn't hurt and some programmers ask for it.
    1.81 +
    1.82 +    catch ( const char * ex )
    1.83 +      { detail::report_exception( out, "", ex ); }
    1.84 +    catch ( const std::string & ex )
    1.85 +      { detail::report_exception( out, "", ex.c_str() ); }
    1.86 +
    1.87 +    //  std:: exceptions
    1.88 +    catch ( const std::bad_alloc & ex )
    1.89 +      { detail::report_exception( out, "std::bad_alloc:", ex.what() ); }
    1.90 +
    1.91 +# ifndef BOOST_BUILT_IN_EXCEPTIONS_MISSING_WHAT
    1.92 +    catch ( const std::bad_cast & ex )
    1.93 +      { detail::report_exception( out, "std::bad_cast:", ex.what() ); }
    1.94 +    catch ( const std::bad_typeid & ex )
    1.95 +      { detail::report_exception( out, "std::bad_typeid:", ex.what() ); }
    1.96 +# else
    1.97 +    catch ( const std::bad_cast & )
    1.98 +      { detail::report_exception( out, "std::bad_cast", "" ); }
    1.99 +    catch ( const std::bad_typeid & )
   1.100 +      { detail::report_exception( out, "std::bad_typeid", "" ); }
   1.101 +# endif
   1.102 +
   1.103 +    catch ( const std::bad_exception & ex )
   1.104 +      { detail::report_exception( out, "std::bad_exception:", ex.what() ); }
   1.105 +    catch ( const std::domain_error & ex )
   1.106 +      { detail::report_exception( out, "std::domain_error:", ex.what() ); }
   1.107 +    catch ( const std::invalid_argument & ex )
   1.108 +      { detail::report_exception( out, "std::invalid_argument:", ex.what() ); }
   1.109 +    catch ( const std::length_error & ex )
   1.110 +      { detail::report_exception( out, "std::length_error:", ex.what() ); }
   1.111 +    catch ( const std::out_of_range & ex )
   1.112 +      { detail::report_exception( out, "std::out_of_range:", ex.what() ); }
   1.113 +    catch ( const std::range_error & ex )
   1.114 +      { detail::report_exception( out, "std::range_error:", ex.what() ); }
   1.115 +    catch ( const std::overflow_error & ex )
   1.116 +      { detail::report_exception( out, "std::overflow_error:", ex.what() ); }
   1.117 +    catch ( const std::underflow_error & ex )
   1.118 +      { detail::report_exception( out, "std::underflow_error:", ex.what() ); }
   1.119 +    catch ( const std::logic_error & ex )
   1.120 +      { detail::report_exception( out, "std::logic_error:", ex.what() ); }
   1.121 +    catch ( const std::runtime_error & ex )
   1.122 +      { detail::report_exception( out, "std::runtime_error:", ex.what() ); }
   1.123 +    catch ( const std::exception & ex )
   1.124 +      { detail::report_exception( out, "std::exception:", ex.what() ); }
   1.125 +
   1.126 +    catch ( ... )
   1.127 +      { detail::report_exception( out, "unknown exception", "" ); }
   1.128 +#endif // BOOST_NO_EXCEPTIONS
   1.129 +
   1.130 +    if ( exception_thrown ) result = boost::exit_exception_failure;
   1.131 +
   1.132 +    if ( result != 0 && result != exit_success )
   1.133 +    {
   1.134 +      out << std::endl << "**** returning with error code "
   1.135 +                << result << std::endl;
   1.136 +      err
   1.137 +        << "**********  errors detected; see stdout for details  ***********"
   1.138 +        << std::endl;
   1.139 +    }
   1.140 +#if !defined(BOOST_NO_CPP_MAIN_SUCCESS_MESSAGE)
   1.141 +    else { out << std::flush << "no errors detected" << std::endl; }
   1.142 +#endif
   1.143 +    return result;
   1.144 +  } // catch_exceptions
   1.145 +
   1.146 +} // boost
   1.147 +
   1.148 +#endif  // BOOST_CATCH_EXCEPTIONS_HPP
   1.149 +