]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/include/boost/spirit/home/qi/detail/pass_function.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / spirit / include / boost / spirit / home / qi / detail / pass_function.hpp
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 #if !defined(SPIRIT_PASS_FUNCTION_FEBRUARY_05_2007_1138AM)
8 #define SPIRIT_PASS_FUNCTION_FEBRUARY_05_2007_1138AM
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 {
22 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>
33 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>
40 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>
53 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 private:
65 // silence MSVC warning C4512: assignment operator could not be generated
66 pass_function& operator= (pass_function const&);
67 };
68 }}}}
69
70 #endif