]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/test/qi/bool.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / spirit / test / qi / bool.hpp
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
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>
18 #include "test.hpp"
19
20 ///////////////////////////////////////////////////////////////////////////////
21 struct backwards_bool_policies : boost::spirit::qi::bool_policies<>
22 {
23 // we want to interpret a 'true' spelled backwards as 'false'
24 template <typename Iterator, typename Attribute>
25 static bool
26 parse_false(Iterator& first, Iterator const& last, Attribute& attr)
27 {
28 namespace spirit = boost::spirit;
29 namespace qi = boost::spirit::qi;
30 if (qi::detail::string_parse("eurt", first, last, qi::unused))
31 {
32 spirit::traits::assign_to(false, attr); // result is false
33 return true;
34 }
35 return false;
36 }
37 };
38
39 ///////////////////////////////////////////////////////////////////////////////
40 struct test_bool_type
41 {
42 test_bool_type(bool b) : b(b) {} // provide conversion
43 bool b;
44 };
45
46 #endif
47