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 
11 #include <boost/detail/lightweight_test.hpp>
12 #include <boost/spirit/home/x3.hpp>
13 #include "test.hpp"
14 
15 ///////////////////////////////////////////////////////////////////////////////
16 struct backwards_bool_policies : boost::spirit::x3::bool_policies<>
17 {
18     // we want to interpret a 'true' spelled backwards as 'false'
19     template <typename Iterator, typename Attribute, typename CaseCompare>
20     static bool
parse_falsebackwards_bool_policies21     parse_false(Iterator& first, Iterator const& last, Attribute& attr, CaseCompare const& case_compare)
22     {
23         namespace spirit = boost::spirit;
24         namespace x3 = boost::spirit::x3;
25         if (x3::detail::string_parse("eurt", first, last, x3::unused, case_compare))
26         {
27             x3::traits::move_to(false, attr);   // result is false
28             return true;
29         }
30         return false;
31     }
32 };
33 
34 ///////////////////////////////////////////////////////////////////////////////
35 struct test_bool_type
36 {
test_bool_typetest_bool_type37     test_bool_type(bool b = false) : b(b) {}    // provide conversion
38     bool b;
39 };
40 
41 #endif
42