File indexing completed on 2025-01-18 09:39:24
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef BOOST_LOG_EXPRESSIONS_KEYWORD_HPP_INCLUDED_
0016 #define BOOST_LOG_EXPRESSIONS_KEYWORD_HPP_INCLUDED_
0017
0018 #include <boost/ref.hpp>
0019 #include <boost/proto/extends.hpp>
0020 #include <boost/proto/make_expr.hpp>
0021 #include <boost/phoenix/core/actor.hpp>
0022 #include <boost/phoenix/core/domain.hpp>
0023 #include <boost/phoenix/core/environment.hpp>
0024 #include <boost/fusion/sequence/intrinsic/at.hpp>
0025 #include <boost/preprocessor/cat.hpp>
0026 #include <boost/log/detail/config.hpp>
0027 #include <boost/log/detail/custom_terminal_spec.hpp>
0028 #include <boost/log/expressions/keyword_fwd.hpp>
0029 #include <boost/log/expressions/is_keyword_descriptor.hpp>
0030 #include <boost/log/expressions/attr.hpp>
0031 #include <boost/log/attributes/attribute_name.hpp>
0032 #include <boost/log/attributes/value_extraction.hpp>
0033 #include <boost/log/attributes/fallback_policy.hpp>
0034 #include <boost/log/detail/header.hpp>
0035
0036 #ifdef BOOST_HAS_PRAGMA_ONCE
0037 #pragma once
0038 #endif
0039
0040 namespace boost {
0041
0042 BOOST_LOG_OPEN_NAMESPACE
0043
0044 namespace expressions {
0045
0046
0047
0048
0049 template< typename DescriptorT, template< typename > class ActorT >
0050 struct attribute_keyword
0051 {
0052
0053 typedef attribute_keyword this_type;
0054
0055 typedef DescriptorT descriptor_type;
0056
0057 BOOST_PROTO_BASIC_EXTENDS(typename proto::terminal< descriptor_type >::type, this_type, phoenix::phoenix_domain)
0058
0059
0060 typedef typename descriptor_type::value_type value_type;
0061
0062
0063 static attribute_name get_name() { return descriptor_type::get_name(); }
0064
0065
0066 typedef attribute_actor<
0067 value_type,
0068 fallback_to_none,
0069 descriptor_type,
0070 ActorT
0071 > or_none_result_type;
0072
0073
0074 static or_none_result_type or_none()
0075 {
0076 typedef typename or_none_result_type::terminal_type result_terminal;
0077 typename or_none_result_type::base_type act = {{ result_terminal(get_name()) }};
0078 return or_none_result_type(act);
0079 }
0080
0081
0082 typedef attribute_actor<
0083 value_type,
0084 fallback_to_throw,
0085 descriptor_type,
0086 ActorT
0087 > or_throw_result_type;
0088
0089
0090 static or_throw_result_type or_throw()
0091 {
0092 typedef typename or_throw_result_type::terminal_type result_terminal;
0093 typename or_throw_result_type::base_type act = {{ result_terminal(get_name()) }};
0094 return or_throw_result_type(act);
0095 }
0096
0097
0098 template< typename DefaultT >
0099 static attribute_actor<
0100 value_type,
0101 fallback_to_default< DefaultT >,
0102 descriptor_type,
0103 ActorT
0104 > or_default(DefaultT const& def_val)
0105 {
0106 typedef attribute_actor<
0107 value_type,
0108 fallback_to_default< DefaultT >,
0109 descriptor_type,
0110 ActorT
0111 > or_default_result_type;
0112 typedef typename or_default_result_type::terminal_type result_terminal;
0113 typename or_default_result_type::base_type act = {{ result_terminal(get_name(), def_val) }};
0114 return or_default_result_type(act);
0115 }
0116 };
0117
0118 }
0119
0120 BOOST_LOG_CLOSE_NAMESPACE
0121
0122 #ifndef BOOST_LOG_DOXYGEN_PASS
0123
0124 namespace proto {
0125
0126 namespace detail {
0127
0128
0129
0130
0131 template< typename DescriptorT, template< typename > class ActorT, typename DomainT >
0132 struct protoify< boost::log::expressions::attribute_keyword< DescriptorT, ActorT >, DomainT >
0133 {
0134 typedef boost::log::expressions::attribute_keyword< DescriptorT, ActorT > keyword_type;
0135 typedef typename keyword_type::or_none_result_type result_type;
0136
0137 result_type operator() (keyword_type const& keyword) const
0138 {
0139 return keyword.or_none();
0140 }
0141 };
0142
0143 template< typename DescriptorT, template< typename > class ActorT, typename DomainT >
0144 struct protoify< boost::log::expressions::attribute_keyword< DescriptorT, ActorT >&, DomainT > :
0145 public protoify< boost::log::expressions::attribute_keyword< DescriptorT, ActorT >, DomainT >
0146 {
0147 };
0148
0149 template< typename DescriptorT, template< typename > class ActorT, typename DomainT >
0150 struct protoify< boost::log::expressions::attribute_keyword< DescriptorT, ActorT > const&, DomainT > :
0151 public protoify< boost::log::expressions::attribute_keyword< DescriptorT, ActorT >, DomainT >
0152 {
0153 };
0154
0155 template< typename DescriptorT, template< typename > class ActorT, typename DomainT >
0156 struct protoify< boost::reference_wrapper< boost::log::expressions::attribute_keyword< DescriptorT, ActorT > >, DomainT > :
0157 public protoify< boost::log::expressions::attribute_keyword< DescriptorT, ActorT >, DomainT >
0158 {
0159 };
0160
0161 template< typename DescriptorT, template< typename > class ActorT, typename DomainT >
0162 struct protoify< boost::reference_wrapper< boost::log::expressions::attribute_keyword< DescriptorT, ActorT > > const, DomainT > :
0163 public protoify< boost::log::expressions::attribute_keyword< DescriptorT, ActorT >, DomainT >
0164 {
0165 };
0166
0167 template< typename DescriptorT, template< typename > class ActorT, typename DomainT >
0168 struct protoify< boost::reference_wrapper< const boost::log::expressions::attribute_keyword< DescriptorT, ActorT > >, DomainT > :
0169 public protoify< boost::log::expressions::attribute_keyword< DescriptorT, ActorT >, DomainT >
0170 {
0171 };
0172
0173 template< typename DescriptorT, template< typename > class ActorT, typename DomainT >
0174 struct protoify< boost::reference_wrapper< const boost::log::expressions::attribute_keyword< DescriptorT, ActorT > > const, DomainT > :
0175 public protoify< boost::log::expressions::attribute_keyword< DescriptorT, ActorT >, DomainT >
0176 {
0177 };
0178
0179 }
0180
0181 }
0182
0183 #endif
0184
0185 }
0186
0187 #ifndef BOOST_LOG_DOXYGEN_PASS
0188
0189 #define BOOST_LOG_ATTRIBUTE_KEYWORD_TYPE_IMPL(keyword_, name_, value_type_, tag_ns_)\
0190 namespace tag_ns_\
0191 {\
0192 struct keyword_ :\
0193 public ::boost::log::expressions::keyword_descriptor\
0194 {\
0195 typedef value_type_ value_type;\
0196 static ::boost::log::attribute_name get_name() { return ::boost::log::attribute_name(name_); }\
0197 };\
0198 }\
0199 typedef ::boost::log::expressions::attribute_keyword< tag_ns_::keyword_ > BOOST_PP_CAT(keyword_, _type);
0200
0201 #define BOOST_LOG_ATTRIBUTE_KEYWORD_IMPL(keyword_, name_, value_type_, tag_ns_)\
0202 BOOST_LOG_ATTRIBUTE_KEYWORD_TYPE_IMPL(keyword_, name_, value_type_, tag_ns_)\
0203 BOOST_INLINE_VARIABLE const BOOST_PP_CAT(keyword_, _type) keyword_ = {};
0204
0205 #endif
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236 #define BOOST_LOG_ATTRIBUTE_KEYWORD_TYPE(keyword_, name_, value_type_)\
0237 BOOST_LOG_ATTRIBUTE_KEYWORD_TYPE_IMPL(keyword_, name_, value_type_, tag)
0238
0239
0240
0241
0242
0243
0244
0245
0246
0247
0248
0249 #define BOOST_LOG_ATTRIBUTE_KEYWORD(keyword_, name_, value_type_)\
0250 BOOST_LOG_ATTRIBUTE_KEYWORD_IMPL(keyword_, name_, value_type_, tag)
0251
0252 #include <boost/log/detail/footer.hpp>
0253
0254 #if defined(BOOST_LOG_TRIVIAL_HPP_INCLUDED_)
0255 #include <boost/log/detail/trivial_keyword.hpp>
0256 #endif
0257
0258 #endif