// -*- c++ -*- /* Do not edit! -- generated file */ #ifndef _SIGC_ADAPTORS_MACROS_EXCEPTION_CATCHHM4_ #define _SIGC_ADAPTORS_MACROS_EXCEPTION_CATCHHM4_ #include namespace sigc { /* functor adaptor: exception_catch(functor, catcher) usage: Future directions: The catcher should be told what type of return it needs to return for multiple type functors, to do this the user will need to derive from catcher_base. */ /** @defgroup exception_catch exception_catch() * sigc::exception_catch() catches an exception thrown from within * the wrapped functor and directs it to a catcher functor. * This catcher can then rethrow the exception and catch it with the proper type. * * Note that the catcher is expected to return the same type * as the wrapped functor so that normal flow can continue. * * Catchers can be cascaded to catch multiple types because uncaught * rethrown exceptions proceed to the next catcher adaptor. * * @par Examples: * @code * struct my_catch * { * int operator()() * { * try { throw; } * catch (std::range_error e) // catch what types we know * { std::cerr << "caught " << e.what() << std::endl; } * return 1; * } * } * int foo(); // throws std::range_error * sigc::exception_catch(&foo, my_catch())(); * @endcode * * The functor sigc::execption_catch() returns can be passed into * sigc::signal::connect() directly. * * @par Example: * @code * sigc::signal some_signal; * some_signal.connect(sigc::exception_catch(&foo, my_catch)); * @endcode * * @ingroup adaptors */ template ::result_type> struct exception_catch_functor : public adapts { typedef typename adapts::adaptor_type adaptor_type; template struct deduce_result_type { typedef typename adaptor_type::template deduce_result_type::pass, typename type_trait::pass, typename type_trait::pass, typename type_trait::pass, typename type_trait::pass, typename type_trait::pass, typename type_trait::pass>::type type; }; typedef T_return result_type; result_type operator()(); template typename deduce_result_type::type operator()(T_arg1 _A_a1) { try { return this->functor_.SIGC_WORKAROUND_OPERATOR_PARENTHESES::pass> (_A_a1); } catch (...) { return catcher_(); } } template typename deduce_result_type::type operator()(T_arg1 _A_a1, T_arg2 _A_a2) { try { return this->functor_.SIGC_WORKAROUND_OPERATOR_PARENTHESES::pass, typename type_trait::pass> (_A_a1, _A_a2); } catch (...) { return catcher_(); } } template typename deduce_result_type::type operator()(T_arg1 _A_a1, T_arg2 _A_a2, T_arg3 _A_a3) { try { return this->functor_.SIGC_WORKAROUND_OPERATOR_PARENTHESES::pass, typename type_trait::pass, typename type_trait::pass> (_A_a1, _A_a2, _A_a3); } catch (...) { return catcher_(); } } template typename deduce_result_type::type operator()(T_arg1 _A_a1, T_arg2 _A_a2, T_arg3 _A_a3, T_arg4 _A_a4) { try { return this->functor_.SIGC_WORKAROUND_OPERATOR_PARENTHESES::pass, typename type_trait::pass, typename type_trait::pass, typename type_trait::pass> (_A_a1, _A_a2, _A_a3, _A_a4); } catch (...) { return catcher_(); } } template typename deduce_result_type::type operator()(T_arg1 _A_a1, T_arg2 _A_a2, T_arg3 _A_a3, T_arg4 _A_a4, T_arg5 _A_a5) { try { return this->functor_.SIGC_WORKAROUND_OPERATOR_PARENTHESES::pass, typename type_trait::pass, typename type_trait::pass, typename type_trait::pass, typename type_trait::pass> (_A_a1, _A_a2, _A_a3, _A_a4, _A_a5); } catch (...) { return catcher_(); } } template typename deduce_result_type::type operator()(T_arg1 _A_a1, T_arg2 _A_a2, T_arg3 _A_a3, T_arg4 _A_a4, T_arg5 _A_a5, T_arg6 _A_a6) { try { return this->functor_.SIGC_WORKAROUND_OPERATOR_PARENTHESES::pass, typename type_trait::pass, typename type_trait::pass, typename type_trait::pass, typename type_trait::pass, typename type_trait::pass> (_A_a1, _A_a2, _A_a3, _A_a4, _A_a5, _A_a6); } catch (...) { return catcher_(); } } template typename deduce_result_type::type operator()(T_arg1 _A_a1, T_arg2 _A_a2, T_arg3 _A_a3, T_arg4 _A_a4, T_arg5 _A_a5, T_arg6 _A_a6, T_arg7 _A_a7) { try { return this->functor_.SIGC_WORKAROUND_OPERATOR_PARENTHESES::pass, typename type_trait::pass, typename type_trait::pass, typename type_trait::pass, typename type_trait::pass, typename type_trait::pass, typename type_trait::pass> (_A_a1, _A_a2, _A_a3, _A_a4, _A_a5, _A_a6, _A_a7); } catch (...) { return catcher_(); } } exception_catch_functor(const T_functor& _A_func, const T_catcher& _A_catcher) : adapts(_A_func), catcher_(_A_catcher) {} T_catcher catcher_; }; template typename exception_catch_functor::result_type exception_catch_functor::operator()() { try { return this->functor_(); } catch (...) { return catcher_(); } } // void specialization template struct exception_catch_functor : public adapts { typedef void result_type; typedef typename adapts::adaptor_type adaptor_type; void operator()(); template typename deduce_result_type::type operator()(T_arg1 _A_a1) { try { return this->functor_.SIGC_WORKAROUND_OPERATOR_PARENTHESES::pass> (_A_a1); } catch (...) { return catcher_(); } } template typename deduce_result_type::type operator()(T_arg1 _A_a1, T_arg2 _A_a2) { try { return this->functor_.SIGC_WORKAROUND_OPERATOR_PARENTHESES::pass, typename type_trait::pass> (_A_a1, _A_a2); } catch (...) { return catcher_(); } } template typename deduce_result_type::type operator()(T_arg1 _A_a1, T_arg2 _A_a2, T_arg3 _A_a3) { try { return this->functor_.SIGC_WORKAROUND_OPERATOR_PARENTHESES::pass, typename type_trait::pass, typename type_trait::pass> (_A_a1, _A_a2, _A_a3); } catch (...) { return catcher_(); } } template typename deduce_result_type::type operator()(T_arg1 _A_a1, T_arg2 _A_a2, T_arg3 _A_a3, T_arg4 _A_a4) { try { return this->functor_.SIGC_WORKAROUND_OPERATOR_PARENTHESES::pass, typename type_trait::pass, typename type_trait::pass, typename type_trait::pass> (_A_a1, _A_a2, _A_a3, _A_a4); } catch (...) { return catcher_(); } } template typename deduce_result_type::type operator()(T_arg1 _A_a1, T_arg2 _A_a2, T_arg3 _A_a3, T_arg4 _A_a4, T_arg5 _A_a5) { try { return this->functor_.SIGC_WORKAROUND_OPERATOR_PARENTHESES::pass, typename type_trait::pass, typename type_trait::pass, typename type_trait::pass, typename type_trait::pass> (_A_a1, _A_a2, _A_a3, _A_a4, _A_a5); } catch (...) { return catcher_(); } } template typename deduce_result_type::type operator()(T_arg1 _A_a1, T_arg2 _A_a2, T_arg3 _A_a3, T_arg4 _A_a4, T_arg5 _A_a5, T_arg6 _A_a6) { try { return this->functor_.SIGC_WORKAROUND_OPERATOR_PARENTHESES::pass, typename type_trait::pass, typename type_trait::pass, typename type_trait::pass, typename type_trait::pass, typename type_trait::pass> (_A_a1, _A_a2, _A_a3, _A_a4, _A_a5, _A_a6); } catch (...) { return catcher_(); } } template typename deduce_result_type::type operator()(T_arg1 _A_a1, T_arg2 _A_a2, T_arg3 _A_a3, T_arg4 _A_a4, T_arg5 _A_a5, T_arg6 _A_a6, T_arg7 _A_a7) { try { return this->functor_.SIGC_WORKAROUND_OPERATOR_PARENTHESES::pass, typename type_trait::pass, typename type_trait::pass, typename type_trait::pass, typename type_trait::pass, typename type_trait::pass, typename type_trait::pass> (_A_a1, _A_a2, _A_a3, _A_a4, _A_a5, _A_a6, _A_a7); } catch (...) { return catcher_(); } } exception_catch_functor() {} exception_catch_functor(const T_functor& _A_func, const T_catcher& _A_catcher) : adapts(_A_func), catcher_(_A_catcher) {} ~exception_catch_functor() {} T_catcher catcher_; }; template void exception_catch_functor::operator()() { try { this->functor_(); } // I don't understand why void return doesn't work here (Martin) catch (...) { this->catcher_(); } } //template specialization of visit_each<>(action, functor): template void visit_each(const T_action& _A_action, const exception_catch_functor& _A_target) { visit_each(_A_action, _A_target.functor_); visit_each(_A_action, _A_target.catcher_); } template inline exception_catch_functor exception_catch(const T_functor& _A_func, const T_catcher& _A_catcher) { return exception_catch_functor(_A_func, _A_catcher); } } /* namespace sigc */ #endif /* _SIGC_ADAPTORS_MACROS_EXCEPTION_CATCHHM4_ */