]>
Commit | Line | Data |
---|---|---|
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_FAIL_FUNCTION_APRIL_22_2006_0159PM) | |
8 | #define SPIRIT_FAIL_FUNCTION_APRIL_22_2006_0159PM | |
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 | ||
24 | 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> | |
35 | 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> | |
42 | 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 | private: | |
54 | // silence MSVC warning C4512: assignment operator could not be generated | |
55 | fail_function& operator= (fail_function const&); | |
56 | }; | |
57 | }}}} | |
58 | ||
59 | #endif |