1 /*=============================================================================
2 Copyright (c) 2001-2011 Hartmut Kaiser
3 Copyright (c) 2001-2011 Joel de Guzman
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 ==============================================================================*/
8 #if !defined(BOOST_SPIRIT_MATCH_MANIP_MAY_05_2007_1202PM)
9 #define BOOST_SPIRIT_MATCH_MANIP_MAY_05_2007_1202PM
15 #include <boost/spirit/home/qi/parse.hpp>
16 #include <boost/spirit/home/qi/parser.hpp>
17 #include <boost/spirit/home/support/unused.hpp>
18 #include <boost/spirit/home/qi/stream/detail/match_manip.hpp>
20 ///////////////////////////////////////////////////////////////////////////////
21 namespace boost { namespace spirit { namespace qi
23 ///////////////////////////////////////////////////////////////////////////
24 template <typename Expr>
25 inline typename detail::match<Expr>::type
29 return detail::match<Expr>::call(expr);
32 template <typename Expr, typename Attribute>
33 inline detail::match_manip<
34 Expr, mpl::false_, mpl::false_, unused_type, Attribute
40 using qi::detail::match_manip;
42 // Report invalid expression error as early as possible.
43 // If you got an error_invalid_expression error message here,
44 // then the expression (expr) is not a valid spirit qi expression.
45 BOOST_SPIRIT_ASSERT_MATCH(qi::domain, Expr);
46 return match_manip<Expr, mpl::false_, mpl::false_, unused_type, Attribute>(
50 ///////////////////////////////////////////////////////////////////////////
51 template <typename Expr, typename Skipper>
52 inline typename detail::phrase_match<Expr, Skipper>::type
56 , BOOST_SCOPED_ENUM(skip_flag) post_skip = skip_flag::postskip)
58 return detail::phrase_match<Expr, Skipper>::call(expr, s, post_skip);
61 template <typename Expr, typename Skipper, typename Attribute>
62 inline detail::match_manip<
63 Expr, mpl::false_, mpl::false_, Skipper, Attribute
68 , BOOST_SCOPED_ENUM(skip_flag) post_skip
71 using qi::detail::match_manip;
73 // Report invalid expression error as early as possible.
74 // If you got an error_invalid_expression error message here,
75 // then either the expression (expr) or skipper is not a valid
76 // spirit qi expression.
77 BOOST_SPIRIT_ASSERT_MATCH(qi::domain, Expr);
78 BOOST_SPIRIT_ASSERT_MATCH(qi::domain, Skipper);
79 return match_manip<Expr, mpl::false_, mpl::false_, Skipper, Attribute>(
80 xpr, s, post_skip, p);
83 template <typename Expr, typename Skipper, typename Attribute>
84 inline detail::match_manip<
85 Expr, mpl::false_, mpl::false_, Skipper, Attribute
92 using qi::detail::match_manip;
94 // Report invalid expression error as early as possible.
95 // If you got an error_invalid_expression error message here,
96 // then either the expression (expr) or skipper is not a valid
97 // spirit qi expression.
98 BOOST_SPIRIT_ASSERT_MATCH(qi::domain, Expr);
99 BOOST_SPIRIT_ASSERT_MATCH(qi::domain, Skipper);
100 return match_manip<Expr, mpl::false_, mpl::false_, Skipper, Attribute>(
104 ///////////////////////////////////////////////////////////////////////////
105 template<typename Char, typename Traits, typename Derived>
106 inline std::basic_istream<Char, Traits>&
107 operator>>(std::basic_istream<Char, Traits>& is, parser<Derived> const& p)
109 typedef spirit::basic_istream_iterator<Char, Traits> input_iterator;
111 input_iterator f(is);
113 if (!p.derived().parse(f, l, unused, unused, unused))
115 is.setstate(std::ios_base::failbit);