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(SPIRIT_PASS_FUNCTION_FEBRUARY_05_2007_1138AM)
|
Chris@16
|
8 #define SPIRIT_PASS_FUNCTION_FEBRUARY_05_2007_1138AM
|
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/support/unused.hpp>
|
Chris@16
|
15 #include <boost/optional.hpp>
|
Chris@16
|
16
|
Chris@16
|
17 namespace boost { namespace spirit { namespace qi { namespace detail
|
Chris@16
|
18 {
|
Chris@16
|
19 template <typename Iterator, typename Context, typename Skipper>
|
Chris@16
|
20 struct pass_function
|
Chris@16
|
21 {
|
Chris@16
|
22 pass_function(
|
Chris@16
|
23 Iterator& first_, Iterator const& last_
|
Chris@16
|
24 , Context& context_, Skipper const& skipper_)
|
Chris@16
|
25 : first(first_)
|
Chris@16
|
26 , last(last_)
|
Chris@16
|
27 , context(context_)
|
Chris@16
|
28 , skipper(skipper_)
|
Chris@16
|
29 {
|
Chris@16
|
30 }
|
Chris@16
|
31
|
Chris@16
|
32 template <typename Component, typename Attribute>
|
Chris@16
|
33 bool operator()(Component const& component, Attribute& attr)
|
Chris@16
|
34 {
|
Chris@16
|
35 // return true if the parser succeeds
|
Chris@16
|
36 return component.parse(first, last, context, skipper, attr);
|
Chris@16
|
37 }
|
Chris@16
|
38
|
Chris@16
|
39 template <typename Component, typename Attribute>
|
Chris@16
|
40 bool operator()(Component const& component, boost::optional<Attribute>& attr)
|
Chris@16
|
41 {
|
Chris@16
|
42 // return true if the parser succeeds
|
Chris@16
|
43 Attribute val;
|
Chris@16
|
44 if (component.parse(first, last, context, skipper, val))
|
Chris@16
|
45 {
|
Chris@16
|
46 attr = val;
|
Chris@16
|
47 return true;
|
Chris@16
|
48 }
|
Chris@16
|
49 return false;
|
Chris@16
|
50 }
|
Chris@16
|
51
|
Chris@16
|
52 template <typename Component>
|
Chris@16
|
53 bool operator()(Component const& component)
|
Chris@16
|
54 {
|
Chris@16
|
55 // return true if the parser succeeds
|
Chris@16
|
56 return component.parse(first, last, context, skipper, unused);
|
Chris@16
|
57 }
|
Chris@16
|
58
|
Chris@16
|
59 Iterator& first;
|
Chris@16
|
60 Iterator const& last;
|
Chris@16
|
61 Context& context;
|
Chris@16
|
62 Skipper const& skipper;
|
Chris@16
|
63
|
Chris@16
|
64 private:
|
Chris@16
|
65 // silence MSVC warning C4512: assignment operator could not be generated
|
Chris@16
|
66 pass_function& operator= (pass_function const&);
|
Chris@16
|
67 };
|
Chris@16
|
68 }}}}
|
Chris@16
|
69
|
Chris@16
|
70 #endif
|