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/spirit/include/qi_match.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_auto.hpp>
21#include <boost/phoenix/core.hpp>
22#include <boost/phoenix/operator.hpp>
23#include <boost/phoenix/statement.hpp>
24
25#include <string>
26#include <sstream>
27#include <vector>
28#include <list>
29
30#include <boost/core/lightweight_test.hpp>
31
32///////////////////////////////////////////////////////////////////////////////
33template <typename Char, typename Expr>
34bool test(Char const *toparse, Expr const& expr)
35{
36 namespace spirit = boost::spirit;
37 BOOST_SPIRIT_ASSERT_MATCH(spirit::qi::domain, Expr);
38
39 std::istringstream istrm(toparse);
40 istrm.unsetf(mask: std::ios::skipws);
41 istrm >> spirit::qi::compile<spirit::qi::domain>(expr);
42 return istrm.good() || istrm.eof();
43}
44
45template <typename Char, typename Expr, typename CopyExpr, typename CopyAttr
46 , typename Skipper, typename Attribute>
47bool test(Char const *toparse,
48 boost::spirit::qi::detail::match_manip<
49 Expr, CopyExpr, CopyAttr, Skipper, Attribute> const& mm)
50{
51 std::istringstream istrm(toparse);
52 istrm.unsetf(mask: std::ios::skipws);
53 istrm >> mm;
54 return istrm.good() || istrm.eof();
55}
56
57///////////////////////////////////////////////////////////////////////////////
58bool is_list_ok(std::list<char> const& l)
59{
60 std::list<char>::const_iterator cit = l.begin();
61 if (cit == l.end() || *cit != 'a')
62 return false;
63 if (++cit == l.end() || *cit != 'b')
64 return false;
65
66 return ++cit != l.end() && *cit == 'c';
67}
68
69#endif
70

source code of boost/libs/spirit/test/qi/match_manip.hpp