File indexing completed on 2025-01-31 10:02:15
0001
0002
0003
0004
0005
0006 #if !defined(BOOST_SPIRIT_LEX_LEXER_ITERATOR_MAR_16_2007_0353PM)
0007 #define BOOST_SPIRIT_LEX_LEXER_ITERATOR_MAR_16_2007_0353PM
0008
0009 #if defined(_MSC_VER)
0010 #pragma once
0011 #endif
0012
0013 #include <boost/spirit/home/support/multi_pass_wrapper.hpp>
0014 #if defined(BOOST_SPIRIT_DEBUG)
0015 #include <boost/spirit/home/support/iterators/detail/buf_id_check_policy.hpp>
0016 #else
0017 #include <boost/spirit/home/support/iterators/detail/no_check_policy.hpp>
0018 #endif
0019 #include <boost/spirit/home/support/iterators/detail/split_functor_input_policy.hpp>
0020 #include <boost/spirit/home/support/iterators/detail/ref_counted_policy.hpp>
0021 #include <boost/spirit/home/support/iterators/detail/split_std_deque_policy.hpp>
0022 #include <boost/spirit/home/support/iterators/multi_pass.hpp>
0023
0024 namespace boost { namespace spirit { namespace lex { namespace lexertl
0025 {
0026
0027 template <typename FunctorData>
0028 struct make_multi_pass
0029 {
0030
0031
0032 typedef std::pair<typename FunctorData::unique
0033 , typename FunctorData::shared> functor_data_type;
0034
0035
0036 typedef typename FunctorData::result_type result_type;
0037
0038
0039
0040 typedef iterator_policies::split_functor_input input_policy;
0041 typedef iterator_policies::ref_counted ownership_policy;
0042 #if defined(BOOST_SPIRIT_DEBUG)
0043 typedef iterator_policies::buf_id_check check_policy;
0044 #else
0045 typedef iterator_policies::no_check check_policy;
0046 #endif
0047 typedef iterator_policies::split_std_deque storage_policy;
0048
0049 typedef iterator_policies::default_policy<
0050 ownership_policy, check_policy, input_policy, storage_policy>
0051 policy_type;
0052
0053
0054 typedef spirit::multi_pass<functor_data_type, policy_type> type;
0055 };
0056
0057
0058
0059
0060
0061
0062 template <typename Functor>
0063 class iterator : public make_multi_pass<Functor>::type
0064 {
0065 public:
0066 typedef typename Functor::unique unique_functor_type;
0067 typedef typename Functor::shared shared_functor_type;
0068
0069 typedef typename Functor::iterator_type base_iterator_type;
0070 typedef typename Functor::result_type token_type;
0071
0072 private:
0073 typedef typename make_multi_pass<Functor>::functor_data_type
0074 functor_type;
0075 typedef typename make_multi_pass<Functor>::type base_type;
0076 typedef typename Functor::char_type char_type;
0077
0078 public:
0079
0080
0081 template <typename IteratorData>
0082 iterator(IteratorData const& iterdata_, base_iterator_type& first
0083 , base_iterator_type const& last, char_type const* state = 0)
0084 : base_type(functor_type(unique_functor_type()
0085 , shared_functor_type(iterdata_, first, last)))
0086 {
0087 set_state(map_state(state));
0088 }
0089
0090
0091 iterator() {}
0092
0093
0094
0095 iterator(const base_type& base)
0096 : base_type(base) { }
0097
0098
0099 std::size_t set_state(std::size_t state)
0100 {
0101 return unique_functor_type::set_state(*this, state);
0102 }
0103
0104
0105 std::size_t get_state()
0106 {
0107 return unique_functor_type::get_state(*this);
0108 }
0109
0110
0111
0112 std::size_t map_state(char_type const* statename)
0113 {
0114 return (0 != statename)
0115 ? unique_functor_type::map_state(*this, statename)
0116 : 0;
0117 }
0118 };
0119 }}
0120
0121 namespace traits
0122 {
0123 template <typename Functor>
0124 struct is_multi_pass<spirit::lex::lexertl::iterator<Functor> >
0125 : mpl::true_ {};
0126
0127 template <typename Functor>
0128 void clear_queue(spirit::lex::lexertl::iterator<Functor> & mp
0129 , BOOST_SCOPED_ENUM(traits::clear_mode) mode)
0130 {
0131 mp.clear_queue(mode);
0132 }
0133
0134 template <typename Functor>
0135 void inhibit_clear_queue(spirit::lex::lexertl::iterator<Functor>& mp, bool flag)
0136 {
0137 mp.inhibit_clear_queue(flag);
0138 }
0139
0140 template <typename Functor>
0141 bool inhibit_clear_queue(spirit::lex::lexertl::iterator<Functor>& mp)
0142 {
0143 return mp.inhibit_clear_queue();
0144 }
0145 }
0146
0147 }}
0148
0149 #endif