1
/*=============================================================================
2
Copyright (c) 2005-2007 Dan Marsden
3
Copyright (c) 2005-2007 Joel de Guzman
5
Distributed under the Boost Software License, Version 1.0. (See accompanying
6
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7
==============================================================================*/
9
#ifndef PHOENIX_STATEMENT_TRY_CATCH_HPP
10
#define PHOENIX_STATEMENT_TRY_CATCH_HPP
12
#include <boost/spirit/home/phoenix/core/actor.hpp>
13
#include <boost/spirit/home/phoenix/core/composite.hpp>
15
#include <boost/fusion/include/push_back.hpp>
16
#include <boost/fusion/include/as_vector.hpp>
18
#include <boost/spirit/home/phoenix/statement/detail/catch_composite.hpp>
19
#include <boost/spirit/home/phoenix/statement/detail/catch_eval.hpp>
20
#include <boost/spirit/home/phoenix/statement/detail/catch_all_eval.hpp>
22
#if defined(BOOST_MSVC)
23
# pragma warning(push)
24
# pragma warning(disable:4355)
27
namespace boost { namespace phoenix {
29
template<typename Tuple> struct try_catch_composite;
33
template<typename Composite, typename Actor>
34
struct try_catch_composite_push_back
36
typedef typename Composite::base_type actor_tuple;
37
typedef try_catch_composite<
38
typename fusion::result_of::as_vector<
39
typename fusion::result_of::push_back<
40
actor_tuple, Actor>::type>::type> type;
43
template<typename Composite, typename Actor>
44
struct catch_all_composite_push_back
46
typedef typename Composite::base_type actor_tuple;
50
typename fusion::result_of::as_vector<
51
typename fusion::result_of::push_back<
52
actor_tuple, Actor>::type>::type> type;
58
struct try_catch_composite_push_back
60
template<typename Composite, typename Actor>
62
: meta::try_catch_composite_push_back<Composite, Actor>
65
template<typename Composite, typename Actor>
66
typename result<Composite, Actor>::type
68
const Composite& composite, const Actor& actor) const
70
typedef typename result<Composite, Actor>::type result;
73
fusion::push_back(composite, actor)));
77
struct catch_all_composite_push_back
79
template<typename Composite, typename Actor>
81
: meta::catch_all_composite_push_back<Composite, Actor>
84
template<typename Composite, typename Actor>
85
typename result<Composite, Actor>::type
87
const Composite& composite, const Actor& actor) const
89
typedef typename result<Composite, Actor>::type result;
92
fusion::push_back(composite, actor)));
98
detail::try_catch_composite_push_back const try_catch_composite_push_back
99
= detail::try_catch_composite_push_back();
100
detail::catch_all_composite_push_back const catch_all_composite_push_back
101
= detail::catch_all_composite_push_back();
103
template<typename Exception, typename SourceComposite>
107
const SourceComposite& sourceComposite)
108
: mSourceComposite(sourceComposite) { }
110
template<typename Actor>
111
actor<typename meta::try_catch_composite_push_back<
113
detail::catch_composite<Exception, Actor> >::type>
114
operator[](const Actor& actor) const
116
return try_catch_composite_push_back(
117
mSourceComposite, detail::catch_composite<Exception, Actor>(actor));
120
const SourceComposite& mSourceComposite;
123
template<typename SourceComposite>
126
explicit catch_all_gen(
127
const SourceComposite& sourceComposite)
128
: mSourceComposite(sourceComposite) { }
130
template<typename Actor>
131
actor<typename meta::catch_all_composite_push_back<SourceComposite, Actor>::type>
132
operator[](const Actor& actor) const
134
return catch_all_composite_push_back(
135
mSourceComposite, actor);
138
const SourceComposite& mSourceComposite;
141
template<typename Tuple>
142
struct try_catch_composite
143
: composite<catch_eval, Tuple>
145
explicit try_catch_composite(
148
composite<catch_eval, Tuple>(t),
152
const try_catch_composite& rhs)
153
: composite<catch_eval, Tuple>(rhs),
156
template<typename Exception>
157
catch_gen<Exception, try_catch_composite> catch_() const
159
return catch_gen<Exception, try_catch_composite>(
163
const catch_all_gen<try_catch_composite> catch_all;
166
try_catch_composite& operator=(const try_catch_composite&);
171
template<typename Try>
172
try_catch_composite<fusion::vector<Try> > operator[](
173
const Try& try_) const
175
typedef fusion::vector<Try> tuple_type;
176
return try_catch_composite<tuple_type>(
181
try_gen const try_ = try_gen();
184
#if defined(BOOST_MSVC)
185
# pragma warning(pop)