File indexing completed on 2025-01-19 09:47:43
0001
0002
0003
0004
0005
0006
0007
0008 #if !defined(BOOST_SPIRIT_ATTR_JUL_23_2008_0956AM)
0009 #define BOOST_SPIRIT_ATTR_JUL_23_2008_0956AM
0010
0011 #if defined(_MSC_VER)
0012 #pragma once
0013 #endif
0014
0015 #include <boost/mpl/bool.hpp>
0016 #include <boost/spirit/home/qi/domain.hpp>
0017 #include <boost/spirit/home/qi/parser.hpp>
0018 #include <boost/spirit/home/qi/detail/assign_to.hpp>
0019 #include <boost/spirit/home/qi/meta_compiler.hpp>
0020 #include <boost/spirit/home/support/common_terminals.hpp>
0021 #include <boost/spirit/home/support/handles_container.hpp>
0022 #include <boost/type_traits/add_reference.hpp>
0023 #include <boost/type_traits/add_const.hpp>
0024 #include <boost/type_traits/remove_const.hpp>
0025
0026 namespace boost { namespace spirit
0027 {
0028
0029
0030
0031 template <typename A0>
0032 struct use_terminal<
0033 qi::domain, terminal_ex<tag::attr, fusion::vector1<A0> > >
0034 : mpl::true_ {};
0035
0036 template <>
0037 struct use_lazy_terminal<qi::domain, tag::attr, 1>
0038 : mpl::true_ {};
0039
0040 }}
0041
0042 namespace boost { namespace spirit { namespace qi
0043 {
0044 #ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
0045 using spirit::attr;
0046 #endif
0047 using spirit::attr_type;
0048
0049 template <typename Value>
0050 struct attr_parser : primitive_parser<attr_parser<Value> >
0051 {
0052 template <typename Context, typename Iterator>
0053 struct attribute : remove_const<Value> {};
0054
0055 attr_parser(typename add_reference<Value>::type value)
0056 : value_(value) {}
0057
0058 template <typename Iterator, typename Context
0059 , typename Skipper, typename Attribute>
0060 bool parse(Iterator& , Iterator const&
0061 , Context& , Skipper const&
0062 , Attribute& attr_) const
0063 {
0064 spirit::traits::assign_to(value_, attr_);
0065 return true;
0066 }
0067
0068 template <typename Context>
0069 info what(Context& ) const
0070 {
0071 return info("attr");
0072 }
0073
0074 Value value_;
0075 };
0076
0077
0078
0079
0080 template <typename Modifiers, typename A0>
0081 struct make_primitive<
0082 terminal_ex<tag::attr, fusion::vector1<A0> >
0083 , Modifiers>
0084 {
0085 typedef typename add_const<A0>::type const_value;
0086 typedef attr_parser<const_value> result_type;
0087
0088 template <typename Terminal>
0089 result_type operator()(Terminal const& term, unused_type) const
0090 {
0091 return result_type(fusion::at_c<0>(term.args));
0092 }
0093 };
0094 }}}
0095
0096 namespace boost { namespace spirit { namespace traits
0097 {
0098
0099 template <typename T, typename Attr, typename Context, typename Iterator>
0100 struct handles_container<qi::attr_parser<T>, Attr, Context, Iterator>
0101 : traits::is_container<Attr> {};
0102 }}}
0103
0104 #endif
0105
0106