PageRenderTime 21ms CodeModel.GetById 15ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/src/contrib/boost/spirit/home/support/action_dispatch.hpp

http://pythonocc.googlecode.com/
C++ Header | 84 lines | 58 code | 11 blank | 15 comment | 0 complexity | d67ef71083b715e2f6e846a4a120aa62 MD5 | raw file
 1/*=============================================================================
 2    Copyright (c) 2001-2010 Joel de Guzman
 3    Copyright (c) 2001-2010 Hartmut Kaiser
 4    http://spirit.sourceforge.net/
 5
 6    Distributed under the Boost Software License, Version 1.0. (See accompanying
 7    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 8=============================================================================*/
 9#if !defined(BOOST_SPIRIT_ACTION_DISPATCH_APRIL_18_2008_0720AM)
10#define BOOST_SPIRIT_ACTION_DISPATCH_APRIL_18_2008_0720AM
11
12#if defined(_MSC_VER)
13#pragma once
14#endif
15
16#include <boost/spirit/home/phoenix/core/actor.hpp>
17#include <boost/spirit/home/support/attributes.hpp>
18
19namespace boost { namespace spirit { namespace traits
20{
21    template <typename Component>
22    struct action_dispatch
23    {
24        // general handler for everything not explicitly specialized below
25        template <typename F, typename Attribute, typename Context>
26        bool operator()(F const& f, Attribute& attr, Context& context)
27        {
28            bool pass = true;
29            f(attr, context, pass);
30            return pass;
31        }
32
33        // handler for phoenix actors
34
35        // If the component this action has to be invoked for is a tuple, we
36        // wrap any non-fusion tuple into a fusion tuple (done by pass_attribute)
37        // and pass through any fusion tuple.
38        template <typename Eval, typename Attribute, typename Context>
39        bool operator()(phoenix::actor<Eval> const& f
40          , Attribute& attr, Context& context)
41        {
42            bool pass = true;
43            typename pass_attribute<Component, Attribute>::type attr_wrap(attr);
44            f(attr_wrap, context, pass);
45            return pass;
46        }
47
48        // specializations for plain function pointers taking different number of
49        // arguments
50        template <typename RT, typename A0, typename A1, typename A2
51          , typename Attribute, typename Context>
52        bool operator()(RT(*f)(A0, A1, A2), Attribute& attr, Context& context)
53        {
54            bool pass = true;
55            f(attr, context, pass);
56            return pass;
57        }
58
59        template <typename RT, typename A0, typename A1
60          , typename Attribute, typename Context>
61        bool operator()(RT(*f)(A0, A1), Attribute& attr, Context& context)
62        {
63            f(attr, context);
64            return true;
65        }
66
67        template <typename RT, typename A0, typename Attribute, typename Context>
68        bool operator()(RT(*f)(A0), Attribute& attr, Context&)
69        {
70            f(attr);
71            return true;
72        }
73
74        template <typename RT, typename Attribute, typename Context>
75        bool operator()(RT(*f)(), Attribute&, Context&)
76        {
77            f();
78            return true;
79        }
80    };
81
82}}}
83
84#endif