1 /*=============================================================================
2 Copyright (c) 2001-2011 Hartmut Kaiser
3 Copyright (c) 2011 Bryce Lelbach
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
11 #include <boost/detail/lightweight_test.hpp>
13 #include <boost/spirit/include/support_argument.hpp>
14 #include <boost/spirit/include/qi_char.hpp>
15 #include <boost/spirit/include/qi_numeric.hpp>
16 #include <boost/spirit/include/qi_directive.hpp>
17 #include <boost/cstdint.hpp>
20 ///////////////////////////////////////////////////////////////////////////////
21 struct backwards_bool_policies : boost::spirit::qi::bool_policies<>
23 // we want to interpret a 'true' spelled backwards as 'false'
24 template <typename Iterator, typename Attribute>
26 parse_false(Iterator& first, Iterator const& last, Attribute& attr)
28 namespace spirit = boost::spirit;
29 namespace qi = boost::spirit::qi;
30 if (qi::detail::string_parse("eurt", first, last, qi::unused))
32 spirit::traits::assign_to(false, attr); // result is false
39 ///////////////////////////////////////////////////////////////////////////////
42 test_bool_type(bool b) : b(b) {} // provide conversion