Chris@16: /* Chris@16: * Copyright Andrey Semashev 2007 - 2013. 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/regex.hpp Chris@16: * \author Andrey Semashev Chris@16: * \date 18.07.2009 Chris@16: * Chris@16: * This header enables Boost.Regex support for Boost.Log. Chris@16: */ Chris@16: Chris@16: #ifndef BOOST_LOG_SUPPORT_REGEX_HPP_INCLUDED_ Chris@16: #define BOOST_LOG_SUPPORT_REGEX_HPP_INCLUDED_ Chris@16: 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@16: //! The trait verifies if the type can be converted to a Boost.Regex expression Chris@16: template< typename T > Chris@16: struct is_regex< T, true > Chris@16: { Chris@16: private: Chris@16: typedef char yes_type; Chris@16: struct no_type { char dummy[2]; }; Chris@16: Chris@16: template< typename CharT, typename TraitsT > Chris@16: static yes_type check_regex(basic_regex< CharT, TraitsT > const&); Chris@16: static no_type check_regex(...); Chris@16: static T& get_T(); Chris@16: Chris@16: public: Chris@16: enum { value = sizeof(check_regex(get_T())) == sizeof(yes_type) }; Chris@16: typedef mpl::bool_< value > type; Chris@16: }; Chris@16: Chris@16: //! The regex matching functor implementation Chris@16: template< > Chris@16: struct matches_fun_impl< boost_regex_expression_tag > Chris@16: { Chris@16: template< typename StringT, typename CharT, typename TraitsT > Chris@16: static bool matches( Chris@16: StringT const& str, Chris@16: basic_regex< CharT, TraitsT > const& expr, Chris@16: match_flag_type flags = match_default) Chris@16: { Chris@16: return boost::regex_match(str.begin(), str.end(), 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_REGEX_HPP_INCLUDED_