File indexing completed on 2025-01-19 09:47:44
0001
0002
0003
0004
0005
0006
0007 #ifndef BOOST_SPIRIT_QI_DETAIL_EXPECT_FUNCTION_HPP
0008 #define BOOST_SPIRIT_QI_DETAIL_EXPECT_FUNCTION_HPP
0009
0010 #if defined(_MSC_VER)
0011 #pragma once
0012 #endif
0013
0014 #include <boost/spirit/home/support/unused.hpp>
0015 #include <boost/spirit/home/support/multi_pass_wrapper.hpp>
0016 #include <boost/throw_exception.hpp>
0017
0018 namespace boost { namespace spirit { namespace qi { namespace detail
0019 {
0020 #ifdef _MSC_VER
0021 # pragma warning(push)
0022 # pragma warning(disable: 4512)
0023 #endif
0024 template <
0025 typename Iterator, typename Context
0026 , typename Skipper, typename Exception>
0027 struct expect_function
0028 {
0029 typedef Iterator iterator_type;
0030 typedef Context context_type;
0031
0032 expect_function(
0033 Iterator& first_, Iterator const& last_
0034 , Context& context_, Skipper const& skipper_)
0035 : first(first_)
0036 , last(last_)
0037 , context(context_)
0038 , skipper(skipper_)
0039 , is_first(true)
0040 {
0041 }
0042
0043 template <typename Component, typename Attribute>
0044 bool operator()(Component const& component, Attribute& attr) const
0045 {
0046
0047
0048 if (!is_first)
0049 spirit::traits::clear_queue(first);
0050
0051
0052
0053
0054 if (!component.parse(first, last, context, skipper, attr))
0055 {
0056 if (is_first)
0057 {
0058 is_first = false;
0059 return true;
0060 }
0061 boost::throw_exception(Exception(first, last, component.what(context)));
0062 #if defined(BOOST_NO_EXCEPTIONS)
0063 return true;
0064 #endif
0065 }
0066 is_first = false;
0067 return false;
0068 }
0069
0070 template <typename Component>
0071 bool operator()(Component const& component) const
0072 {
0073
0074
0075 if (!is_first)
0076 spirit::traits::clear_queue(first);
0077
0078
0079
0080
0081 if (!component.parse(first, last, context, skipper, unused))
0082 {
0083 if (is_first)
0084 {
0085 is_first = false;
0086 return true;
0087 }
0088 boost::throw_exception(Exception(first, last, component.what(context)));
0089 #if defined(BOOST_NO_EXCEPTIONS)
0090 return false;
0091 #endif
0092 }
0093 is_first = false;
0094 return false;
0095 }
0096
0097 Iterator& first;
0098 Iterator const& last;
0099 Context& context;
0100 Skipper const& skipper;
0101 mutable bool is_first;
0102 };
0103 #ifdef _MSC_VER
0104 # pragma warning(pop)
0105 #endif
0106 }}}}
0107
0108 #endif