/*============================================================================= Copyright (c) 2001-2010 Joel de Guzman Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ #if !defined(BOOST_SPIRIT_INT_APR_17_2006_0830AM) #define BOOST_SPIRIT_INT_APR_17_2006_0830AM #if defined(_MSC_VER) #pragma once #endif #include #include #include #include #include #include #include namespace boost { namespace spirit { /////////////////////////////////////////////////////////////////////////// // Enablers /////////////////////////////////////////////////////////////////////////// //[primitive_parsers_enable_short_ template <> struct use_terminal // enables short_ : mpl::true_ {}; //] //[primitive_parsers_enable_int_ template <> struct use_terminal // enables int_ : mpl::true_ {}; //] //[primitive_parsers_enable_long_ template <> struct use_terminal // enables long_ : mpl::true_ {}; //] #ifdef BOOST_HAS_LONG_LONG //[primitive_parsers_enable_long_long_ template <> struct use_terminal // enables long_long : mpl::true_ {}; //] #endif }} namespace boost { namespace spirit { namespace qi { using spirit::short_; using spirit::short__type; using spirit::int_; using spirit::int__type; using spirit::long_; using spirit::long__type; #ifdef BOOST_HAS_LONG_LONG using spirit::long_long; using spirit::long_long_type; #endif /////////////////////////////////////////////////////////////////////////// // This is the actual int parser /////////////////////////////////////////////////////////////////////////// //[primitive_parsers_int template < typename T , unsigned Radix = 10 , unsigned MinDigits = 1 , int MaxDigits = -1> struct int_parser_impl : primitive_parser > { // check template parameter 'Radix' for validity BOOST_SPIRIT_ASSERT_MSG( Radix == 2 || Radix == 8 || Radix == 10 || Radix == 16, not_supported_radix, ()); template struct attribute { typedef T type; }; template bool parse(Iterator& first, Iterator const& last , Context& /*context*/, Skipper const& skipper , Attribute& attr) const { qi::skip_over(first, last, skipper); return extract_int ::call(first, last, attr); } template info what(Context& /*context*/) const { return info("integer"); } }; //] /////////////////////////////////////////////////////////////////////////// // This one is the class that the user can instantiate directly /////////////////////////////////////////////////////////////////////////// template < typename T , unsigned Radix = 10 , unsigned MinDigits = 1 , int MaxDigits = -1> struct int_parser : proto::terminal >::type { }; /////////////////////////////////////////////////////////////////////////// // Parser generators: make_xxx function (objects) /////////////////////////////////////////////////////////////////////////// //[primitive_parsers_make_int template struct make_int { typedef int_parser_impl result_type; result_type operator()(unused_type, unused_type) const { return result_type(); } }; //] //[primitive_parsers_short_ template struct make_primitive : make_int {}; //] //[primitive_parsers_int_ template struct make_primitive : make_int {}; //] //[primitive_parsers_long_ template struct make_primitive : make_int {}; //] #ifdef BOOST_HAS_LONG_LONG //[primitive_parsers_long_long_ template struct make_primitive : make_int {}; //] #endif }}} #endif