File indexing completed on 2025-01-19 09:47:44
0001
0002
0003
0004
0005
0006
0007 #ifndef BOOST_SPIRIT_QI_DIRECTIVE_RAW_HPP
0008 #define BOOST_SPIRIT_QI_DIRECTIVE_RAW_HPP
0009
0010 #if defined(_MSC_VER)
0011 #pragma once
0012 #endif
0013
0014 #include <boost/spirit/home/qi/meta_compiler.hpp>
0015 #include <boost/spirit/home/qi/skip_over.hpp>
0016 #include <boost/spirit/home/qi/parser.hpp>
0017 #include <boost/spirit/home/qi/detail/assign_to.hpp>
0018 #include <boost/spirit/home/support/unused.hpp>
0019 #include <boost/spirit/home/support/info.hpp>
0020 #include <boost/spirit/home/support/common_terminals.hpp>
0021 #include <boost/spirit/home/support/unused.hpp>
0022 #include <boost/spirit/home/support/has_semantic_action.hpp>
0023 #include <boost/spirit/home/support/handles_container.hpp>
0024 #include <boost/range/iterator_range_core.hpp> // TODO: use forward include
0025
0026 namespace boost { namespace spirit
0027 {
0028
0029
0030
0031 template <>
0032 struct use_directive<qi::domain, tag::raw>
0033 : mpl::true_ {};
0034 }}
0035
0036 namespace boost { namespace spirit { namespace qi
0037 {
0038 #ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
0039 using spirit::raw;
0040 #endif
0041 using spirit::raw_type;
0042
0043 template <typename Subject>
0044 struct raw_directive : unary_parser<raw_directive<Subject> >
0045 {
0046 typedef Subject subject_type;
0047 raw_directive(Subject const& subject_)
0048 : subject(subject_) {}
0049
0050 template <typename Context, typename Iterator>
0051 struct attribute
0052 {
0053 typedef iterator_range<Iterator> type;
0054 };
0055
0056 template <typename Iterator, typename Context
0057 , typename Skipper, typename Attribute>
0058 bool parse(Iterator& first, Iterator const& last
0059 , Context& context, Skipper const& skipper, Attribute& attr_) const
0060 {
0061 qi::skip_over(first, last, skipper);
0062 Iterator i = first;
0063 if (subject.parse(i, last, context, skipper, unused))
0064 {
0065 spirit::traits::assign_to(first, i, attr_);
0066 first = i;
0067 return true;
0068 }
0069 return false;
0070 }
0071
0072 template <typename Context>
0073 info what(Context& context) const
0074 {
0075 return info("raw", subject.what(context));
0076
0077 }
0078
0079 Subject subject;
0080 };
0081
0082
0083
0084
0085 template <typename Subject, typename Modifiers>
0086 struct make_directive<tag::raw, Subject, Modifiers>
0087 {
0088 typedef raw_directive<Subject> result_type;
0089 result_type operator()(unused_type, Subject const& subject, unused_type) const
0090 {
0091 return result_type(subject);
0092 }
0093 };
0094 }}}
0095
0096 namespace boost { namespace spirit { namespace traits
0097 {
0098
0099 template <typename Subject>
0100 struct has_semantic_action<qi::raw_directive<Subject> >
0101 : unary_has_semantic_action<Subject> {};
0102
0103
0104 template <typename Subject, typename Attribute, typename Context
0105 , typename Iterator>
0106 struct handles_container<qi::raw_directive<Subject>, Attribute
0107 , Context, Iterator>
0108 : mpl::true_ {};
0109 }}}
0110
0111 #endif