2 * Copyright Andrey Semashev 2007 - 2015.
3 * Distributed under the Boost Software License, Version 1.0.
4 * (See accompanying file LICENSE_1_0.txt or copy at
5 * http://www.boost.org/LICENSE_1_0.txt)
8 * \file default_filter_factory.hpp
9 * \author Andrey Semashev
12 * \brief This header is the Boost.Log library implementation, see the library documentation
13 * at http://www.boost.org/doc/libs/release/libs/log/doc/html/index.html.
16 #ifndef BOOST_DEFAULT_FILTER_FACTORY_HPP_INCLUDED_
17 #define BOOST_DEFAULT_FILTER_FACTORY_HPP_INCLUDED_
19 #include <boost/log/detail/setup_config.hpp>
21 #include <boost/log/attributes/attribute_name.hpp>
22 #include <boost/log/attributes/value_visitation.hpp>
23 #include <boost/log/utility/setup/filter_parser.hpp>
24 #include <boost/log/utility/functional/save_result.hpp>
25 #include <boost/log/detail/header.hpp>
29 BOOST_LOG_OPEN_NAMESPACE
33 //! Relation predicate wrapper
34 template< typename ValueT, typename PredicateT >
35 struct predicate_wrapper
37 typedef typename PredicateT::result_type result_type;
39 explicit predicate_wrapper(attribute_name const& name, PredicateT const& pred) : m_name(name), m_visitor(pred)
43 template< typename T >
44 result_type operator() (T const& arg) const
47 boost::log::visit< ValueT >(m_name, arg, save_result_wrapper< PredicateT const&, bool >(m_visitor, res));
52 attribute_name m_name;
53 const PredicateT m_visitor;
56 //! The default filter factory that supports creating filters for the standard types (see utility/type_dispatch/standard_types.hpp)
57 template< typename CharT >
58 class default_filter_factory :
59 public filter_factory< CharT >
63 typedef filter_factory< CharT > base_type;
65 typedef default_filter_factory< CharT > this_type;
69 typedef typename base_type::char_type char_type;
70 typedef typename base_type::string_type string_type;
72 //! The callback for equality relation filter
73 virtual filter on_equality_relation(attribute_name const& name, string_type const& arg);
74 //! The callback for inequality relation filter
75 virtual filter on_inequality_relation(attribute_name const& name, string_type const& arg);
76 //! The callback for less relation filter
77 virtual filter on_less_relation(attribute_name const& name, string_type const& arg);
78 //! The callback for greater relation filter
79 virtual filter on_greater_relation(attribute_name const& name, string_type const& arg);
80 //! The callback for less or equal relation filter
81 virtual filter on_less_or_equal_relation(attribute_name const& name, string_type const& arg);
82 //! The callback for greater or equal relation filter
83 virtual filter on_greater_or_equal_relation(attribute_name const& name, string_type const& arg);
85 //! The callback for custom relation filter
86 virtual filter on_custom_relation(attribute_name const& name, string_type const& rel, string_type const& arg);
89 //! The function parses the argument value for a binary relation and constructs the corresponding filter
90 template< typename RelationT >
91 static filter parse_argument(attribute_name const& name, string_type const& arg);
94 //! The function parses the "matches" relation
95 template< typename CharT >
96 filter parse_matches_relation(attribute_name const& name, std::basic_string< CharT > const& operand);
100 BOOST_LOG_CLOSE_NAMESPACE // namespace log
104 #include <boost/log/detail/footer.hpp>
106 #endif // BOOST_DEFAULT_FILTER_FACTORY_HPP_INCLUDED_