Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-25 09:46:54

0001 /*
0002  *          Copyright Andrey Semashev 2007 - 2015.
0003  * Distributed under the Boost Software License, Version 1.0.
0004  *    (See accompanying file LICENSE_1_0.txt or copy at
0005  *          http://www.boost.org/LICENSE_1_0.txt)
0006  */
0007 /*!
0008  * \file   support/xpressive.hpp
0009  * \author Andrey Semashev
0010  * \date   18.07.2009
0011  *
0012  * This header enables Boost.Xpressive support for Boost.Log.
0013  */
0014 
0015 #ifndef BOOST_LOG_SUPPORT_XPRESSIVE_HPP_INCLUDED_
0016 #define BOOST_LOG_SUPPORT_XPRESSIVE_HPP_INCLUDED_
0017 
0018 #include <string>
0019 #include <boost/xpressive/basic_regex.hpp>
0020 #include <boost/xpressive/regex_constants.hpp>
0021 #include <boost/xpressive/regex_algorithms.hpp>
0022 #include <boost/log/detail/config.hpp>
0023 #include <boost/log/utility/functional/matches.hpp>
0024 #include <boost/log/detail/header.hpp>
0025 
0026 #ifdef BOOST_HAS_PRAGMA_ONCE
0027 #pragma once
0028 #endif
0029 
0030 namespace boost {
0031 
0032 BOOST_LOG_OPEN_NAMESPACE
0033 
0034 namespace aux {
0035 
0036 //! This tag type is used if an expression is recognized as a Boost.Xpressive expression
0037 struct boost_xpressive_expression_tag;
0038 
0039 //! The metafunction detects the matching expression kind and returns a tag that is used to specialize \c match_traits
0040 template< typename T >
0041 struct matching_expression_kind< xpressive::basic_regex< T > >
0042 {
0043     typedef boost_xpressive_expression_tag type;
0044 };
0045 
0046 //! The matching function implementation
0047 template< typename ExpressionT >
0048 struct match_traits< ExpressionT, boost_xpressive_expression_tag >
0049 {
0050     typedef ExpressionT compiled_type;
0051     static compiled_type compile(ExpressionT const& expr) { return expr; }
0052 
0053     template< typename StringT, typename T >
0054     static bool matches(StringT const& str, xpressive::basic_regex< T > const& expr, xpressive::regex_constants::match_flag_type flags = xpressive::regex_constants::match_default)
0055     {
0056         return xpressive::regex_match(str, expr, flags);
0057     }
0058 
0059     template< typename CharT, typename TraitsT, typename AllocatorT >
0060     static bool matches(std::basic_string< CharT, TraitsT, AllocatorT > const& str, xpressive::basic_regex< const CharT* > const& expr, xpressive::regex_constants::match_flag_type flags = xpressive::regex_constants::match_default)
0061     {
0062         const CharT* p = str.c_str();
0063         return xpressive::regex_match(p, p + str.size(), expr, flags);
0064     }
0065 };
0066 
0067 } // namespace aux
0068 
0069 BOOST_LOG_CLOSE_NAMESPACE // namespace log
0070 
0071 } // namespace boost
0072 
0073 #include <boost/log/detail/footer.hpp>
0074 
0075 #endif // BOOST_LOG_SUPPORT_XPRESSIVE_HPP_INCLUDED_