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 matches.hpp 9 * \author Andrey Semashev 10 * \date 30.03.2008 11 * 12 * This header contains a predicate for checking if the provided string matches a regular expression. 13 */ 14 15 #ifndef BOOST_LOG_UTILITY_FUNCTIONAL_MATCHES_HPP_INCLUDED_ 16 #define BOOST_LOG_UTILITY_FUNCTIONAL_MATCHES_HPP_INCLUDED_ 17 18 #include <boost/log/detail/config.hpp> 19 #include <boost/log/detail/header.hpp> 20 21 #ifdef BOOST_HAS_PRAGMA_ONCE 22 #pragma once 23 #endif 24 25 namespace boost { 26 27 BOOST_LOG_OPEN_NAMESPACE 28 29 namespace aux { 30 31 //! The metafunction detects the matching expression kind and returns a tag that is used to specialize \c match_traits 32 template< typename ExpressionT, typename = void > 33 struct matching_expression_kind; 34 35 //! The matching function implementation 36 template< typename ExpressionT, typename TagT = typename matching_expression_kind< ExpressionT >::type > 37 struct match_traits; 38 39 } // namespace aux 40 41 //! The regex matching functor 42 struct matches_fun 43 { 44 typedef bool result_type; 45 46 template< typename StringT, typename ExpressionT > operator ()boost::matches_fun47 bool operator() (StringT const& str, ExpressionT const& expr) const 48 { 49 typedef aux::match_traits< ExpressionT > impl; 50 return impl::matches(str, expr); 51 } 52 template< typename StringT, typename ExpressionT, typename ArgT > operator ()boost::matches_fun53 bool operator() (StringT const& str, ExpressionT const& expr, ArgT const& arg) const 54 { 55 typedef aux::match_traits< ExpressionT > impl; 56 return impl::matches(str, expr, arg); 57 } 58 }; 59 60 BOOST_LOG_CLOSE_NAMESPACE // namespace log 61 62 } // namespace boost 63 64 #include <boost/log/detail/footer.hpp> 65 66 #endif // BOOST_LOG_UTILITY_FUNCTIONAL_MATCHES_HPP_INCLUDED_ 67