File indexing completed on 2025-01-30 09:45:08
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef BOOST_LOG_SUPPORT_SPIRIT_CLASSIC_HPP_INCLUDED_
0016 #define BOOST_LOG_SUPPORT_SPIRIT_CLASSIC_HPP_INCLUDED_
0017
0018 #include <boost/mpl/bool.hpp>
0019 #include <boost/core/enable_if.hpp>
0020 #include <boost/log/detail/config.hpp>
0021 #include <boost/log/utility/functional/matches.hpp>
0022
0023 #ifdef BOOST_HAS_PRAGMA_ONCE
0024 #pragma once
0025 #endif
0026
0027 #if !defined(BOOST_LOG_NO_THREADS) && !defined(BOOST_SPIRIT_THREADSAFE) && !defined(BOOST_LOG_DOXYGEN_PASS)
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041 #if defined(__GNUC__)
0042 #pragma message "Boost.Log: Boost.Spirit requires BOOST_SPIRIT_THREADSAFE macro to be defined if parsers are used in a multithreaded context. It is strongly recommended to define this macro project-wide."
0043 #elif defined(_MSC_VER)
0044 #pragma message("Boost.Log: Boost.Spirit requires BOOST_SPIRIT_THREADSAFE macro to be defined if parsers are used in a multithreaded context. It is strongly recommended to define this macro project-wide.")
0045 #endif
0046 #define BOOST_SPIRIT_THREADSAFE 1
0047 #endif
0048
0049 #include <boost/spirit/include/classic_parser.hpp>
0050
0051 #include <boost/log/detail/header.hpp>
0052
0053 namespace boost {
0054
0055 BOOST_LOG_OPEN_NAMESPACE
0056
0057 namespace aux {
0058
0059
0060 struct boost_spirit_classic_expression_tag;
0061
0062
0063 template< typename T >
0064 struct is_spirit_classic_parser
0065 {
0066 private:
0067 typedef char yes_type;
0068 struct no_type { char dummy[2]; };
0069
0070 template< typename U >
0071 static yes_type check_spirit_classic_parser(spirit::classic::parser< U > const&);
0072 static no_type check_spirit_classic_parser(...);
0073 static T& get_T();
0074
0075 public:
0076 enum { value = sizeof(check_spirit_classic_parser(get_T())) == sizeof(yes_type) };
0077 typedef mpl::bool_< value > type;
0078 };
0079
0080
0081 template< typename ExpressionT >
0082 struct matching_expression_kind< ExpressionT, typename boost::enable_if_c< is_spirit_classic_parser< ExpressionT >::value >::type >
0083 {
0084 typedef boost_spirit_classic_expression_tag type;
0085 };
0086
0087
0088 template< typename ExpressionT >
0089 struct match_traits< ExpressionT, boost_spirit_classic_expression_tag >
0090 {
0091 typedef ExpressionT compiled_type;
0092 static compiled_type compile(ExpressionT const& expr) { return expr; }
0093
0094 template< typename StringT >
0095 static bool matches(StringT const& str, ExpressionT const& expr)
0096 {
0097 typedef typename StringT::const_iterator const_iterator;
0098 spirit::classic::parse_info< const_iterator > info =
0099 spirit::classic::parse(str.begin(), str.end(), expr);
0100 return info.full;
0101 }
0102 };
0103
0104 }
0105
0106 BOOST_LOG_CLOSE_NAMESPACE
0107
0108 }
0109
0110 #include <boost/log/detail/footer.hpp>
0111
0112 #endif