]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/log/src/setup/default_filter_factory.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / libs / log / src / setup / default_filter_factory.hpp
CommitLineData
7c673cae
FG
1/*
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)
6 */
7/*!
8 * \file default_filter_factory.hpp
9 * \author Andrey Semashev
10 * \date 29.05.2010
11 *
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.
14 */
15
16#ifndef BOOST_DEFAULT_FILTER_FACTORY_HPP_INCLUDED_
17#define BOOST_DEFAULT_FILTER_FACTORY_HPP_INCLUDED_
18
19#include <boost/log/detail/setup_config.hpp>
20#include <cstddef>
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>
26
27namespace boost {
28
29BOOST_LOG_OPEN_NAMESPACE
30
31namespace aux {
32
33//! Relation predicate wrapper
34template< typename ValueT, typename PredicateT >
35struct predicate_wrapper
36{
37 typedef typename PredicateT::result_type result_type;
38
39 explicit predicate_wrapper(attribute_name const& name, PredicateT const& pred) : m_name(name), m_visitor(pred)
40 {
41 }
42
43 template< typename T >
44 result_type operator() (T const& arg) const
45 {
46 bool res = false;
47 boost::log::visit< ValueT >(m_name, arg, save_result_wrapper< PredicateT const&, bool >(m_visitor, res));
48 return res;
49 }
50
51private:
52 attribute_name m_name;
53 const PredicateT m_visitor;
54};
55
56//! The default filter factory that supports creating filters for the standard types (see utility/type_dispatch/standard_types.hpp)
57template< typename CharT >
58class default_filter_factory :
59 public filter_factory< CharT >
60{
61private:
62 //! Base type
63 typedef filter_factory< CharT > base_type;
64 //! Self type
65 typedef default_filter_factory< CharT > this_type;
66
67public:
68 // Type imports
69 typedef typename base_type::char_type char_type;
70 typedef typename base_type::string_type string_type;
71
72 //! The callback for equality relation filter
20effc67 73 filter on_equality_relation(attribute_name const& name, string_type const& arg) BOOST_OVERRIDE;
7c673cae 74 //! The callback for inequality relation filter
20effc67 75 filter on_inequality_relation(attribute_name const& name, string_type const& arg) BOOST_OVERRIDE;
7c673cae 76 //! The callback for less relation filter
20effc67 77 filter on_less_relation(attribute_name const& name, string_type const& arg) BOOST_OVERRIDE;
7c673cae 78 //! The callback for greater relation filter
20effc67 79 filter on_greater_relation(attribute_name const& name, string_type const& arg) BOOST_OVERRIDE;
7c673cae 80 //! The callback for less or equal relation filter
20effc67 81 filter on_less_or_equal_relation(attribute_name const& name, string_type const& arg) BOOST_OVERRIDE;
7c673cae 82 //! The callback for greater or equal relation filter
20effc67 83 filter on_greater_or_equal_relation(attribute_name const& name, string_type const& arg) BOOST_OVERRIDE;
7c673cae
FG
84
85 //! The callback for custom relation filter
20effc67 86 filter on_custom_relation(attribute_name const& name, string_type const& rel, string_type const& arg) BOOST_OVERRIDE;
7c673cae
FG
87
88private:
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);
92};
93
94//! The function parses the "matches" relation
95template< typename CharT >
96filter parse_matches_relation(attribute_name const& name, std::basic_string< CharT > const& operand);
97
98} // namespace aux
99
100BOOST_LOG_CLOSE_NAMESPACE // namespace log
101
102} // namespace boost
103
104#include <boost/log/detail/footer.hpp>
105
106#endif // BOOST_DEFAULT_FILTER_FACTORY_HPP_INCLUDED_