• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*=============================================================================
2     Copyright (c) 2001-2014 Joel de Guzman
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 #if !defined(BOOST_SPIRIT_X3_PROXY_FEBRUARY_1_2013_0211PM)
8 #define BOOST_SPIRIT_X3_PROXY_FEBRUARY_1_2013_0211PM
9 
10 #include <boost/spirit/home/x3/core/parser.hpp>
11 #include <boost/spirit/home/x3/core/detail/parse_into_container.hpp>
12 #include <boost/spirit/home/x3/support/traits/attribute_category.hpp>
13 
14 namespace boost { namespace spirit { namespace x3
15 {
16     template <typename Subject, typename Derived>
17     struct proxy : unary_parser<Subject, Derived>
18     {
19         static bool const is_pass_through_unary = true;
20 
proxyboost::spirit::x3::proxy21         constexpr proxy(Subject const& subject)
22           : unary_parser<Subject, Derived>(subject) {}
23 
24         // Overload this when appropriate. The proxy parser will pick up
25         // the most derived overload.
26         template <typename Iterator, typename Context
27           , typename RuleContext, typename Attribute, typename Category>
parse_subjectboost::spirit::x3::proxy28         bool parse_subject(Iterator& first, Iterator const& last
29           , Context const& context, RuleContext& rcontext, Attribute& attr, Category) const
30         {
31             this->subject.parse(first, last, context, rcontext, attr);
32             return true;
33         }
34 
35         // Main entry point.
36         template <typename Iterator, typename Context
37           , typename RuleContext, typename Attribute>
parseboost::spirit::x3::proxy38         bool parse(Iterator& first, Iterator const& last
39           , Context const& context, RuleContext& rcontext, Attribute& attr) const
40         {
41             return this->derived().parse_subject(first, last, context, rcontext, attr
42                 , typename traits::attribute_category<Attribute>::type());
43         }
44     };
45 
46 }}}
47 
48 #endif
49