| 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 | #ifdef _MSC_VER |
| 19 | # pragma warning(push) |
| 20 | # pragma warning(disable: 4512) // assignment operator could not be generated. |
| 21 | #endif |
| 22 | template <typename Iterator, typename Context, typename Skipper> |
| 23 | struct fail_function |
| 24 | { |
| 25 | typedef Iterator iterator_type; |
| 26 | typedef Context context_type; |
| 27 | |
| 28 | fail_function( |
| 29 | Iterator& first_, Iterator const& last_ |
| 30 | , Context& context_, Skipper const& skipper_) |
| 31 | : first(first_) |
| 32 | , last(last_) |
| 33 | , context(context_) |
| 34 | , skipper(skipper_) |
| 35 | { |
| 36 | } |
| 37 | |
| 38 | template <typename Component, typename Attribute> |
| 39 | bool operator()(Component const& component, Attribute& attr) const |
| 40 | { |
| 41 | // return true if the parser fails |
| 42 | return !component.parse(first, last, context, skipper, attr); |
| 43 | } |
| 44 | |
| 45 | template <typename Component> |
| 46 | bool operator()(Component const& component) const |
| 47 | { |
| 48 | // return true if the parser fails |
| 49 | return !component.parse(first, last, context, skipper, unused); |
| 50 | } |
| 51 | |
| 52 | Iterator& first; |
| 53 | Iterator const& last; |
| 54 | Context& context; |
| 55 | Skipper const& skipper; |
| 56 | }; |
| 57 | #ifdef _MSC_VER |
| 58 | # pragma warning(pop) |
| 59 | #endif |
| 60 | }}}} |
| 61 | |
| 62 | #endif |
| 63 | |