Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/log/support/spirit_qi.hpp @ 101:c530137014c0
Update Boost headers (1.58.0)
author | Chris Cannam |
---|---|
date | Mon, 07 Sep 2015 11:12:49 +0100 |
parents | 2665513ce2d3 |
children |
comparison
equal
deleted
inserted
replaced
100:793467b5e61c | 101:c530137014c0 |
---|---|
1 /* | 1 /* |
2 * Copyright Andrey Semashev 2007 - 2013. | 2 * Copyright Andrey Semashev 2007 - 2015. |
3 * Distributed under the Boost Software License, Version 1.0. | 3 * Distributed under the Boost Software License, Version 1.0. |
4 * (See accompanying file LICENSE_1_0.txt or copy at | 4 * (See accompanying file LICENSE_1_0.txt or copy at |
5 * http://www.boost.org/LICENSE_1_0.txt) | 5 * http://www.boost.org/LICENSE_1_0.txt) |
6 */ | 6 */ |
7 /*! | 7 /*! |
13 */ | 13 */ |
14 | 14 |
15 #ifndef BOOST_LOG_SUPPORT_SPIRIT_QI_HPP_INCLUDED_ | 15 #ifndef BOOST_LOG_SUPPORT_SPIRIT_QI_HPP_INCLUDED_ |
16 #define BOOST_LOG_SUPPORT_SPIRIT_QI_HPP_INCLUDED_ | 16 #define BOOST_LOG_SUPPORT_SPIRIT_QI_HPP_INCLUDED_ |
17 | 17 |
18 #include <boost/utility/enable_if.hpp> | |
19 #include <boost/spirit/include/qi_parse.hpp> | |
20 #include <boost/spirit/include/qi_domain.hpp> | |
21 #include <boost/spirit/include/support_unused.hpp> | |
22 #include <boost/spirit/home/support/meta_compiler.hpp> // spirit::compile() | |
23 #include <boost/spirit/home/qi/nonterminal/nonterminal_fwd.hpp> // rule forward declaration | |
18 #include <boost/log/detail/config.hpp> | 24 #include <boost/log/detail/config.hpp> |
19 #include <boost/log/utility/functional/matches.hpp> | 25 #include <boost/log/utility/functional/matches.hpp> |
20 #include <boost/spirit/include/qi_parse.hpp> | |
21 #include <boost/spirit/include/qi_domain.hpp> | |
22 #include <boost/spirit/include/support_component.hpp> | |
23 #include <boost/log/detail/header.hpp> | 26 #include <boost/log/detail/header.hpp> |
24 | 27 |
25 #ifdef BOOST_HAS_PRAGMA_ONCE | 28 #ifdef BOOST_HAS_PRAGMA_ONCE |
26 #pragma once | 29 #pragma once |
27 #endif | 30 #endif |
30 | 33 |
31 BOOST_LOG_OPEN_NAMESPACE | 34 BOOST_LOG_OPEN_NAMESPACE |
32 | 35 |
33 namespace aux { | 36 namespace aux { |
34 | 37 |
35 //! The trait verifies if the type can be converted to a Boost.Spirit.Qi parser | 38 //! This tag type is used if an expression is recognized as a Boost.Spirit.Qi expression |
36 template< typename T > | 39 struct boost_spirit_qi_expression_tag; |
37 struct is_spirit_qi_parser< T, true > : | 40 |
38 public spirit::traits::is_component< spirit::qi::domain, T > | 41 //! The metafunction detects the matching expression kind and returns a tag that is used to specialize \c match_traits |
42 template< typename ExpressionT > | |
43 struct matching_expression_kind< ExpressionT, typename boost::enable_if< spirit::traits::matches< spirit::qi::domain, ExpressionT > >::type > | |
39 { | 44 { |
45 typedef boost_spirit_qi_expression_tag type; | |
40 }; | 46 }; |
41 | 47 |
42 //! The matching functor implementation | 48 //! The matching function implementation |
43 template< > | 49 template< typename ExpressionT > |
44 struct matches_fun_impl< boost_spirit_qi_expression_tag > | 50 struct match_traits< ExpressionT, boost_spirit_qi_expression_tag > |
45 { | 51 { |
46 template< typename StringT, typename ParserT > | 52 typedef typename spirit::result_of::compile< spirit::qi::domain, ExpressionT, spirit::unused_type >::type compiled_type; |
47 static bool matches( | 53 |
48 StringT const& str, | 54 static compiled_type compile(ExpressionT const& expr) |
49 ParserT const& expr) | 55 { |
56 return spirit::compile< spirit::qi::domain >(expr); | |
57 } | |
58 | |
59 template< typename StringT > | |
60 static bool matches(StringT const& str, ExpressionT const& expr) | |
61 { | |
62 typedef typename StringT::const_iterator const_iterator; | |
63 const_iterator it = str.begin(), end = str.end(); | |
64 return (spirit::qi::parse(it, end, expr) && it == end); | |
65 } | |
66 }; | |
67 | |
68 //! The matching function implementation | |
69 template< typename IteratorT, typename T1, typename T2, typename T3, typename T4 > | |
70 struct match_traits< spirit::qi::rule< IteratorT, T1, T2, T3, T4 >, boost_spirit_qi_expression_tag > | |
71 { | |
72 typedef spirit::qi::rule< IteratorT, T1, T2, T3, T4 > compiled_type; | |
73 static compiled_type compile(compiled_type const& expr) { return expr; } | |
74 | |
75 template< typename StringT > | |
76 static bool matches(StringT const& str, compiled_type const& expr) | |
50 { | 77 { |
51 typedef typename StringT::const_iterator const_iterator; | 78 typedef typename StringT::const_iterator const_iterator; |
52 const_iterator it = str.begin(), end = str.end(); | 79 const_iterator it = str.begin(), end = str.end(); |
53 return (spirit::qi::parse(it, end, expr) && it == end); | 80 return (spirit::qi::parse(it, end, expr) && it == end); |
54 } | 81 } |