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_INT_APR_17_2006_0830AM)
0008 #define BOOST_SPIRIT_X3_INT_APR_17_2006_0830AM
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/support/numeric_utils/extract_int.hpp>
0013 #include <cstdint>
0014 
0015 namespace boost { namespace spirit { namespace x3
0016 {
0017     ///////////////////////////////////////////////////////////////////////////
0018     template <
0019         typename T
0020       , unsigned Radix = 10
0021       , unsigned MinDigits = 1
0022       , int MaxDigits = -1>
0023     struct int_parser : parser<int_parser<T, Radix, MinDigits, MaxDigits>>
0024     {
0025         // check template parameter 'Radix' for validity
0026         static_assert(
0027             (Radix == 2 || Radix == 8 || Radix == 10 || Radix == 16),
0028             "Error Unsupported Radix");
0029 
0030         typedef T attribute_type;
0031         static bool const has_attribute = true;
0032 
0033         template <typename Iterator, typename Context, typename Attribute>
0034         bool parse(Iterator& first, Iterator const& last
0035           , Context const& context, unused_type, Attribute& attr) const
0036         {
0037             typedef extract_int<T, Radix, MinDigits, MaxDigits> extract;
0038             x3::skip_over(first, last, context);
0039             return extract::call(first, last, attr);
0040         }
0041     };
0042 
0043 #define BOOST_SPIRIT_X3_INT_PARSER(int_type, name)                              \
0044     typedef int_parser<int_type> name##type;                                    \
0045     constexpr name##type name = {};                                             \
0046     /***/
0047 
0048     BOOST_SPIRIT_X3_INT_PARSER(long, long_)
0049     BOOST_SPIRIT_X3_INT_PARSER(short, short_)
0050     BOOST_SPIRIT_X3_INT_PARSER(int, int_)
0051     BOOST_SPIRIT_X3_INT_PARSER(long long, long_long)
0052 
0053     BOOST_SPIRIT_X3_INT_PARSER(int8_t, int8)
0054     BOOST_SPIRIT_X3_INT_PARSER(int16_t, int16)
0055     BOOST_SPIRIT_X3_INT_PARSER(int32_t, int32)
0056     BOOST_SPIRIT_X3_INT_PARSER(int64_t, int64)
0057 
0058 #undef BOOST_SPIRIT_X3_INT_PARSER
0059 
0060 }}}
0061 
0062 #endif