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