]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/log/include/boost/log/expressions/predicates/contains.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / log / include / boost / log / expressions / predicates / contains.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 contains.hpp
9 * \author Andrey Semashev
10 * \date 02.09.2012
11 *
12 * The header contains implementation of a \c contains predicate in template expressions.
13 */
14
15#ifndef BOOST_LOG_EXPRESSIONS_PREDICATES_CONTAINS_HPP_INCLUDED_
16#define BOOST_LOG_EXPRESSIONS_PREDICATES_CONTAINS_HPP_INCLUDED_
17
18#include <boost/phoenix/core/actor.hpp>
19#include <boost/log/detail/config.hpp>
20#include <boost/log/detail/embedded_string_type.hpp>
21#include <boost/log/detail/unary_function_terminal.hpp>
22#include <boost/log/detail/attribute_predicate.hpp>
23#include <boost/log/expressions/attr_fwd.hpp>
24#include <boost/log/expressions/keyword_fwd.hpp>
25#include <boost/log/attributes/attribute_name.hpp>
26#include <boost/log/attributes/fallback_policy.hpp>
27#include <boost/log/utility/functional/contains.hpp>
28#include <boost/log/detail/header.hpp>
29
30#ifdef BOOST_HAS_PRAGMA_ONCE
31#pragma once
32#endif
33
34namespace boost {
35
36BOOST_LOG_OPEN_NAMESPACE
37
38namespace expressions {
39
40/*!
41 * The predicate checks if the attribute value contains a substring. The attribute value is assumed to be of a string type.
42 */
43#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
44
45template< typename T, typename SubstringT, typename FallbackPolicyT = fallback_to_none >
46using attribute_contains = aux::attribute_predicate< T, SubstringT, contains_fun, FallbackPolicyT >;
47
48#else // !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
49
50template< typename T, typename SubstringT, typename FallbackPolicyT = fallback_to_none >
51class attribute_contains :
52 public aux::attribute_predicate< T, SubstringT, contains_fun, FallbackPolicyT >
53{
54 typedef aux::attribute_predicate< T, SubstringT, contains_fun, FallbackPolicyT > base_type;
55
56public:
57 /*!
58 * Initializing constructor
59 *
60 * \param name Attribute name
61 * \param substring The expected attribute value substring
62 */
63 attribute_contains(attribute_name const& name, SubstringT const& substring) : base_type(name, substring)
64 {
65 }
66
67 /*!
68 * Initializing constructor
69 *
70 * \param name Attribute name
71 * \param substring The expected attribute value substring
72 * \param arg Additional parameter for the fallback policy
73 */
74 template< typename U >
75 attribute_contains(attribute_name const& name, SubstringT const& substring, U const& arg) : base_type(name, substring, arg)
76 {
77 }
78};
79
80#endif // !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
81
82/*!
83 * The function generates a terminal node in a template expression. The node will check if the attribute value,
84 * which is assumed to be a string, contains the specified substring.
85 */
86template< typename T, typename FallbackPolicyT, typename TagT, template< typename > class ActorT, typename SubstringT >
87BOOST_FORCEINLINE ActorT< aux::unary_function_terminal< attribute_contains< T, typename boost::log::aux::make_embedded_string_type< SubstringT >::type, FallbackPolicyT > > >
88contains(attribute_actor< T, FallbackPolicyT, TagT, ActorT > const& attr, SubstringT const& substring)
89{
90 typedef aux::unary_function_terminal< attribute_contains< T, typename boost::log::aux::make_embedded_string_type< SubstringT >::type, FallbackPolicyT > > terminal_type;
91 ActorT< terminal_type > act = {{ terminal_type(attr.get_name(), substring, attr.get_fallback_policy()) }};
92 return act;
93}
94
95/*!
96 * The function generates a terminal node in a template expression. The node will check if the attribute value,
97 * which is assumed to be a string, contains the specified substring.
98 */
99template< typename DescriptorT, template< typename > class ActorT, typename SubstringT >
100BOOST_FORCEINLINE ActorT< aux::unary_function_terminal< attribute_contains< typename DescriptorT::value_type, typename boost::log::aux::make_embedded_string_type< SubstringT >::type > > >
101contains(attribute_keyword< DescriptorT, ActorT > const&, SubstringT const& substring)
102{
103 typedef aux::unary_function_terminal< attribute_contains< typename DescriptorT::value_type, typename boost::log::aux::make_embedded_string_type< SubstringT >::type > > terminal_type;
104 ActorT< terminal_type > act = {{ terminal_type(DescriptorT::get_name(), substring) }};
105 return act;
106}
107
108/*!
109 * The function generates a terminal node in a template expression. The node will check if the attribute value,
110 * which is assumed to be a string, contains the specified substring.
111 */
112template< typename T, typename SubstringT >
113BOOST_FORCEINLINE phoenix::actor< aux::unary_function_terminal< attribute_contains< T, typename boost::log::aux::make_embedded_string_type< SubstringT >::type > > >
114contains(attribute_name const& name, SubstringT const& substring)
115{
116 typedef aux::unary_function_terminal< attribute_contains< T, typename boost::log::aux::make_embedded_string_type< SubstringT >::type > > terminal_type;
117 phoenix::actor< terminal_type > act = {{ terminal_type(name, substring) }};
118 return act;
119}
120
121} // namespace expressions
122
123BOOST_LOG_CLOSE_NAMESPACE // namespace log
124
125} // namespace boost
126
127#include <boost/log/detail/footer.hpp>
128
129#endif // BOOST_LOG_EXPRESSIONS_PREDICATES_CONTAINS_HPP_INCLUDED_