Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/spirit/home/qi/nonterminal/success_handler.hpp @ 16:2665513ce2d3
Add boost headers
author | Chris Cannam |
---|---|
date | Tue, 05 Aug 2014 11:11:38 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
15:663ca0da4350 | 16:2665513ce2d3 |
---|---|
1 /*============================================================================= | |
2 Copyright (c) 2001-2011 Joel de Guzman | |
3 | |
4 Distributed under the Boost Software License, Version 1.0. (See accompanying | |
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
6 ==============================================================================*/ | |
7 #if !defined(BOOST_SPIRIT_SUCCESS_HANDLER_FEBRUARY_25_2011_1051AM) | |
8 #define BOOST_SPIRIT_SUCCESS_HANDLER_FEBRUARY_25_2011_1051AM | |
9 | |
10 #if defined(_MSC_VER) | |
11 #pragma once | |
12 #endif | |
13 | |
14 #include <boost/spirit/home/qi/nonterminal/rule.hpp> | |
15 #include <boost/function.hpp> | |
16 | |
17 namespace boost { namespace spirit { namespace qi | |
18 { | |
19 template < | |
20 typename Iterator, typename Context | |
21 , typename Skipper, typename F | |
22 > | |
23 struct success_handler | |
24 { | |
25 typedef function< | |
26 bool(Iterator& first, Iterator const& last | |
27 , Context& context | |
28 , Skipper const& skipper | |
29 )> | |
30 function_type; | |
31 | |
32 success_handler(function_type subject_, F f_) | |
33 : subject(subject_) | |
34 , f(f_) | |
35 { | |
36 } | |
37 | |
38 bool operator()( | |
39 Iterator& first, Iterator const& last | |
40 , Context& context, Skipper const& skipper) const | |
41 { | |
42 Iterator i = first; | |
43 bool r = subject(i, last, context, skipper); | |
44 if (r) | |
45 { | |
46 typedef | |
47 fusion::vector< | |
48 Iterator& | |
49 , Iterator const& | |
50 , Iterator const&> | |
51 params; | |
52 skip_over(first, last, skipper); | |
53 params args(first, last, i); | |
54 f(args, context); | |
55 | |
56 first = i; | |
57 } | |
58 return r; | |
59 } | |
60 | |
61 function_type subject; | |
62 F f; | |
63 }; | |
64 | |
65 template < | |
66 typename Iterator, typename T0, typename T1, typename T2 | |
67 , typename F> | |
68 void on_success(rule<Iterator, T0, T1, T2>& r, F f) | |
69 { | |
70 typedef rule<Iterator, T0, T1, T2> rule_type; | |
71 | |
72 typedef | |
73 success_handler< | |
74 Iterator | |
75 , typename rule_type::context_type | |
76 , typename rule_type::skipper_type | |
77 , F> | |
78 success_handler; | |
79 r.f = success_handler(r.f, f); | |
80 } | |
81 }}} | |
82 | |
83 #endif |