exception_translator.hpp 939 B

12345678910111213141516171819202122232425262728
  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/bind/placeholders.hpp>
  10. # include <boost/type.hpp>
  11. # include <boost/python/detail/translate_exception.hpp>
  12. # include <boost/python/detail/exception_handler.hpp>
  13. namespace boost { namespace python {
  14. template <class ExceptionType, class Translate>
  15. void register_exception_translator(Translate translate, boost::type<ExceptionType>* = 0)
  16. {
  17. detail::register_exception_handler(
  18. boost::bind<bool>(detail::translate_exception<ExceptionType,Translate>(), _1, _2, translate)
  19. );
  20. }
  21. }} // namespace boost::python
  22. #endif // EXCEPTION_TRANSLATOR_DWA2002810_HPP