]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/spirit/include/boost/spirit/home/qi/detail/permute_function.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / spirit / include / boost / spirit / home / qi / detail / permute_function.hpp
CommitLineData
7c673cae
FG
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_PERMUTE_FUNCTION_MARCH_13_2007_1129AM)
8#define SPIRIT_PERMUTE_FUNCTION_MARCH_13_2007_1129AM
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 template <typename Iterator, typename Context, typename Skipper>
20 struct permute_function
21 {
22 permute_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 and the slot is not yet taken
36 if (!*taken && component.parse(first, last, context, skipper, attr))
37 {
38 *taken = true;
39 ++taken;
40 return true;
41 }
42 ++taken;
43 return false;
44 }
45
46 template <typename Component, typename Attribute>
47 bool operator()(Component const& component, boost::optional<Attribute>& attr)
48 {
49 // return true if the parser succeeds and the slot is not yet taken
50 Attribute val;
51 if (!*taken && component.parse(first, last, context, skipper, val))
52 {
53 attr = val;
54 *taken = true;
55 ++taken;
56 return true;
57 }
58 ++taken;
59 return false;
60 }
61
62 template <typename Component>
63 bool operator()(Component const& component)
64 {
65 // return true if the parser succeeds and the slot is not yet taken
66 if (!*taken && component.parse(first, last, context, skipper, unused))
67 {
68 *taken = true;
69 ++taken;
70 return true;
71 }
72 ++taken;
73 return false;
74 }
75
76 Iterator& first;
77 Iterator const& last;
78 Context& context;
79 Skipper const& skipper;
80 bool* taken;
81
82 private:
83 // silence MSVC warning C4512: assignment operator could not be generated
84 permute_function& operator= (permute_function const&);
85 };
86}}}}
87
88#endif