annotate DEPENDENCIES/generic/include/boost/log/expressions/predicates/matches.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 /*
Chris@101 2 * Copyright Andrey Semashev 2007 - 2015.
Chris@16 3 * Distributed under the Boost Software License, Version 1.0.
Chris@16 4 * (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 5 * http://www.boost.org/LICENSE_1_0.txt)
Chris@16 6 */
Chris@16 7 /*!
Chris@16 8 * \file matches.hpp
Chris@16 9 * \author Andrey Semashev
Chris@16 10 * \date 02.09.2012
Chris@16 11 *
Chris@16 12 * The header contains implementation of a \c matches predicate in template expressions.
Chris@16 13 */
Chris@16 14
Chris@16 15 #ifndef BOOST_LOG_EXPRESSIONS_PREDICATES_MATCHES_HPP_INCLUDED_
Chris@16 16 #define BOOST_LOG_EXPRESSIONS_PREDICATES_MATCHES_HPP_INCLUDED_
Chris@16 17
Chris@16 18 #include <boost/phoenix/core/actor.hpp>
Chris@16 19 #include <boost/log/detail/config.hpp>
Chris@16 20 #include <boost/log/detail/unary_function_terminal.hpp>
Chris@16 21 #include <boost/log/detail/attribute_predicate.hpp>
Chris@16 22 #include <boost/log/expressions/attr_fwd.hpp>
Chris@16 23 #include <boost/log/expressions/keyword_fwd.hpp>
Chris@16 24 #include <boost/log/attributes/attribute_name.hpp>
Chris@16 25 #include <boost/log/attributes/fallback_policy.hpp>
Chris@16 26 #include <boost/log/utility/functional/matches.hpp>
Chris@16 27 #include <boost/log/detail/header.hpp>
Chris@16 28
Chris@16 29 #ifdef BOOST_HAS_PRAGMA_ONCE
Chris@16 30 #pragma once
Chris@16 31 #endif
Chris@16 32
Chris@16 33 namespace boost {
Chris@16 34
Chris@16 35 BOOST_LOG_OPEN_NAMESPACE
Chris@16 36
Chris@16 37 namespace expressions {
Chris@16 38
Chris@16 39 /*!
Chris@16 40 * The predicate checks if the attribute value matches a regular expression. The attribute value is assumed to be of a string type.
Chris@16 41 */
Chris@16 42 template< typename T, typename RegexT, typename FallbackPolicyT = fallback_to_none >
Chris@16 43 class attribute_matches :
Chris@101 44 public aux::attribute_predicate< T, typename boost::log::aux::match_traits< RegexT >::compiled_type, matches_fun, FallbackPolicyT >
Chris@16 45 {
Chris@101 46 typedef aux::attribute_predicate< T, typename boost::log::aux::match_traits< RegexT >::compiled_type, matches_fun, FallbackPolicyT > base_type;
Chris@16 47
Chris@16 48 public:
Chris@16 49 /*!
Chris@16 50 * Initializing constructor
Chris@16 51 *
Chris@16 52 * \param name Attribute name
Chris@16 53 * \param rex The regular expression to match the attribute value against
Chris@16 54 */
Chris@101 55 attribute_matches(attribute_name const& name, RegexT const& rex) : base_type(name, boost::log::aux::match_traits< RegexT >::compile(rex))
Chris@16 56 {
Chris@16 57 }
Chris@16 58
Chris@16 59 /*!
Chris@16 60 * Initializing constructor
Chris@16 61 *
Chris@16 62 * \param name Attribute name
Chris@16 63 * \param rex The regular expression to match the attribute value against
Chris@16 64 * \param arg Additional parameter for the fallback policy
Chris@16 65 */
Chris@16 66 template< typename U >
Chris@101 67 attribute_matches(attribute_name const& name, RegexT const& rex, U const& arg) : base_type(name, boost::log::aux::match_traits< RegexT >::compile(rex), arg)
Chris@16 68 {
Chris@16 69 }
Chris@16 70 };
Chris@16 71
Chris@16 72 /*!
Chris@16 73 * The function generates a terminal node in a template expression. The node will check if the attribute value,
Chris@16 74 * which is assumed to be a string, matches the specified regular expression.
Chris@16 75 */
Chris@16 76 template< typename T, typename FallbackPolicyT, typename TagT, template< typename > class ActorT, typename RegexT >
Chris@16 77 BOOST_FORCEINLINE ActorT< aux::unary_function_terminal< attribute_matches< T, RegexT, FallbackPolicyT > > >
Chris@16 78 matches(attribute_actor< T, FallbackPolicyT, TagT, ActorT > const& attr, RegexT const& rex)
Chris@16 79 {
Chris@16 80 typedef aux::unary_function_terminal< attribute_matches< T, RegexT, FallbackPolicyT > > terminal_type;
Chris@16 81 ActorT< terminal_type > act = {{ terminal_type(attr.get_name(), rex, attr.get_fallback_policy()) }};
Chris@16 82 return act;
Chris@16 83 }
Chris@16 84
Chris@16 85 /*!
Chris@16 86 * The function generates a terminal node in a template expression. The node will check if the attribute value,
Chris@16 87 * which is assumed to be a string, matches the specified regular expression.
Chris@16 88 */
Chris@16 89 template< typename DescriptorT, template< typename > class ActorT, typename RegexT >
Chris@16 90 BOOST_FORCEINLINE ActorT< aux::unary_function_terminal< attribute_matches< typename DescriptorT::value_type, RegexT > > >
Chris@16 91 matches(attribute_keyword< DescriptorT, ActorT > const&, RegexT const& rex)
Chris@16 92 {
Chris@16 93 typedef aux::unary_function_terminal< attribute_matches< typename DescriptorT::value_type, RegexT > > terminal_type;
Chris@16 94 ActorT< terminal_type > act = {{ terminal_type(DescriptorT::get_name(), rex) }};
Chris@16 95 return act;
Chris@16 96 }
Chris@16 97
Chris@16 98 /*!
Chris@16 99 * The function generates a terminal node in a template expression. The node will check if the attribute value,
Chris@16 100 * which is assumed to be a string, matches the specified regular expression.
Chris@16 101 */
Chris@16 102 template< typename T, typename RegexT >
Chris@16 103 BOOST_FORCEINLINE phoenix::actor< aux::unary_function_terminal< attribute_matches< T, RegexT > > >
Chris@16 104 matches(attribute_name const& name, RegexT const& rex)
Chris@16 105 {
Chris@16 106 typedef aux::unary_function_terminal< attribute_matches< T, RegexT > > terminal_type;
Chris@16 107 phoenix::actor< terminal_type > act = {{ terminal_type(name, rex) }};
Chris@16 108 return act;
Chris@16 109 }
Chris@16 110
Chris@16 111 } // namespace expressions
Chris@16 112
Chris@16 113 BOOST_LOG_CLOSE_NAMESPACE // namespace log
Chris@16 114
Chris@16 115 } // namespace boost
Chris@16 116
Chris@16 117 #include <boost/log/detail/footer.hpp>
Chris@16 118
Chris@16 119 #endif // BOOST_LOG_EXPRESSIONS_PREDICATES_MATCHES_HPP_INCLUDED_