File indexing completed on 2025-01-18 09:39:23
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef BOOST_LOG_EXPRESSIONS_PREDICATES_HAS_ATTR_HPP_INCLUDED_
0016 #define BOOST_LOG_EXPRESSIONS_PREDICATES_HAS_ATTR_HPP_INCLUDED_
0017
0018 #include <boost/phoenix/core/actor.hpp>
0019 #include <boost/log/detail/config.hpp>
0020 #include <boost/log/core/record_view.hpp>
0021 #include <boost/log/attributes/attribute_name.hpp>
0022 #include <boost/log/attributes/attribute_value_set.hpp>
0023 #include <boost/log/attributes/value_visitation.hpp>
0024 #include <boost/log/expressions/keyword_fwd.hpp>
0025 #include <boost/log/detail/unary_function_terminal.hpp>
0026 #include <boost/log/utility/functional/nop.hpp>
0027 #include <boost/log/detail/header.hpp>
0028
0029 #ifdef BOOST_HAS_PRAGMA_ONCE
0030 #pragma once
0031 #endif
0032
0033 namespace boost {
0034
0035 BOOST_LOG_OPEN_NAMESPACE
0036
0037 namespace expressions {
0038
0039
0040
0041
0042 template< typename T >
0043 class has_attribute
0044 {
0045 public:
0046
0047 typedef bool result_type;
0048
0049 typedef T value_type;
0050
0051 private:
0052
0053 const attribute_name m_name;
0054
0055 value_visitor_invoker< value_type > m_visitor_invoker;
0056
0057 public:
0058
0059
0060
0061
0062
0063 explicit has_attribute(attribute_name const& name) : m_name(name)
0064 {
0065 }
0066
0067
0068
0069
0070
0071
0072
0073 template< typename ArgT >
0074 result_type operator() (ArgT const& arg) const
0075 {
0076 return m_visitor_invoker(m_name, arg, nop()).code() == visitation_result::ok;
0077 }
0078 };
0079
0080
0081
0082
0083 template< >
0084 class has_attribute< void >
0085 {
0086 public:
0087
0088 typedef bool result_type;
0089
0090 typedef void value_type;
0091
0092 private:
0093
0094 const attribute_name m_name;
0095
0096 public:
0097
0098
0099
0100
0101
0102 explicit has_attribute(attribute_name const& name) : m_name(name)
0103 {
0104 }
0105
0106
0107
0108
0109
0110
0111
0112 result_type operator() (attribute_value_set const& attrs) const
0113 {
0114 return attrs.find(m_name) != attrs.end();
0115 }
0116
0117
0118
0119
0120
0121
0122
0123 result_type operator() (boost::log::record_view const& rec) const
0124 {
0125 return operator()(rec.attribute_values());
0126 }
0127 };
0128
0129
0130
0131
0132
0133 template< typename AttributeValueT >
0134 BOOST_FORCEINLINE phoenix::actor< aux::unary_function_terminal< has_attribute< AttributeValueT > > > has_attr(attribute_name const& name)
0135 {
0136 typedef aux::unary_function_terminal< has_attribute< AttributeValueT > > terminal_type;
0137 phoenix::actor< terminal_type > act = {{ terminal_type(name) }};
0138 return act;
0139 }
0140
0141
0142
0143
0144
0145 BOOST_FORCEINLINE phoenix::actor< aux::unary_function_terminal< has_attribute< void > > > has_attr(attribute_name const& name)
0146 {
0147 typedef aux::unary_function_terminal< has_attribute< void > > terminal_type;
0148 phoenix::actor< terminal_type > act = {{ terminal_type(name) }};
0149 return act;
0150 }
0151
0152
0153
0154
0155
0156 template< typename DescriptorT, template< typename > class ActorT >
0157 BOOST_FORCEINLINE ActorT< aux::unary_function_terminal< has_attribute< typename DescriptorT::value_type > > > has_attr(attribute_keyword< DescriptorT, ActorT > const&)
0158 {
0159 typedef aux::unary_function_terminal< has_attribute< typename DescriptorT::value_type > > terminal_type;
0160 ActorT< terminal_type > act = {{ terminal_type(DescriptorT::get_name()) }};
0161 return act;
0162 }
0163
0164 }
0165
0166 BOOST_LOG_CLOSE_NAMESPACE
0167
0168 }
0169
0170 #include <boost/log/detail/footer.hpp>
0171
0172 #endif