PageRenderTime 24ms CodeModel.GetById 8ms app.highlight 13ms RepoModel.GetById 1ms app.codeStats 1ms

/Src/Dependencies/Boost/boost/spirit/home/qi/detail/permute_function.hpp

http://hadesmem.googlecode.com/
C++ Header | 88 lines | 69 code | 9 blank | 10 comment | 6 complexity | 9dc554a487b5d8ad607383e0c5c01ec1 MD5 | raw file
 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