PageRenderTime 22ms CodeModel.GetById 16ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/boost/spirit/home/qi/numeric/bool_policies.hpp

http://hadesmem.googlecode.com/
C++ Header | 81 lines | 63 code | 8 blank | 10 comment | 4 complexity | 8919789c6b41b24ec2150c29ebb52e8a MD5 | raw file
 1/*=============================================================================
 2    Copyright (c) 2001-2011 Hartmut Kaiser
 3
 4    Distributed under the Boost Software License, Version 1.0. (See accompanying
 5    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 6==============================================================================*/
 7#if !defined(SPIRIT_QI_BOOL_POLICIES_SEP_29_2009_0710AM)
 8#define SPIRIT_QI_BOOL_POLICIES_SEP_29_2009_0710AM
 9
10#if defined(_MSC_VER)
11#pragma once
12#endif
13
14#include <boost/spirit/home/qi/detail/string_parse.hpp>
15#include <boost/spirit/home/qi/detail/assign_to.hpp>
16
17namespace boost { namespace spirit { namespace qi
18{
19    ///////////////////////////////////////////////////////////////////////////
20    //  Default boolean policies
21    ///////////////////////////////////////////////////////////////////////////
22    template <typename T = bool>
23    struct bool_policies
24    {
25        template <typename Iterator, typename Attribute>
26        static bool
27        parse_true(Iterator& first, Iterator const& last, Attribute& attr)
28        {
29            if (detail::string_parse("true", first, last, unused))
30            {
31                spirit::traits::assign_to(T(true), attr);    // result is true
32                return true;
33            }
34            return false;
35        }
36
37        template <typename Iterator, typename Attribute>
38        static bool
39        parse_false(Iterator& first, Iterator const& last, Attribute& attr)
40        {
41            if (detail::string_parse("false", first, last, unused))
42            {
43                spirit::traits::assign_to(T(false), attr);   // result is false
44                return true;
45            }
46            return false;
47        }
48    };
49
50    ///////////////////////////////////////////////////////////////////////////
51    template <typename T = bool>
52    struct no_case_bool_policies
53    {
54        template <typename Iterator, typename Attribute>
55        static bool
56        parse_true(Iterator& first, Iterator const& last, Attribute& attr)
57        {
58            if (detail::string_parse("true", "TRUE", first, last, unused))
59            {
60                spirit::traits::assign_to(T(true), attr);    // result is true
61                return true;
62            }
63            return false;
64        }
65
66        template <typename Iterator, typename Attribute>
67        static bool
68        parse_false(Iterator& first, Iterator const& last, Attribute& attr)
69        {
70            if (detail::string_parse("false", "FALSE", first, last, unused))
71            {
72                spirit::traits::assign_to(T(false), attr);   // result is false
73                return true;
74            }
75            return false;
76        }
77    };
78
79}}}
80
81#endif