| 1 | /*============================================================================= |
| 2 | Copyright (c) 2001-2014 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(BOOST_SPIRIT_X3_CHAR_PARSER_APR_16_2006_0906AM) |
| 8 | #define BOOST_SPIRIT_X3_CHAR_PARSER_APR_16_2006_0906AM |
| 9 | |
| 10 | #include <boost/spirit/home/x3/core/parser.hpp> |
| 11 | #include <boost/spirit/home/x3/core/skip_over.hpp> |
| 12 | #include <boost/spirit/home/x3/support/traits/move_to.hpp> |
| 13 | #include <boost/spirit/home/x3/support/no_case.hpp> |
| 14 | |
| 15 | namespace boost { namespace spirit { namespace x3 |
| 16 | { |
| 17 | /////////////////////////////////////////////////////////////////////////// |
| 18 | // The base char_parser |
| 19 | /////////////////////////////////////////////////////////////////////////// |
| 20 | template <typename Derived> |
| 21 | struct char_parser : parser<Derived> |
| 22 | { |
| 23 | template <typename Iterator, typename Context, typename Attribute> |
| 24 | bool parse( |
| 25 | Iterator& first, Iterator const& last |
| 26 | , Context const& context, unused_type, Attribute& attr) const |
| 27 | { |
| 28 | x3::skip_over(first, last, context); |
| 29 | if (first != last && this->derived().test(*first, context)) |
| 30 | { |
| 31 | x3::traits::move_to(*first, attr); |
| 32 | ++first; |
| 33 | return true; |
| 34 | } |
| 35 | return false; |
| 36 | } |
| 37 | }; |
| 38 | }}} |
| 39 | |
| 40 | #endif |
| 41 | |