• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //   Copyright (c) 2012 Louis Dionne
2 //   Copyright (c) 2001-2012 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 #include <boost/config/warning_disable.hpp>
8 #include <boost/detail/lightweight_test.hpp>
9 
10 #include <boost/spirit/include/qi.hpp>
11 
12 #include <iostream>
13 #include <string>
14 
15 struct MyInt
16 {
17     int i_;
18 
19     template <typename Istream>
operator >>(Istream & is,MyInt & self)20     friend Istream operator>>(Istream& is, MyInt& self)
21     {
22         is >> self.i_;
23         return is;
24     }
25 };
26 
main()27 int main()
28 {
29     using namespace boost::spirit::qi;
30     typedef std::string::const_iterator Iterator;
31 
32     std::string input = "1";
33     Iterator first(input.begin()), last(input.end());
34     rule<Iterator, int()> my_int = stream_parser<char, MyInt>();
35     BOOST_TEST(parse(first, last, my_int));
36     BOOST_TEST(first == last);
37 
38     return boost::report_errors();
39 }
40 
41