| 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 | #ifdef _MSC_VER |
| 19 | # pragma warning(push) |
| 20 | # pragma warning(disable: 4512) // assignment operator could not be generated. |
| 21 | #endif |
| 22 | template <typename Skipper> |
| 23 | struct unused_skipper : unused_type |
| 24 | { |
| 25 | unused_skipper(Skipper const& skipper_) |
| 26 | : skipper(skipper_) {} |
| 27 | Skipper const& skipper; |
| 28 | }; |
| 29 | #ifdef _MSC_VER |
| 30 | # pragma warning(pop) |
| 31 | #endif |
| 32 | |
| 33 | template <typename Skipper> |
| 34 | struct is_unused_skipper |
| 35 | : mpl::false_ {}; |
| 36 | |
| 37 | template <typename Skipper> |
| 38 | struct is_unused_skipper<unused_skipper<Skipper> > |
| 39 | : mpl::true_ {}; |
| 40 | |
| 41 | template <> |
| 42 | struct is_unused_skipper<unused_type> |
| 43 | : mpl::true_ {}; |
| 44 | |
| 45 | // If a surrounding lexeme[] directive was specified, the current |
| 46 | // skipper is of the type unused_skipper. In this case we |
| 47 | // re-activate the skipper which was active before the skip[] |
| 48 | // directive. |
| 49 | template <typename Skipper> |
| 50 | inline Skipper const& |
| 51 | get_skipper(unused_skipper<Skipper> const& u) |
| 52 | { |
| 53 | return u.skipper; |
| 54 | } |
| 55 | |
| 56 | // If no surrounding lexeme[] directive was specified we keep what we got. |
| 57 | template <typename Skipper> |
| 58 | inline Skipper const& |
| 59 | get_skipper(Skipper const& u) |
| 60 | { |
| 61 | return u; |
| 62 | } |
| 63 | |
| 64 | }}}} |
| 65 | |
| 66 | #endif |
| 67 | |