exception_translator.hpp 899 B

123456789101112131415161718192021222324252627
  1. // Copyright David Abrahams 2002.
  2. // Distributed under the Boost Software License, Version 1.0. (See
  3. // accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef EXCEPTION_TRANSLATOR_DWA2002810_HPP
  6. # define EXCEPTION_TRANSLATOR_DWA2002810_HPP
  7. # include <boost/python/detail/prefix.hpp>
  8. # include <boost/bind.hpp>
  9. # include <boost/type.hpp>
  10. # include <boost/python/detail/translate_exception.hpp>
  11. # include <boost/python/detail/exception_handler.hpp>
  12. namespace boost { namespace python {
  13. template <class ExceptionType, class Translate>
  14. void register_exception_translator(Translate translate, boost::type<ExceptionType>* = 0)
  15. {
  16. detail::register_exception_handler(
  17. boost::bind<bool>(detail::translate_exception<ExceptionType,Translate>(), _1, _2, translate)
  18. );
  19. }
  20. }} // namespace boost::python
  21. #endif // EXCEPTION_TRANSLATOR_DWA2002810_HPP