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

source code of boost/libs/spirit/include/boost/spirit/home/qi/detail/pass_function.hpp