]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Copyright (c) 2001-2011 Hartmut Kaiser |
2 | // | |
3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | |
4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
5 | ||
6 | #if !defined(BOOST_SPIRIT_QI_UNUSED_SKIPPER_JUL_25_2009_0921AM) | |
7 | #define BOOST_SPIRIT_QI_UNUSED_SKIPPER_JUL_25_2009_0921AM | |
8 | ||
9 | #if defined(_MSC_VER) | |
10 | #pragma once | |
11 | #endif | |
12 | ||
13 | #include <boost/spirit/home/support/unused.hpp> | |
14 | #include <boost/mpl/bool.hpp> | |
15 | ||
16 | namespace boost { namespace spirit { namespace qi { namespace detail | |
17 | { | |
18 | template <typename Skipper> | |
19 | struct unused_skipper : unused_type | |
20 | { | |
21 | unused_skipper(Skipper const& skipper_) | |
22 | : skipper(skipper_) {} | |
23 | Skipper const& skipper; | |
24 | ||
25 | private: | |
26 | // silence MSVC warning C4512: assignment operator could not be generated | |
27 | unused_skipper& operator= (unused_skipper const&); | |
28 | }; | |
29 | ||
30 | template <typename Skipper> | |
31 | struct is_unused_skipper | |
32 | : mpl::false_ {}; | |
33 | ||
34 | template <typename Skipper> | |
35 | struct is_unused_skipper<unused_skipper<Skipper> > | |
36 | : mpl::true_ {}; | |
37 | ||
38 | template <> | |
39 | struct is_unused_skipper<unused_type> | |
40 | : mpl::true_ {}; | |
41 | ||
42 | // If a surrounding lexeme[] directive was specified, the current | |
43 | // skipper is of the type unused_skipper. In this case we | |
44 | // re-activate the skipper which was active before the skip[] | |
45 | // directive. | |
46 | template <typename Skipper> | |
47 | inline Skipper const& | |
48 | get_skipper(unused_skipper<Skipper> const& u) | |
49 | { | |
50 | return u.skipper; | |
51 | } | |
52 | ||
53 | // If no surrounding lexeme[] directive was specified we keep what we got. | |
54 | template <typename Skipper> | |
55 | inline Skipper const& | |
56 | get_skipper(Skipper const& u) | |
57 | { | |
58 | return u; | |
59 | } | |
60 | ||
61 | }}}} | |
62 | ||
63 | #endif |