annotate DEPENDENCIES/generic/include/boost/spirit/home/qi/nonterminal/success_handler.hpp @ 133:4acb5d8d80b6 tip

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