matches.hpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. #ifndef BOOST_LOG_UTILITY_FUNCTIONAL_MATCHES_HPP_INCLUDED_
  15. #define BOOST_LOG_UTILITY_FUNCTIONAL_MATCHES_HPP_INCLUDED_
  16. #include <boost/log/detail/config.hpp>
  17. #include <boost/log/detail/header.hpp>
  18. #ifdef BOOST_HAS_PRAGMA_ONCE
  19. #pragma once
  20. #endif
  21. namespace boost {
  22. BOOST_LOG_OPEN_NAMESPACE
  23. namespace aux {
  24. //! The metafunction detects the matching expression kind and returns a tag that is used to specialize \c match_traits
  25. template< typename ExpressionT, typename = void >
  26. struct matching_expression_kind;
  27. //! The matching function implementation
  28. template< typename ExpressionT, typename TagT = typename matching_expression_kind< ExpressionT >::type >
  29. struct match_traits;
  30. } // namespace aux
  31. //! The regex matching functor
  32. struct matches_fun
  33. {
  34. typedef bool result_type;
  35. template< typename StringT, typename ExpressionT >
  36. bool operator() (StringT const& str, ExpressionT const& expr) const
  37. {
  38. typedef aux::match_traits< ExpressionT > impl;
  39. return impl::matches(str, expr);
  40. }
  41. template< typename StringT, typename ExpressionT, typename ArgT >
  42. bool operator() (StringT const& str, ExpressionT const& expr, ArgT const& arg) const
  43. {
  44. typedef aux::match_traits< ExpressionT > impl;
  45. return impl::matches(str, expr, arg);
  46. }
  47. };
  48. BOOST_LOG_CLOSE_NAMESPACE // namespace log
  49. } // namespace boost
  50. #include <boost/log/detail/footer.hpp>
  51. #endif // BOOST_LOG_UTILITY_FUNCTIONAL_MATCHES_HPP_INCLUDED_