Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/spirit/home/qi/reference.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*=============================================================================
0002     Copyright (c) 2001-2011 Joel de Guzman
0003 
0004     Distributed under the Boost Software License, Version 1.0. (See accompanying
0005     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 ==============================================================================*/
0007 #if !defined(BOOST_SPIRIT_REFERENCE_OCTOBER_31_2008_1218AM)
0008 #define BOOST_SPIRIT_REFERENCE_OCTOBER_31_2008_1218AM
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/parser.hpp>
0016 #include <boost/spirit/home/support/info.hpp>
0017 #include <boost/spirit/home/support/handles_container.hpp>
0018 #include <boost/type_traits/remove_const.hpp>
0019 #include <boost/ref.hpp>
0020 
0021 namespace boost { namespace spirit { namespace qi
0022 {
0023     ///////////////////////////////////////////////////////////////////////////
0024     // reference is a parser that references another parser (its Subject)
0025     ///////////////////////////////////////////////////////////////////////////
0026     template <typename Subject>
0027     struct reference : parser<reference<Subject> >
0028     {
0029         typedef Subject subject_type;
0030 
0031         reference(Subject& subject)
0032           : ref(subject) {}
0033 
0034         template <typename Context, typename Iterator>
0035         struct attribute : Subject::template attribute<Context, Iterator> {};
0036 
0037         template <typename Iterator, typename Context
0038           , typename Skipper, typename Attribute>
0039         bool parse(Iterator& first, Iterator const& last
0040           , Context& context, Skipper const& skipper
0041           , Attribute& attr_) const
0042         {
0043             return ref.get().parse(first, last, context, skipper, attr_);
0044         }
0045 
0046         template <typename Context>
0047         info what(Context& context) const
0048         {
0049             // the reference is transparent (does not add any info)
0050             return ref.get().what(context);
0051         }
0052 
0053         boost::reference_wrapper<Subject> ref;
0054     };
0055 }}}
0056 
0057 namespace boost { namespace spirit { namespace traits
0058 {
0059     ///////////////////////////////////////////////////////////////////////////
0060     template <typename Subject, typename Attribute, typename Context
0061       , typename Iterator>
0062     struct handles_container<qi::reference<Subject>, Attribute, Context
0063       , Iterator>
0064       : handles_container<typename remove_const<Subject>::type
0065         , Attribute, Context, Iterator> 
0066     {};
0067 }}}
0068 
0069 #endif