]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /*============================================================================= |
2 | Copyright (c) 2001-2011 Hartmut Kaiser | |
3 | Copyright (c) 2011 Bryce Lelbach | |
4 | ||
5 | Distributed under the Boost Software License, Version 1.0. (See accompanying | |
6 | file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
7 | ==============================================================================*/ | |
8 | #if !defined(BOOST_SPIRIT_TEST_QI_BOOL) | |
9 | #define BOOST_SPIRIT_TEST_QI_BOOL | |
10 | ||
7c673cae FG |
11 | #include <boost/spirit/home/x3.hpp> |
12 | #include "test.hpp" | |
13 | ||
14 | /////////////////////////////////////////////////////////////////////////////// | |
15 | struct backwards_bool_policies : boost::spirit::x3::bool_policies<> | |
16 | { | |
17 | // we want to interpret a 'true' spelled backwards as 'false' | |
18 | template <typename Iterator, typename Attribute, typename CaseCompare> | |
19 | static bool | |
20 | parse_false(Iterator& first, Iterator const& last, Attribute& attr, CaseCompare const& case_compare) | |
21 | { | |
22 | namespace spirit = boost::spirit; | |
23 | namespace x3 = boost::spirit::x3; | |
24 | if (x3::detail::string_parse("eurt", first, last, x3::unused, case_compare)) | |
25 | { | |
26 | x3::traits::move_to(false, attr); // result is false | |
27 | return true; | |
28 | } | |
29 | return false; | |
30 | } | |
31 | }; | |
32 | ||
33 | /////////////////////////////////////////////////////////////////////////////// | |
34 | struct test_bool_type | |
35 | { | |
36 | test_bool_type(bool b = false) : b(b) {} // provide conversion | |
37 | bool b; | |
38 | }; | |
39 | ||
40 | #endif |