]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/repository/example/qi/distinct.cpp
1 // Copyright (c) 2001-2010 Hartmut Kaiser
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 // The purpose of this example is to demonstrate different use cases for the
13 //[qi_distinct_includes
14 #include <boost/spirit/include/qi.hpp>
15 #include <boost/spirit/repository/include/qi_distinct.hpp>
18 //[qi_distinct_namespace
19 using namespace boost::spirit
;
20 using namespace boost::spirit::ascii
;
21 using boost::spirit::repository::distinct
;
26 //[qi_distinct_description_ident
28 std::string
str("description ident");
29 std::string::iterator
first(str
.begin());
30 bool r
= qi::phrase_parse(first
, str
.end()
31 , distinct(alnum
| '_')["description"] >> -lit("--") >> +(alnum
| '_')
33 BOOST_ASSERT(r
&& first
== str
.end());
37 //[qi_distinct_description__ident
39 std::string
str("description--ident");
40 std::string::iterator
first(str
.begin());
41 bool r
= qi::phrase_parse(first
, str
.end()
42 , distinct(alnum
| '_')["description"] >> -lit("--") >> +(alnum
| '_')
44 BOOST_ASSERT(r
&& first
== str
.end());
48 //[qi_distinct_description_ident_error
50 std::string
str("description-ident");
51 std::string::iterator
first(str
.begin());
52 bool r
= qi::phrase_parse(first
, str
.end()
53 , distinct(alnum
| '_')["description"] >> -lit("--") >> +(alnum
| '_')
55 BOOST_ASSERT(!r
&& first
== str
.begin());