Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 10:02:36

0001 /*=============================================================================
0002     Copyright (c) 2001-2014 Joel de Guzman
0003 
0004     Distributed under the Boost Software License, Version 1.0. (See accompanying
0005     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 ==============================================================================*/
0007 #if !defined(BOOST_SPIRIT_X3_REAL_APRIL_18_2006_0850AM)
0008 #define BOOST_SPIRIT_X3_REAL_APRIL_18_2006_0850AM
0009 
0010 #include <boost/spirit/home/x3/core/parser.hpp>
0011 #include <boost/spirit/home/x3/core/skip_over.hpp>
0012 #include <boost/spirit/home/x3/numeric/real_policies.hpp>
0013 #include <boost/spirit/home/x3/support/numeric_utils/extract_real.hpp>
0014 
0015 namespace boost { namespace spirit { namespace x3
0016 {
0017     template <typename T, typename RealPolicies = real_policies<T> >
0018     struct real_parser : parser<real_parser<T, RealPolicies> >
0019     {
0020         typedef T attribute_type;
0021         static bool const has_attribute = true;
0022 
0023         constexpr real_parser()
0024             : policies() {}
0025 
0026         constexpr real_parser(RealPolicies const& policies)
0027             : policies(policies) {}
0028 
0029         template <typename Iterator, typename Context>
0030         bool parse(Iterator& first, Iterator const& last
0031           , Context const& context, unused_type, T& attr_) const
0032         {
0033             x3::skip_over(first, last, context);
0034             return extract_real<T, RealPolicies>::parse(first, last, attr_, policies);
0035         }
0036 
0037         template <typename Iterator, typename Context, typename Attribute>
0038         bool parse(Iterator& first, Iterator const& last
0039           , Context const& context, unused_type, Attribute& attr_param) const
0040         {
0041             // this case is called when Attribute is not T
0042             T attr_;
0043             if (parse(first, last, context, unused, attr_))
0044             {
0045                 traits::move_to(attr_, attr_param);
0046                 return true;
0047             }
0048             return false;
0049         }
0050 
0051         RealPolicies policies;
0052     };
0053 
0054     typedef real_parser<float> float_type;
0055     constexpr float_type float_ = {};
0056 
0057     typedef real_parser<double> double_type;
0058     constexpr double_type double_ = {};
0059 
0060     typedef real_parser<long double> long_double_type;
0061     constexpr long_double_type long_double = {};
0062 
0063 }}}
0064 
0065 #endif