1 /*=============================================================================
2     Copyright (c) 2001-2010 Hartmut Kaiser
3     Copyright (c) 2001-2010 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_TEST_MATCH_MANIP_HPP)
9 #define BOOST_SPIRIT_TEST_MATCH_MANIP_HPP
10 
11 #include <boost/config/warning_disable.hpp>
12 
13 #include <boost/spirit/include/support_argument.hpp>
14 #include <boost/spirit/include/qi_action.hpp>
15 #include <boost/spirit/include/qi_numeric.hpp>
16 #include <boost/spirit/include/qi_operator.hpp>
17 #include <boost/spirit/include/qi_char.hpp>
18 #include <boost/spirit/include/qi_operator.hpp>
19 #include <boost/spirit/include/qi_stream.hpp>
20 #include <boost/spirit/include/qi_match.hpp>
21 #include <boost/spirit/include/qi_match_auto.hpp>
22 #include <boost/spirit/include/phoenix_core.hpp>
23 #include <boost/spirit/include/phoenix_operator.hpp>
24 #include <boost/spirit/include/phoenix_statement.hpp>
25 
26 #include <string>
27 #include <sstream>
28 #include <vector>
29 #include <list>
30 
31 #include <boost/detail/lightweight_test.hpp>
32 
33 ///////////////////////////////////////////////////////////////////////////////
34 template <typename Char, typename Expr>
test(Char const * toparse,Expr const & expr)35 bool test(Char const *toparse, Expr const& expr)
36 {
37     namespace spirit = boost::spirit;
38     BOOST_SPIRIT_ASSERT_MATCH(spirit::qi::domain, Expr);
39 
40     std::istringstream istrm(toparse);
41     istrm.unsetf(std::ios::skipws);
42     istrm >> spirit::qi::compile<spirit::qi::domain>(expr);
43     return istrm.good() || istrm.eof();
44 }
45 
46 template <typename Char, typename Expr, typename CopyExpr, typename CopyAttr
47   , typename Skipper, typename Attribute>
test(Char const * toparse,boost::spirit::qi::detail::match_manip<Expr,CopyExpr,CopyAttr,Skipper,Attribute> const & mm)48 bool test(Char const *toparse,
49     boost::spirit::qi::detail::match_manip<
50         Expr, CopyExpr, CopyAttr, Skipper, Attribute> const& mm)
51 {
52     std::istringstream istrm(toparse);
53     istrm.unsetf(std::ios::skipws);
54     istrm >> mm;
55     return istrm.good() || istrm.eof();
56 }
57 
58 ///////////////////////////////////////////////////////////////////////////////
is_list_ok(std::list<char> const & l)59 bool is_list_ok(std::list<char> const& l)
60 {
61     std::list<char>::const_iterator cit = l.begin();
62     if (cit == l.end() || *cit != 'a')
63         return false;
64     if (++cit == l.end() || *cit != 'b')
65         return false;
66 
67     return ++cit != l.end() && *cit == 'c';
68 }
69 
70 #endif
71