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(BOOST_SPIRIT_DETAIL_PARSE_AUTO_DEC_02_2009_0426PM) 8 #define BOOST_SPIRIT_DETAIL_PARSE_AUTO_DEC_02_2009_0426PM 9 10 #if defined(_MSC_VER) 11 #pragma once 12 #endif 13 14 #include <boost/spirit/home/qi/parse.hpp> 15 #include <boost/spirit/home/qi/auto/create_parser.hpp> 16 #include <boost/utility/enable_if.hpp> 17 #include <boost/mpl/not.hpp> 18 #include <boost/mpl/and.hpp> 19 20 namespace boost { namespace spirit { namespace qi { namespace detail 21 { 22 /////////////////////////////////////////////////////////////////////////// 23 template <typename Expr> 24 struct parse_impl<Expr 25 , typename enable_if< 26 mpl::and_< 27 traits::meta_create_exists<qi::domain, Expr> 28 , mpl::not_<traits::matches<qi::domain, Expr> > > 29 >::type> 30 { 31 template <typename Iterator> callboost::spirit::qi::detail::parse_impl32 static bool call(Iterator& first, Iterator last, Expr& expr) 33 { 34 return qi::parse(first, last, create_parser<Expr>(), expr); 35 } 36 37 template <typename Iterator> callboost::spirit::qi::detail::parse_impl38 static bool call(Iterator& first, Iterator last, Expr const& expr) 39 { 40 return qi::parse(first, last, create_parser<Expr>() 41 , const_cast<Expr&>(expr)); 42 } 43 }; 44 45 /////////////////////////////////////////////////////////////////////////// 46 template <typename Expr> 47 struct phrase_parse_impl<Expr 48 , typename enable_if< 49 mpl::and_< 50 traits::meta_create_exists<qi::domain, Expr> 51 , mpl::not_<traits::matches<qi::domain, Expr> > > 52 >::type> 53 { 54 template <typename Iterator, typename Skipper> callboost::spirit::qi::detail::phrase_parse_impl55 static bool call(Iterator& first, Iterator last, Expr& expr 56 , Skipper const& skipper, BOOST_SCOPED_ENUM(skip_flag) post_skip) 57 { 58 return qi::phrase_parse(first, last, create_parser<Expr>() 59 , skipper, post_skip, expr); 60 } 61 62 template <typename Iterator, typename Skipper> callboost::spirit::qi::detail::phrase_parse_impl63 static bool call(Iterator& first, Iterator last, Expr const& expr 64 , Skipper const& skipper, BOOST_SCOPED_ENUM(skip_flag) post_skip) 65 { 66 return qi::phrase_parse(first, last, create_parser<Expr>() 67 , skipper, post_skip, const_cast<Expr&>(expr)); 68 } 69 }; 70 }}}} 71 72 namespace boost { namespace spirit { namespace qi 73 { 74 /////////////////////////////////////////////////////////////////////////// 75 template <typename Iterator, typename Expr> 76 inline bool parse(Iterator & first,Iterator last,Expr & expr)77 parse( 78 Iterator& first 79 , Iterator last 80 , Expr& expr) 81 { 82 // Make sure the iterator is at least a forward_iterator. If you got a 83 // compilation error here, then you are using an input_iterator while 84 // calling this function, you need to supply at least a 85 // forward_iterator instead. 86 BOOST_CONCEPT_ASSERT((ForwardIterator<Iterator>)); 87 88 return detail::parse_impl<Expr>::call(first, last, expr); 89 } 90 91 /////////////////////////////////////////////////////////////////////////// 92 template <typename Iterator, typename Expr, typename Skipper> 93 inline bool phrase_parse(Iterator & first,Iterator last,Expr & expr,Skipper const & skipper,BOOST_SCOPED_ENUM (skip_flag)post_skip=skip_flag::postskip)94 phrase_parse( 95 Iterator& first 96 , Iterator last 97 , Expr& expr 98 , Skipper const& skipper 99 , BOOST_SCOPED_ENUM(skip_flag) post_skip = skip_flag::postskip) 100 { 101 // Make sure the iterator is at least a forward_iterator. If you got a 102 // compilation error here, then you are using an input_iterator while 103 // calling this function, you need to supply at least a 104 // forward_iterator instead. 105 BOOST_CONCEPT_ASSERT((ForwardIterator<Iterator>)); 106 107 return detail::phrase_parse_impl<Expr>::call( 108 first, last, expr, skipper, post_skip); 109 } 110 }}} 111 112 #endif 113 114