| The Gaudi Framework v32r1 (f65d50dc)

iter_pos.hpp
Go to the documentation of this file.
1 // Copyright (c) 2001-2010 Hartmut Kaiser
2 //
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)
5
6 #if !defined( BOOST_SPIRIT_REPOSITORY_QI_ITER_POS_NOV_20_2009_1245PM )
7 # define BOOST_SPIRIT_REPOSITORY_QI_ITER_POS_NOV_20_2009_1245PM
8
9 # include <boost/spirit/include/qi_parse.hpp>
10
12 // definition the place holder
13 namespace boost {
14 namespace spirit {
15 namespace repository {
16 namespace qi {
17 BOOST_SPIRIT_TERMINAL( iter_pos )
18 }
19 } // namespace repository
20 } // namespace spirit
21 } // namespace boost
22
24 // implementation the enabler
25 namespace boost {
26 namespace spirit {
27 // We want custom_parser::iter_pos to be usable as a terminal only,
28 // and only for parser expressions (qi::domain).
29 template <>
30 struct use_terminal<qi::domain, repository::qi::tag::iter_pos> : mpl::true_ {};
31 } // namespace spirit
32 } // namespace boost
33
35 // implementation of the parser
36 namespace boost {
37 namespace spirit {
38 namespace repository {
39 namespace qi {
40 struct iter_pos_parser : boost::spirit::qi::primitive_parser<iter_pos_parser> {
41 // Define the attribute type exposed by this parser component
42 template <typename Context, typename Iterator>
43 struct attribute {
44 typedef Iterator type;
45 };
46
47 // This function is called during the actual parsing process
48 template <typename Iterator, typename Context, typename Skipper, typename Attribute>
49 bool parse( Iterator& first, Iterator const& last, Context&, Skipper const& skipper, Attribute& attr ) const {
50 boost::spirit::qi::skip_over( first, last, skipper );
51 boost::spirit::traits::assign_to( first, attr );
52 return true;
53 }
54
55 // This function is called during error handling to create
56 // a human readable string for the error context.
57 template <typename Context>
58 boost::spirit::info what( Context& ) const {
59 return boost::spirit::info( "iter_pos" );
60 }
61 };
62 } // namespace qi
63 } // namespace repository
64 } // namespace spirit
65 } // namespace boost
66
68 // instantiation of the parser
69 namespace boost {
70 namespace spirit {
71 namespace qi {
72 // This is the factory function object invoked in order to create
73 // an instance of our iter_pos_parser.
74 template <typename Modifiers>
75 struct make_primitive<repository::qi::tag::iter_pos, Modifiers> {
76 typedef repository::qi::iter_pos_parser result_type;
77
78 result_type operator()( unused_type, unused_type ) const { return result_type(); }
79 };
80 } // namespace qi
81 } // namespace spirit
82 } // namespace boost
83
84 #endif
boost
Definition: iter_pos.hpp:13
Gaudi::Parsers::Skipper
SkipperGrammar< IteratorT > Skipper
Definition: Factory.h:26
boost::spirit::repository::qi::iter_pos_parser::attribute
Definition: iter_pos.hpp:43
boost::spirit::repository::qi::iter_pos_parser::parse
bool parse(Iterator &first, Iterator const &last, Context &, Skipper const &skipper, Attribute &attr) const
Definition: iter_pos.hpp:49
boost::spirit::repository::qi::iter_pos_parser::what
boost::spirit::info what(Context &) const
Definition: iter_pos.hpp:58
boost::spirit::qi::make_primitive< repository::qi::tag::iter_pos, Modifiers >::result_type
repository::qi::iter_pos_parser result_type
Definition: iter_pos.hpp:76
boost::spirit::qi::make_primitive< repository::qi::tag::iter_pos, Modifiers >::operator()
result_type operator()(unused_type, unused_type) const
Definition: iter_pos.hpp:78
boost::spirit::repository::qi::iter_pos_parser::attribute::type
Iterator type
Definition: iter_pos.hpp:44
Iterator
boost::spirit::classic::position_iterator2< ForwardIterator > Iterator
Definition: Iterator.h:18
boost::spirit::repository::qi::iter_pos_parser
Definition: iter_pos.hpp:40