Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/spirit/home/qi/detail/permute_function.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*=============================================================================
0002     Copyright (c) 2001-2011 Joel de Guzman
0003 
0004     Distributed under the Boost Software License, Version 1.0. (See accompanying
0005     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 =============================================================================*/
0007 #ifndef BOOST_SPIRIT_QI_DETAIL_PERMUTE_FUNCTION_HPP
0008 #define BOOST_SPIRIT_QI_DETAIL_PERMUTE_FUNCTION_HPP
0009 
0010 #if defined(_MSC_VER)
0011 #pragma once
0012 #endif
0013 
0014 #include <boost/spirit/home/support/unused.hpp>
0015 #include <boost/optional.hpp>
0016 
0017 namespace boost { namespace spirit { namespace qi { namespace detail
0018 {
0019 #ifdef _MSC_VER
0020 #  pragma warning(push)
0021 #  pragma warning(disable: 4512) // assignment operator could not be generated.
0022 #endif
0023     template <typename Iterator, typename Context, typename Skipper>
0024     struct permute_function
0025     {
0026         permute_function(
0027             Iterator& first_, Iterator const& last_
0028           , Context& context_, Skipper const& skipper_)
0029           : first(first_)
0030           , last(last_)
0031           , context(context_)
0032           , skipper(skipper_)
0033         {
0034         }
0035 
0036         template <typename Component, typename Attribute>
0037         bool operator()(Component const& component, Attribute& attr)
0038         {
0039             // return true if the parser succeeds and the slot is not yet taken
0040             if (!*taken && component.parse(first, last, context, skipper, attr))
0041             {
0042                 *taken = true;
0043                 ++taken;
0044                 return true;
0045             }
0046             ++taken;
0047             return false;
0048         }
0049 
0050         template <typename Component>
0051         bool operator()(Component const& component)
0052         {
0053             // return true if the parser succeeds and the slot is not yet taken
0054             if (!*taken && component.parse(first, last, context, skipper, unused))
0055             {
0056                 *taken = true;
0057                 ++taken;
0058                 return true;
0059             }
0060             ++taken;
0061             return false;
0062         }
0063 
0064         Iterator& first;
0065         Iterator const& last;
0066         Context& context;
0067         Skipper const& skipper;
0068         bool* taken;
0069     };
0070 #ifdef _MSC_VER
0071 #  pragma warning(pop)
0072 #endif
0073 }}}}
0074 
0075 #endif