Chris@16: /* Chris@101: * Copyright Andrey Semashev 2007 - 2015. Chris@16: * Distributed under the Boost Software License, Version 1.0. Chris@16: * (See accompanying file LICENSE_1_0.txt or copy at Chris@16: * http://www.boost.org/LICENSE_1_0.txt) Chris@16: */ Chris@16: /*! Chris@16: * \file support/xpressive.hpp Chris@16: * \author Andrey Semashev Chris@16: * \date 18.07.2009 Chris@16: * Chris@16: * This header enables Boost.Xpressive support for Boost.Log. Chris@16: */ Chris@16: Chris@16: #ifndef BOOST_LOG_SUPPORT_XPRESSIVE_HPP_INCLUDED_ Chris@16: #define BOOST_LOG_SUPPORT_XPRESSIVE_HPP_INCLUDED_ Chris@16: Chris@101: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: #ifdef BOOST_HAS_PRAGMA_ONCE Chris@16: #pragma once Chris@16: #endif Chris@16: Chris@16: namespace boost { Chris@16: Chris@16: BOOST_LOG_OPEN_NAMESPACE Chris@16: Chris@16: namespace aux { Chris@16: Chris@101: //! This tag type is used if an expression is recognized as a Boost.Xpressive expression Chris@101: struct boost_xpressive_expression_tag; Chris@101: Chris@101: //! The metafunction detects the matching expression kind and returns a tag that is used to specialize \c match_traits Chris@16: template< typename T > Chris@101: struct matching_expression_kind< xpressive::basic_regex< T > > Chris@16: { Chris@101: typedef boost_xpressive_expression_tag type; Chris@16: }; Chris@16: Chris@101: //! The matching function implementation Chris@101: template< typename ExpressionT > Chris@101: struct match_traits< ExpressionT, boost_xpressive_expression_tag > Chris@16: { Chris@101: typedef ExpressionT compiled_type; Chris@101: static compiled_type compile(ExpressionT const& expr) { return expr; } Chris@101: Chris@16: template< typename StringT, typename T > Chris@101: static bool matches(StringT const& str, xpressive::basic_regex< T > const& expr, xpressive::regex_constants::match_flag_type flags = xpressive::regex_constants::match_default) Chris@16: { Chris@16: return xpressive::regex_match(str, expr, flags); Chris@16: } Chris@16: Chris@101: template< typename CharT, typename TraitsT, typename AllocatorT > Chris@101: 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) Chris@16: { Chris@101: const CharT* p = str.c_str(); Chris@101: return xpressive::regex_match(p, p + str.size(), expr, flags); Chris@16: } Chris@16: }; Chris@16: Chris@16: } // namespace aux Chris@16: Chris@16: BOOST_LOG_CLOSE_NAMESPACE // namespace log Chris@16: Chris@16: } // namespace boost Chris@16: Chris@16: #include Chris@16: Chris@16: #endif // BOOST_LOG_SUPPORT_XPRESSIVE_HPP_INCLUDED_