annotate DEPENDENCIES/generic/include/boost/log/support/spirit_classic.hpp @ 86:413a9d26189e

Handle VamPy plugins
author Chris Cannam
date Tue, 24 Feb 2015 18:00:31 +0000
parents 2665513ce2d3
children c530137014c0
rev   line source
Chris@16 1 /*
Chris@16 2 * Copyright Andrey Semashev 2007 - 2013.
Chris@16 3 * Distributed under the Boost Software License, Version 1.0.
Chris@16 4 * (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 5 * http://www.boost.org/LICENSE_1_0.txt)
Chris@16 6 */
Chris@16 7 /*!
Chris@16 8 * \file support/spirit_classic.hpp
Chris@16 9 * \author Andrey Semashev
Chris@16 10 * \date 19.07.2009
Chris@16 11 *
Chris@16 12 * This header enables Boost.Spirit (classic) support for Boost.Log.
Chris@16 13 */
Chris@16 14
Chris@16 15 #ifndef BOOST_LOG_SUPPORT_SPIRIT_CLASSIC_HPP_INCLUDED_
Chris@16 16 #define BOOST_LOG_SUPPORT_SPIRIT_CLASSIC_HPP_INCLUDED_
Chris@16 17
Chris@16 18 #include <boost/mpl/bool.hpp>
Chris@16 19 #include <boost/log/detail/config.hpp>
Chris@16 20 #include <boost/log/utility/functional/matches.hpp>
Chris@16 21
Chris@16 22 #ifdef BOOST_HAS_PRAGMA_ONCE
Chris@16 23 #pragma once
Chris@16 24 #endif
Chris@16 25
Chris@16 26 #if !defined(BOOST_LOG_NO_THREADS) && !defined(BOOST_SPIRIT_THREADSAFE) && !defined(BOOST_LOG_DOXYGEN_PASS)
Chris@16 27 /*
Chris@16 28 * As Boost.Log filters may be called in multiple threads concurrently,
Chris@16 29 * this may lead to using Boost.Spirit parsers in a multithreaded context.
Chris@16 30 * In order to protect parsers properly, BOOST_SPIRIT_THREADSAFE macro should
Chris@16 31 * be defined.
Chris@16 32 *
Chris@16 33 * If we got here, it means that the user did not define that macro and we
Chris@16 34 * have to define it ourselves. However, it may also lead to ODR violations
Chris@16 35 * or even total ignorance of this macro, if the user has included Boost.Spirit
Chris@16 36 * headers before including this header, or uses Boost.Spirit without the macro
Chris@16 37 * in other translation units. The only reliable way to settle this problem is to
Chris@16 38 * define the macro for the whole project (i.e. all translation units).
Chris@16 39 */
Chris@16 40 #warning 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.
Chris@16 41 #define BOOST_SPIRIT_THREADSAFE 1
Chris@16 42 #endif // !defined(BOOST_LOG_NO_THREADS) && !defined(BOOST_SPIRIT_THREADSAFE)
Chris@16 43
Chris@16 44 #include <boost/spirit/include/classic_parser.hpp>
Chris@16 45
Chris@16 46 #include <boost/log/detail/header.hpp>
Chris@16 47
Chris@16 48 namespace boost {
Chris@16 49
Chris@16 50 BOOST_LOG_OPEN_NAMESPACE
Chris@16 51
Chris@16 52 namespace aux {
Chris@16 53
Chris@16 54 //! The trait verifies if the type can be converted to a Boost.Spirit (classic) parser
Chris@16 55 template< typename T >
Chris@16 56 struct is_spirit_classic_parser< T, true >
Chris@16 57 {
Chris@16 58 private:
Chris@16 59 typedef char yes_type;
Chris@16 60 struct no_type { char dummy[2]; };
Chris@16 61
Chris@16 62 template< typename U >
Chris@16 63 static yes_type check_spirit_classic_parser(spirit::classic::parser< U > const&);
Chris@16 64 static no_type check_spirit_classic_parser(...);
Chris@16 65 static T& get_T();
Chris@16 66
Chris@16 67 public:
Chris@16 68 enum { value = sizeof(check_spirit_classic_parser(get_T())) == sizeof(yes_type) };
Chris@16 69 typedef mpl::bool_< value > type;
Chris@16 70 };
Chris@16 71
Chris@16 72 //! The matching functor implementation
Chris@16 73 template< >
Chris@16 74 struct matches_fun_impl< boost_spirit_classic_expression_tag >
Chris@16 75 {
Chris@16 76 template< typename StringT, typename ParserT >
Chris@16 77 static bool matches(
Chris@16 78 StringT const& str,
Chris@16 79 ParserT const& expr)
Chris@16 80 {
Chris@16 81 typedef typename StringT::const_iterator const_iterator;
Chris@16 82 spirit::classic::parse_info< const_iterator > info =
Chris@16 83 spirit::classic::parse(str.begin(), str.end(), expr);
Chris@16 84 return info.full;
Chris@16 85 }
Chris@16 86 };
Chris@16 87
Chris@16 88 } // namespace aux
Chris@16 89
Chris@16 90 BOOST_LOG_CLOSE_NAMESPACE // namespace log
Chris@16 91
Chris@16 92 } // namespace boost
Chris@16 93
Chris@16 94 #include <boost/log/detail/footer.hpp>
Chris@16 95
Chris@16 96 #endif // BOOST_LOG_SUPPORT_SPIRIT_CLASSIC_HPP_INCLUDED_