]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/spirit/home/qi/detail/expect_function.hpp
bump version to 19.2.0-pve1
[ceph.git] / ceph / src / boost / boost / spirit / home / qi / detail / expect_function.hpp
CommitLineData
7c673cae
FG
1/*=============================================================================
2 Copyright (c) 2001-2011 Joel de Guzman
3
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6=============================================================================*/
f67539c2
TL
7#ifndef BOOST_SPIRIT_QI_DETAIL_EXPECT_FUNCTION_HPP
8#define BOOST_SPIRIT_QI_DETAIL_EXPECT_FUNCTION_HPP
7c673cae
FG
9
10#if defined(_MSC_VER)
11#pragma once
12#endif
13
14#include <boost/spirit/home/support/unused.hpp>
15#include <boost/spirit/home/support/multi_pass_wrapper.hpp>
16#include <boost/throw_exception.hpp>
17
18namespace boost { namespace spirit { namespace qi { namespace detail
19{
f51cf556
TL
20#ifdef _MSC_VER
21# pragma warning(push)
22# pragma warning(disable: 4512) // assignment operator could not be generated.
23#endif
7c673cae
FG
24 template <
25 typename Iterator, typename Context
26 , typename Skipper, typename Exception>
27 struct expect_function
28 {
29 typedef Iterator iterator_type;
30 typedef Context context_type;
31
32 expect_function(
33 Iterator& first_, Iterator const& last_
34 , Context& context_, Skipper const& skipper_)
35 : first(first_)
36 , last(last_)
37 , context(context_)
38 , skipper(skipper_)
39 , is_first(true)
40 {
41 }
42
43 template <typename Component, typename Attribute>
44 bool operator()(Component const& component, Attribute& attr) const
45 {
46 // if this is not the first component in the expect chain we
47 // need to flush any multi_pass iterator we might be acting on
48 if (!is_first)
49 spirit::traits::clear_queue(first);
50
51 // if we are testing the first component in the sequence,
52 // return true if the parser fails, if this is not the first
53 // component, throw exception if the parser fails
54 if (!component.parse(first, last, context, skipper, attr))
55 {
56 if (is_first)
57 {
58 is_first = false;
59 return true; // true means the match failed
60 }
61 boost::throw_exception(Exception(first, last, component.what(context)));
62#if defined(BOOST_NO_EXCEPTIONS)
63 return true; // for systems not supporting exceptions
64#endif
65 }
66 is_first = false;
67 return false;
68 }
69
70 template <typename Component>
71 bool operator()(Component const& component) const
72 {
73 // if this is not the first component in the expect chain we
74 // need to flush any multi_pass iterator we might be acting on
75 if (!is_first)
76 spirit::traits::clear_queue(first);
77
78 // if we are testing the first component in the sequence,
79 // return true if the parser fails, if this not the first
80 // component, throw exception if the parser fails
81 if (!component.parse(first, last, context, skipper, unused))
82 {
83 if (is_first)
84 {
85 is_first = false;
86 return true;
87 }
88 boost::throw_exception(Exception(first, last, component.what(context)));
89#if defined(BOOST_NO_EXCEPTIONS)
90 return false; // for systems not supporting exceptions
91#endif
92 }
93 is_first = false;
94 return false;
95 }
96
97 Iterator& first;
98 Iterator const& last;
99 Context& context;
100 Skipper const& skipper;
101 mutable bool is_first;
7c673cae 102 };
f51cf556
TL
103#ifdef _MSC_VER
104# pragma warning(pop)
105#endif
7c673cae
FG
106}}}}
107
108#endif