1 /*============================================================================= 2 Copyright (c) 2009 Hartmut Kaiser 3 Copyright (c) 2014 Joel de Guzman 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_X3_BOOL_POLICIES_SEP_29_2009_0710AM) 9 #define BOOST_SPIRIT_X3_BOOL_POLICIES_SEP_29_2009_0710AM 10 11 #include <boost/spirit/home/x3/string/detail/string_parse.hpp> 12 #include <boost/spirit/home/x3/support/traits/move_to.hpp> 13 14 namespace boost { namespace spirit { namespace x3 15 { 16 /////////////////////////////////////////////////////////////////////////// 17 // Default boolean policies 18 /////////////////////////////////////////////////////////////////////////// 19 template <typename T = bool> 20 struct bool_policies 21 { 22 template <typename Iterator, typename Attribute, typename CaseCompare> 23 static bool parse_trueboost::spirit::x3::bool_policies24 parse_true(Iterator& first, Iterator const& last, Attribute& attr_, CaseCompare const& case_compare) 25 { 26 if (detail::string_parse("true", first, last, unused, case_compare)) 27 { 28 traits::move_to(T(true), attr_); // result is true 29 return true; 30 } 31 return false; 32 } 33 34 template <typename Iterator, typename Attribute, typename CaseCompare> 35 static bool parse_falseboost::spirit::x3::bool_policies36 parse_false(Iterator& first, Iterator const& last, Attribute& attr_, CaseCompare const& case_compare) 37 { 38 if (detail::string_parse("false", first, last, unused, case_compare)) 39 { 40 traits::move_to(T(false), attr_); // result is false 41 return true; 42 } 43 return false; 44 } 45 }; 46 }}} 47 48 #endif 49