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 parameter_tools.hpp
|
Chris@16
|
9 * \author Andrey Semashev
|
Chris@16
|
10 * \date 28.06.2009
|
Chris@16
|
11 *
|
Chris@16
|
12 * \brief This header is the Boost.Log library implementation, see the library documentation
|
Chris@16
|
13 * at http://www.boost.org/doc/libs/release/libs/log/doc/html/index.html.
|
Chris@16
|
14 */
|
Chris@16
|
15
|
Chris@16
|
16 #ifndef BOOST_LOG_DETAIL_PARAMETER_TOOLS_HPP_INCLUDED_
|
Chris@16
|
17 #define BOOST_LOG_DETAIL_PARAMETER_TOOLS_HPP_INCLUDED_
|
Chris@16
|
18
|
Chris@16
|
19 #include <boost/parameter/keyword.hpp>
|
Chris@16
|
20 #include <boost/preprocessor/repetition/enum_params.hpp>
|
Chris@16
|
21 #include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
Chris@16
|
22 #include <boost/preprocessor/repetition/repeat_from_to.hpp>
|
Chris@16
|
23 #include <boost/preprocessor/facilities/intercept.hpp>
|
Chris@16
|
24 #include <boost/preprocessor/arithmetic/dec.hpp>
|
Chris@16
|
25 #include <boost/preprocessor/tuple/elem.hpp>
|
Chris@16
|
26 #include <boost/log/detail/config.hpp>
|
Chris@16
|
27 #include <boost/log/detail/header.hpp>
|
Chris@16
|
28
|
Chris@16
|
29 #ifdef BOOST_HAS_PRAGMA_ONCE
|
Chris@16
|
30 #pragma once
|
Chris@16
|
31 #endif
|
Chris@16
|
32
|
Chris@16
|
33 #ifndef BOOST_LOG_MAX_PARAMETER_ARGS
|
Chris@16
|
34 //! The maximum number of named arguments that are accepted by constructors and functions
|
Chris@16
|
35 #define BOOST_LOG_MAX_PARAMETER_ARGS 16
|
Chris@16
|
36 #endif
|
Chris@16
|
37
|
Chris@16
|
38 // The macro applies the passed macro with the specified arguments BOOST_LOG_MAX_PARAMETER_ARGS times
|
Chris@16
|
39 #define BOOST_LOG_PARAMETRIZED_CONSTRUCTORS_GEN(macro, args)\
|
Chris@16
|
40 public:\
|
Chris@16
|
41 BOOST_PP_REPEAT_FROM_TO(1, BOOST_LOG_MAX_PARAMETER_ARGS, macro, args)
|
Chris@16
|
42
|
Chris@16
|
43
|
Chris@16
|
44 #define BOOST_LOG_CTOR_FORWARD(z, n, types)\
|
Chris@16
|
45 template< BOOST_PP_ENUM_PARAMS(n, typename T) >\
|
Chris@16
|
46 explicit BOOST_PP_TUPLE_ELEM(2, 0, types)(BOOST_PP_ENUM_BINARY_PARAMS(n, T, const& arg)) :\
|
Chris@16
|
47 BOOST_PP_TUPLE_ELEM(2, 1, types)((BOOST_PP_ENUM_PARAMS(n, arg))) {}
|
Chris@16
|
48
|
Chris@16
|
49 // The macro expands to a number of templated constructors that aggregate their named arguments
|
Chris@16
|
50 // into an ArgumentsPack and pass it to the base class constructor.
|
Chris@16
|
51 #define BOOST_LOG_PARAMETRIZED_CONSTRUCTORS_FORWARD(class_type, base_type)\
|
Chris@16
|
52 BOOST_LOG_PARAMETRIZED_CONSTRUCTORS_GEN(BOOST_LOG_CTOR_FORWARD, (class_type, base_type))
|
Chris@16
|
53
|
Chris@16
|
54
|
Chris@16
|
55 #define BOOST_LOG_CTOR_CALL(z, n, types)\
|
Chris@16
|
56 template< BOOST_PP_ENUM_PARAMS(n, typename T) >\
|
Chris@16
|
57 explicit BOOST_PP_TUPLE_ELEM(2, 0, types)(BOOST_PP_ENUM_BINARY_PARAMS(n, T, const& arg))\
|
Chris@16
|
58 { BOOST_PP_TUPLE_ELEM(2, 1, types)((BOOST_PP_ENUM_PARAMS(n, arg))); }
|
Chris@16
|
59
|
Chris@16
|
60 // The macro expands to a number of templated constructors that aggregate their named arguments
|
Chris@16
|
61 // into an ArgumentsPack and pass it to a function call.
|
Chris@16
|
62 #define BOOST_LOG_PARAMETRIZED_CONSTRUCTORS_CALL(class_type, fun)\
|
Chris@16
|
63 BOOST_LOG_PARAMETRIZED_CONSTRUCTORS_GEN(BOOST_LOG_CTOR_CALL, (class_type, fun))
|
Chris@16
|
64
|
Chris@16
|
65 namespace boost {
|
Chris@16
|
66
|
Chris@16
|
67 BOOST_LOG_OPEN_NAMESPACE
|
Chris@16
|
68
|
Chris@16
|
69 namespace aux {
|
Chris@16
|
70
|
Chris@16
|
71 // Yeah, not too cute. The empty_arg_list class should really be public.
|
Chris@16
|
72 typedef boost::parameter::aux::empty_arg_list empty_arg_list;
|
Chris@16
|
73
|
Chris@16
|
74 #if !(defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_LOG_NO_CXX11_ARG_PACKS_TO_NON_VARIADIC_ARGS_EXPANSION))
|
Chris@16
|
75
|
Chris@16
|
76 //! The metafunction generates argument pack
|
Chris@16
|
77 template< typename ArgT0, typename... ArgsT >
|
Chris@16
|
78 struct make_arg_list
|
Chris@16
|
79 {
|
Chris@16
|
80 typedef boost::parameter::aux::arg_list< ArgT0, typename make_arg_list< ArgsT... >::type > type;
|
Chris@16
|
81 };
|
Chris@16
|
82
|
Chris@16
|
83 template< typename ArgT0 >
|
Chris@16
|
84 struct make_arg_list< ArgT0 >
|
Chris@16
|
85 {
|
Chris@16
|
86 typedef boost::parameter::aux::arg_list< ArgT0 > type;
|
Chris@16
|
87 };
|
Chris@16
|
88
|
Chris@16
|
89 #else
|
Chris@16
|
90
|
Chris@16
|
91 //! The metafunction generates argument pack
|
Chris@16
|
92 template< typename ArgT0, BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_DEC(BOOST_LOG_MAX_PARAMETER_ARGS), typename T, = void BOOST_PP_INTERCEPT) >
|
Chris@16
|
93 struct make_arg_list
|
Chris@16
|
94 {
|
Chris@16
|
95 typedef boost::parameter::aux::arg_list< ArgT0, typename make_arg_list< BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(BOOST_LOG_MAX_PARAMETER_ARGS), T) >::type > type;
|
Chris@16
|
96 };
|
Chris@16
|
97
|
Chris@16
|
98 template< typename ArgT0 >
|
Chris@16
|
99 struct make_arg_list< ArgT0, BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(BOOST_LOG_MAX_PARAMETER_ARGS), void BOOST_PP_INTERCEPT) >
|
Chris@16
|
100 {
|
Chris@16
|
101 typedef boost::parameter::aux::arg_list< ArgT0 > type;
|
Chris@16
|
102 };
|
Chris@16
|
103
|
Chris@16
|
104 #endif
|
Chris@16
|
105
|
Chris@16
|
106 } // namespace aux
|
Chris@16
|
107
|
Chris@16
|
108 BOOST_LOG_CLOSE_NAMESPACE // namespace log
|
Chris@16
|
109
|
Chris@16
|
110 } // namespace boost
|
Chris@16
|
111
|
Chris@16
|
112 #include <boost/log/detail/footer.hpp>
|
Chris@16
|
113
|
Chris@16
|
114 #endif // BOOST_LOG_DETAIL_PARAMETER_TOOLS_HPP_INCLUDED_
|