1/*=============================================================================
2 Copyright (c) 2001-2011 Hartmut Kaiser
3 Copyright (c) 2001-2011 Joel de Guzman
4
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
10
11#if defined(_MSC_VER)
12#pragma once
13#endif
14
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>
19#include <boost/mpl/bool.hpp>
20#include <iosfwd>
21
22///////////////////////////////////////////////////////////////////////////////
23namespace boost { namespace spirit { namespace qi
24{
25 ///////////////////////////////////////////////////////////////////////////
26 template <typename Expr>
27 inline typename detail::match<Expr>::type
28 match(
29 Expr const& expr)
30 {
31 return detail::match<Expr>::call(expr);
32 }
33
34 template <typename Expr, typename Attribute>
35 inline detail::match_manip<
36 Expr, mpl::false_, mpl::false_, unused_type, Attribute
37 >
38 match(
39 Expr const& xpr
40 , Attribute& p)
41 {
42 using qi::detail::match_manip;
43
44 // Report invalid expression error as early as possible.
45 // If you got an error_invalid_expression error message here,
46 // then the expression (expr) is not a valid spirit qi expression.
47 BOOST_SPIRIT_ASSERT_MATCH(qi::domain, Expr);
48 return match_manip<Expr, mpl::false_, mpl::false_, unused_type, Attribute>(
49 xpr, unused, p);
50 }
51
52 ///////////////////////////////////////////////////////////////////////////
53 template <typename Expr, typename Skipper>
54 inline typename detail::phrase_match<Expr, Skipper>::type
55 phrase_match(
56 Expr const& expr
57 , Skipper const& s
58 , BOOST_SCOPED_ENUM(skip_flag) post_skip = skip_flag::postskip)
59 {
60 return detail::phrase_match<Expr, Skipper>::call(expr, s, post_skip);
61 }
62
63 template <typename Expr, typename Skipper, typename Attribute>
64 inline detail::match_manip<
65 Expr, mpl::false_, mpl::false_, Skipper, Attribute
66 >
67 phrase_match(
68 Expr const& xpr
69 , Skipper const& s
70 , BOOST_SCOPED_ENUM(skip_flag) post_skip
71 , Attribute& p)
72 {
73 using qi::detail::match_manip;
74
75 // Report invalid expression error as early as possible.
76 // If you got an error_invalid_expression error message here,
77 // then either the expression (expr) or skipper is not a valid
78 // spirit qi expression.
79 BOOST_SPIRIT_ASSERT_MATCH(qi::domain, Expr);
80 BOOST_SPIRIT_ASSERT_MATCH(qi::domain, Skipper);
81 return match_manip<Expr, mpl::false_, mpl::false_, Skipper, Attribute>(
82 xpr, s, post_skip, p);
83 }
84
85 template <typename Expr, typename Skipper, typename Attribute>
86 inline detail::match_manip<
87 Expr, mpl::false_, mpl::false_, Skipper, Attribute
88 >
89 phrase_match(
90 Expr const& xpr
91 , Skipper const& s
92 , Attribute& p)
93 {
94 using qi::detail::match_manip;
95
96 // Report invalid expression error as early as possible.
97 // If you got an error_invalid_expression error message here,
98 // then either the expression (expr) or skipper is not a valid
99 // spirit qi expression.
100 BOOST_SPIRIT_ASSERT_MATCH(qi::domain, Expr);
101 BOOST_SPIRIT_ASSERT_MATCH(qi::domain, Skipper);
102 return match_manip<Expr, mpl::false_, mpl::false_, Skipper, Attribute>(
103 xpr, s, p);
104 }
105
106 ///////////////////////////////////////////////////////////////////////////
107 template<typename Char, typename Traits, typename Derived>
108 inline std::basic_istream<Char, Traits>&
109 operator>>(std::basic_istream<Char, Traits>& is, parser<Derived> const& p)
110 {
111 typedef spirit::basic_istream_iterator<Char, Traits> input_iterator;
112
113 input_iterator f(is);
114 input_iterator l;
115 if (!p.derived().parse(f, l, unused, unused, unused))
116 {
117 is.setstate(std::basic_istream<Char, Traits>::failbit);
118 }
119 return is;
120 }
121
122}}}
123
124#endif
125
126

source code of boost/libs/spirit/include/boost/spirit/home/qi/stream/match_manip.hpp