File indexing completed on 2025-01-19 09:47:45
0001
0002
0003
0004
0005
0006
0007 #if !defined(BOOST_SPIRIT_SUCCESS_HANDLER_FEBRUARY_25_2011_1051AM)
0008 #define BOOST_SPIRIT_SUCCESS_HANDLER_FEBRUARY_25_2011_1051AM
0009
0010 #if defined(_MSC_VER)
0011 #pragma once
0012 #endif
0013
0014 #include <boost/spirit/home/qi/nonterminal/rule.hpp>
0015 #include <boost/function.hpp>
0016
0017 namespace boost { namespace spirit { namespace qi
0018 {
0019 template <
0020 typename Iterator, typename Context
0021 , typename Skipper, typename F
0022 >
0023 struct success_handler
0024 {
0025 typedef function<
0026 bool(Iterator& first, Iterator const& last
0027 , Context& context
0028 , Skipper const& skipper
0029 )>
0030 function_type;
0031
0032 success_handler(function_type subject_, F f_)
0033 : subject(subject_)
0034 , f(f_)
0035 {
0036 }
0037
0038 bool operator()(
0039 Iterator& first, Iterator const& last
0040 , Context& context, Skipper const& skipper) const
0041 {
0042 Iterator i = first;
0043 bool r = subject(i, last, context, skipper);
0044 if (r)
0045 {
0046 typedef
0047 fusion::vector<
0048 Iterator&
0049 , Iterator const&
0050 , Iterator const&>
0051 params;
0052 skip_over(first, last, skipper);
0053 params args(first, last, i);
0054 f(args, context);
0055
0056 first = i;
0057 }
0058 return r;
0059 }
0060
0061 function_type subject;
0062 F f;
0063 };
0064
0065 template <
0066 typename Iterator, typename T0, typename T1, typename T2
0067 , typename F>
0068 void on_success(rule<Iterator, T0, T1, T2>& r, F f)
0069 {
0070 typedef rule<Iterator, T0, T1, T2> rule_type;
0071
0072 typedef
0073 success_handler<
0074 Iterator
0075 , typename rule_type::context_type
0076 , typename rule_type::skipper_type
0077 , F>
0078 success_handler;
0079 r.f = success_handler(r.f, f);
0080 }
0081 }}}
0082
0083 #endif