1 /*=============================================================================
2 Copyright (c) 2009 Chris Hoeppler
3 Copyright (c) 2014 Lee Clagett
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 ==============================================================================*/
9 #if !defined(BOOST_SPIRIT_X3_CONFIX_MAY_30_2014_1819PM)
10 #define BOOST_SPIRIT_X3_CONFIX_MAY_30_2014_1819PM
12 #include <boost/spirit/home/x3/core/parser.hpp>
14 namespace boost { namespace spirit { namespace x3
16 template<typename Prefix, typename Subject, typename Postfix>
17 struct confix_directive :
18 unary_parser<Subject, confix_directive<Prefix, Subject, Postfix>>
21 Subject, confix_directive<Prefix, Subject, Postfix>> base_type;
22 static bool const is_pass_through_unary = true;
23 static bool const handles_container = Subject::handles_container;
25 confix_directive(Prefix const& prefix
26 , Subject const& subject
27 , Postfix const& postfix) :
34 template<typename Iterator, typename Context
35 , typename RContext, typename Attribute>
37 Iterator& first, Iterator const& last
38 , Context& context, RContext& rcontext, Attribute& attr) const
40 Iterator save = first;
42 if (!(prefix.parse(first, last, context, rcontext, unused) &&
43 this->subject.parse(first, last, context, rcontext, attr) &&
44 postfix.parse(first, last, context, rcontext, unused)))
57 template<typename Prefix, typename Postfix>
60 template<typename Subject>
62 Prefix, typename extension::as_parser<Subject>::value_type, Postfix>
63 operator[](Subject const& subject) const
65 return { prefix, as_parser(subject), postfix };
73 template<typename Prefix, typename Postfix>
74 confix_gen<typename extension::as_parser<Prefix>::value_type,
75 typename extension::as_parser<Postfix>::value_type>
76 confix(Prefix const& prefix, Postfix const& postfix)
78 return { as_parser(prefix), as_parser(postfix) };