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_FAIL_FUNCTION_HPP 8 #define BOOST_SPIRIT_QI_DETAIL_FAIL_FUNCTION_HPP 9 10 #if defined(_MSC_VER) 11 #pragma once 12 #endif 13 14 #include <boost/spirit/home/support/unused.hpp> 15 16 namespace boost { namespace spirit { namespace qi { namespace detail 17 { 18 template <typename Iterator, typename Context, typename Skipper> 19 struct fail_function 20 { 21 typedef Iterator iterator_type; 22 typedef Context context_type; 23 fail_functionboost::spirit::qi::detail::fail_function24 fail_function( 25 Iterator& first_, Iterator const& last_ 26 , Context& context_, Skipper const& skipper_) 27 : first(first_) 28 , last(last_) 29 , context(context_) 30 , skipper(skipper_) 31 { 32 } 33 34 template <typename Component, typename Attribute> operator ()boost::spirit::qi::detail::fail_function35 bool operator()(Component const& component, Attribute& attr) const 36 { 37 // return true if the parser fails 38 return !component.parse(first, last, context, skipper, attr); 39 } 40 41 template <typename Component> operator ()boost::spirit::qi::detail::fail_function42 bool operator()(Component const& component) const 43 { 44 // return true if the parser fails 45 return !component.parse(first, last, context, skipper, unused); 46 } 47 48 Iterator& first; 49 Iterator const& last; 50 Context& context; 51 Skipper const& skipper; 52 53 // silence MSVC warning C4512: assignment operator could not be generated 54 BOOST_DELETED_FUNCTION(fail_function& operator= (fail_function const&)) 55 }; 56 }}}} 57 58 #endif 59