Chris@16
|
1 /*=============================================================================
|
Chris@16
|
2 Copyright (c) 2001-2011 Joel de Guzman
|
Chris@16
|
3
|
Chris@16
|
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
6 =============================================================================*/
|
Chris@16
|
7 #if !defined(SPIRIT_FAIL_FUNCTION_APRIL_22_2006_0159PM)
|
Chris@16
|
8 #define SPIRIT_FAIL_FUNCTION_APRIL_22_2006_0159PM
|
Chris@16
|
9
|
Chris@16
|
10 #if defined(_MSC_VER)
|
Chris@16
|
11 #pragma once
|
Chris@16
|
12 #endif
|
Chris@16
|
13
|
Chris@16
|
14 #include <boost/spirit/home/support/unused.hpp>
|
Chris@16
|
15
|
Chris@16
|
16 namespace boost { namespace spirit { namespace qi { namespace detail
|
Chris@16
|
17 {
|
Chris@16
|
18 template <typename Iterator, typename Context, typename Skipper>
|
Chris@16
|
19 struct fail_function
|
Chris@16
|
20 {
|
Chris@16
|
21 typedef Iterator iterator_type;
|
Chris@16
|
22 typedef Context context_type;
|
Chris@16
|
23
|
Chris@16
|
24 fail_function(
|
Chris@16
|
25 Iterator& first_, Iterator const& last_
|
Chris@16
|
26 , Context& context_, Skipper const& skipper_)
|
Chris@16
|
27 : first(first_)
|
Chris@16
|
28 , last(last_)
|
Chris@16
|
29 , context(context_)
|
Chris@16
|
30 , skipper(skipper_)
|
Chris@16
|
31 {
|
Chris@16
|
32 }
|
Chris@16
|
33
|
Chris@16
|
34 template <typename Component, typename Attribute>
|
Chris@16
|
35 bool operator()(Component const& component, Attribute& attr) const
|
Chris@16
|
36 {
|
Chris@16
|
37 // return true if the parser fails
|
Chris@16
|
38 return !component.parse(first, last, context, skipper, attr);
|
Chris@16
|
39 }
|
Chris@16
|
40
|
Chris@16
|
41 template <typename Component>
|
Chris@16
|
42 bool operator()(Component const& component) const
|
Chris@16
|
43 {
|
Chris@16
|
44 // return true if the parser fails
|
Chris@16
|
45 return !component.parse(first, last, context, skipper, unused);
|
Chris@16
|
46 }
|
Chris@16
|
47
|
Chris@16
|
48 Iterator& first;
|
Chris@16
|
49 Iterator const& last;
|
Chris@16
|
50 Context& context;
|
Chris@16
|
51 Skipper const& skipper;
|
Chris@16
|
52
|
Chris@16
|
53 private:
|
Chris@16
|
54 // silence MSVC warning C4512: assignment operator could not be generated
|
Chris@16
|
55 fail_function& operator= (fail_function const&);
|
Chris@16
|
56 };
|
Chris@16
|
57 }}}}
|
Chris@16
|
58
|
Chris@16
|
59 #endif
|