File indexing completed on 2025-01-30 09:45:05
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef BOOST_LOG_EXPRESSIONS_FILTER_HPP_INCLUDED_
0016 #define BOOST_LOG_EXPRESSIONS_FILTER_HPP_INCLUDED_
0017
0018 #include <boost/move/core.hpp>
0019 #include <boost/move/utility_core.hpp>
0020 #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
0021 #include <boost/type_traits/is_same.hpp>
0022 #include <boost/type_traits/remove_cv.hpp>
0023 #include <boost/log/detail/sfinae_tools.hpp>
0024 #endif
0025 #include <boost/log/detail/config.hpp>
0026 #include <boost/log/attributes/attribute_value_set.hpp>
0027 #include <boost/log/detail/light_function.hpp>
0028 #include <boost/log/detail/header.hpp>
0029
0030 #ifdef BOOST_HAS_PRAGMA_ONCE
0031 #pragma once
0032 #endif
0033
0034 namespace boost {
0035
0036 BOOST_LOG_OPEN_NAMESPACE
0037
0038
0039
0040
0041 class filter
0042 {
0043 BOOST_COPYABLE_AND_MOVABLE(filter)
0044
0045 public:
0046
0047 typedef bool result_type;
0048
0049 private:
0050
0051 typedef boost::log::aux::light_function< bool (attribute_value_set const&) > filter_type;
0052
0053
0054 struct default_filter
0055 {
0056 typedef bool result_type;
0057 result_type operator() (attribute_value_set const&) const { return true; }
0058 };
0059
0060 private:
0061
0062 filter_type m_Filter;
0063
0064 public:
0065
0066
0067
0068 filter() : m_Filter(default_filter())
0069 {
0070 }
0071
0072
0073
0074 filter(filter const& that) : m_Filter(that.m_Filter)
0075 {
0076 }
0077
0078
0079
0080 filter(BOOST_RV_REF(filter) that) BOOST_NOEXCEPT : m_Filter(boost::move(that.m_Filter))
0081 {
0082 }
0083
0084
0085
0086
0087 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
0088 template< typename FunT >
0089 filter(FunT&& fun) : m_Filter(boost::forward< FunT >(fun))
0090 {
0091 }
0092 #elif !defined(BOOST_MSVC) || BOOST_MSVC >= 1600
0093 template< typename FunT >
0094 filter(FunT const& fun, typename boost::disable_if_c< move_detail::is_rv< FunT >::value, boost::log::aux::sfinae_dummy >::type = boost::log::aux::sfinae_dummy()) : m_Filter(fun)
0095 {
0096 }
0097 #else
0098
0099 template< typename FunT >
0100 filter(FunT const& fun) : m_Filter(fun)
0101 {
0102 }
0103 template< typename FunT >
0104 filter(rv< FunT >& fun) : m_Filter(fun)
0105 {
0106 }
0107 template< typename FunT >
0108 filter(rv< FunT > const& fun) : m_Filter(static_cast< FunT const& >(fun))
0109 {
0110 }
0111 filter(rv< filter > const& that) : m_Filter(that.m_Filter)
0112 {
0113 }
0114 #endif
0115
0116
0117
0118
0119 filter& operator= (BOOST_RV_REF(filter) that) BOOST_NOEXCEPT
0120 {
0121 m_Filter.swap(that.m_Filter);
0122 return *this;
0123 }
0124
0125
0126
0127 filter& operator= (BOOST_COPY_ASSIGN_REF(filter) that)
0128 {
0129 m_Filter = that.m_Filter;
0130 return *this;
0131 }
0132
0133
0134
0135 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
0136 template< typename FunT >
0137 filter& operator= (FunT const& fun)
0138 #else
0139 template< typename FunT >
0140 typename boost::disable_if_c< is_same< typename remove_cv< FunT >::type, filter >::value, filter& >::type
0141 operator= (FunT const& fun)
0142 #endif
0143 {
0144 filter(fun).swap(*this);
0145 return *this;
0146 }
0147
0148
0149
0150
0151
0152
0153
0154 result_type operator() (attribute_value_set const& values) const
0155 {
0156 return m_Filter(values);
0157 }
0158
0159
0160
0161
0162 void reset()
0163 {
0164 m_Filter = default_filter();
0165 }
0166
0167
0168
0169
0170 void swap(filter& that) BOOST_NOEXCEPT
0171 {
0172 m_Filter.swap(that.m_Filter);
0173 }
0174 };
0175
0176 inline void swap(filter& left, filter& right) BOOST_NOEXCEPT
0177 {
0178 left.swap(right);
0179 }
0180
0181 BOOST_LOG_CLOSE_NAMESPACE
0182
0183 }
0184
0185 #include <boost/log/detail/footer.hpp>
0186
0187 #endif