Chris@16
|
1 /*
|
Chris@101
|
2 * Copyright Andrey Semashev 2007 - 2015.
|
Chris@16
|
3 * Distributed under the Boost Software License, Version 1.0.
|
Chris@16
|
4 * (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
5 * http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
6 */
|
Chris@16
|
7 /*!
|
Chris@16
|
8 * \file as_action.hpp
|
Chris@16
|
9 * \author Andrey Semashev
|
Chris@16
|
10 * \date 30.03.2008
|
Chris@16
|
11 *
|
Chris@16
|
12 * This header contains function object adapter for compatibility with Boost.Spirit actions interface requirements.
|
Chris@16
|
13 */
|
Chris@16
|
14
|
Chris@16
|
15 #ifndef BOOST_LOG_UTILITY_FUNCTIONAL_AS_ACTION_HPP_INCLUDED_
|
Chris@16
|
16 #define BOOST_LOG_UTILITY_FUNCTIONAL_AS_ACTION_HPP_INCLUDED_
|
Chris@16
|
17
|
Chris@16
|
18 #include <boost/log/detail/config.hpp>
|
Chris@16
|
19 #include <boost/log/detail/header.hpp>
|
Chris@16
|
20
|
Chris@16
|
21 #ifdef BOOST_HAS_PRAGMA_ONCE
|
Chris@16
|
22 #pragma once
|
Chris@16
|
23 #endif
|
Chris@16
|
24
|
Chris@16
|
25 namespace boost {
|
Chris@16
|
26
|
Chris@16
|
27 BOOST_LOG_OPEN_NAMESPACE
|
Chris@16
|
28
|
Chris@16
|
29 //! Function object adapter for Boost.Spirit actions
|
Chris@16
|
30 template< typename FunT >
|
Chris@16
|
31 struct as_action_adapter
|
Chris@16
|
32 {
|
Chris@16
|
33 typedef typename FunT::result_type result_type;
|
Chris@16
|
34
|
Chris@16
|
35 BOOST_DEFAULTED_FUNCTION(as_action_adapter(), {})
|
Chris@16
|
36 explicit as_action_adapter(FunT const& fun) : m_fun(fun) {}
|
Chris@16
|
37
|
Chris@16
|
38 template< typename AttributeT, typename ContextT >
|
Chris@16
|
39 result_type operator() (AttributeT const& attr, ContextT const& ctx, bool& pass) const
|
Chris@16
|
40 {
|
Chris@16
|
41 return m_fun(attr);
|
Chris@16
|
42 }
|
Chris@16
|
43
|
Chris@16
|
44 private:
|
Chris@16
|
45 FunT m_fun;
|
Chris@16
|
46 };
|
Chris@16
|
47
|
Chris@16
|
48 template< typename FunT >
|
Chris@16
|
49 BOOST_FORCEINLINE as_action_adapter< FunT > as_action(FunT const& fun)
|
Chris@16
|
50 {
|
Chris@16
|
51 return as_action_adapter< FunT >(fun);
|
Chris@16
|
52 }
|
Chris@16
|
53
|
Chris@16
|
54 BOOST_LOG_CLOSE_NAMESPACE // namespace log
|
Chris@16
|
55
|
Chris@16
|
56 } // namespace boost
|
Chris@16
|
57
|
Chris@16
|
58 #include <boost/log/detail/footer.hpp>
|
Chris@16
|
59
|
Chris@16
|
60 #endif // BOOST_LOG_UTILITY_FUNCTIONAL_AS_ACTION_HPP_INCLUDED_
|