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