Chris@16
|
1 ///////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
2 // modifier.hpp
|
Chris@16
|
3 //
|
Chris@16
|
4 // Copyright 2008 Eric Niebler. Distributed under the Boost
|
Chris@16
|
5 // Software License, Version 1.0. (See accompanying file
|
Chris@16
|
6 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
7
|
Chris@16
|
8 #ifndef BOOST_XPRESSIVE_DETAIL_STATIC_MODIFIER_HPP_EAN_10_04_2005
|
Chris@16
|
9 #define BOOST_XPRESSIVE_DETAIL_STATIC_MODIFIER_HPP_EAN_10_04_2005
|
Chris@16
|
10
|
Chris@16
|
11 // MS compatible compilers support #pragma once
|
Chris@101
|
12 #if defined(_MSC_VER)
|
Chris@16
|
13 # pragma once
|
Chris@16
|
14 # pragma warning(push)
|
Chris@16
|
15 # pragma warning(disable : 4510) // default constructor could not be generated
|
Chris@16
|
16 # pragma warning(disable : 4610) // user defined constructor required
|
Chris@16
|
17 #endif
|
Chris@16
|
18
|
Chris@16
|
19 #include <boost/xpressive/detail/detail_fwd.hpp>
|
Chris@16
|
20 #include <boost/proto/traits.hpp>
|
Chris@16
|
21 #include <boost/xpressive/regex_constants.hpp>
|
Chris@16
|
22
|
Chris@16
|
23 namespace boost { namespace xpressive { namespace detail
|
Chris@16
|
24 {
|
Chris@16
|
25
|
Chris@16
|
26 ///////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
27 // modifier
|
Chris@16
|
28 template<typename Modifier>
|
Chris@16
|
29 struct modifier_op
|
Chris@16
|
30 {
|
Chris@16
|
31 typedef regex_constants::syntax_option_type opt_type;
|
Chris@16
|
32
|
Chris@16
|
33 template<typename Expr>
|
Chris@16
|
34 struct apply
|
Chris@16
|
35 {
|
Chris@16
|
36 typedef typename proto::binary_expr<
|
Chris@16
|
37 modifier_tag
|
Chris@16
|
38 , typename proto::terminal<Modifier>::type
|
Chris@16
|
39 , typename proto::result_of::as_child<Expr const>::type
|
Chris@16
|
40 >::type type;
|
Chris@16
|
41 };
|
Chris@16
|
42
|
Chris@16
|
43 template<typename Expr>
|
Chris@16
|
44 typename apply<Expr>::type const
|
Chris@16
|
45 operator ()(Expr const &expr) const
|
Chris@16
|
46 {
|
Chris@16
|
47 typename apply<Expr>::type that = {{this->mod_}, proto::as_child(expr)};
|
Chris@16
|
48 return that;
|
Chris@16
|
49 }
|
Chris@16
|
50
|
Chris@16
|
51 operator opt_type() const
|
Chris@16
|
52 {
|
Chris@16
|
53 return this->opt_;
|
Chris@16
|
54 }
|
Chris@16
|
55
|
Chris@16
|
56 Modifier mod_;
|
Chris@16
|
57 opt_type opt_;
|
Chris@16
|
58 };
|
Chris@16
|
59
|
Chris@16
|
60 }}}
|
Chris@16
|
61
|
Chris@101
|
62 #if defined(_MSC_VER)
|
Chris@16
|
63 # pragma warning(pop)
|
Chris@16
|
64 #endif
|
Chris@16
|
65
|
Chris@16
|
66 #endif
|