Chris@102
|
1 /*=============================================================================
|
Chris@102
|
2 Copyright (c) 2009 Hartmut Kaiser
|
Chris@102
|
3 Copyright (c) 2014 Joel de Guzman
|
Chris@102
|
4
|
Chris@102
|
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Chris@102
|
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@102
|
7 ==============================================================================*/
|
Chris@102
|
8 #if !defined(SPIRIT_QI_BOOL_POLICIES_SEP_29_2009_0710AM)
|
Chris@102
|
9 #define SPIRIT_QI_BOOL_POLICIES_SEP_29_2009_0710AM
|
Chris@102
|
10
|
Chris@102
|
11 #if defined(_MSC_VER)
|
Chris@102
|
12 #pragma once
|
Chris@102
|
13 #endif
|
Chris@102
|
14
|
Chris@102
|
15 #include <boost/spirit/home/x3/string/detail/string_parse.hpp>
|
Chris@102
|
16 #include <boost/spirit/home/x3/support/traits/move_to.hpp>
|
Chris@102
|
17
|
Chris@102
|
18 namespace boost { namespace spirit { namespace x3
|
Chris@102
|
19 {
|
Chris@102
|
20 ///////////////////////////////////////////////////////////////////////////
|
Chris@102
|
21 // Default boolean policies
|
Chris@102
|
22 ///////////////////////////////////////////////////////////////////////////
|
Chris@102
|
23 template <typename T = bool>
|
Chris@102
|
24 struct bool_policies
|
Chris@102
|
25 {
|
Chris@102
|
26 template <typename Iterator, typename Attribute>
|
Chris@102
|
27 static bool
|
Chris@102
|
28 parse_true(Iterator& first, Iterator const& last, Attribute& attr_)
|
Chris@102
|
29 {
|
Chris@102
|
30 if (detail::string_parse("true", first, last, unused))
|
Chris@102
|
31 {
|
Chris@102
|
32 traits::move_to(T(true), attr_); // result is true
|
Chris@102
|
33 return true;
|
Chris@102
|
34 }
|
Chris@102
|
35 return false;
|
Chris@102
|
36 }
|
Chris@102
|
37
|
Chris@102
|
38 template <typename Iterator, typename Attribute>
|
Chris@102
|
39 static bool
|
Chris@102
|
40 parse_false(Iterator& first, Iterator const& last, Attribute& attr_)
|
Chris@102
|
41 {
|
Chris@102
|
42 if (detail::string_parse("false", first, last, unused))
|
Chris@102
|
43 {
|
Chris@102
|
44 traits::move_to(T(false), attr_); // result is false
|
Chris@102
|
45 return true;
|
Chris@102
|
46 }
|
Chris@102
|
47 return false;
|
Chris@102
|
48 }
|
Chris@102
|
49 };
|
Chris@102
|
50 }}}
|
Chris@102
|
51
|
Chris@102
|
52 #endif
|