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_qi.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.Qi support for Boost.Log.
|
Chris@16
|
13 */
|
Chris@16
|
14
|
Chris@16
|
15 #ifndef BOOST_LOG_SUPPORT_SPIRIT_QI_HPP_INCLUDED_
|
Chris@16
|
16 #define BOOST_LOG_SUPPORT_SPIRIT_QI_HPP_INCLUDED_
|
Chris@16
|
17
|
Chris@16
|
18 #include <boost/log/detail/config.hpp>
|
Chris@16
|
19 #include <boost/log/utility/functional/matches.hpp>
|
Chris@16
|
20 #include <boost/spirit/include/qi_parse.hpp>
|
Chris@16
|
21 #include <boost/spirit/include/qi_domain.hpp>
|
Chris@16
|
22 #include <boost/spirit/include/support_component.hpp>
|
Chris@16
|
23 #include <boost/log/detail/header.hpp>
|
Chris@16
|
24
|
Chris@16
|
25 #ifdef BOOST_HAS_PRAGMA_ONCE
|
Chris@16
|
26 #pragma once
|
Chris@16
|
27 #endif
|
Chris@16
|
28
|
Chris@16
|
29 namespace boost {
|
Chris@16
|
30
|
Chris@16
|
31 BOOST_LOG_OPEN_NAMESPACE
|
Chris@16
|
32
|
Chris@16
|
33 namespace aux {
|
Chris@16
|
34
|
Chris@16
|
35 //! The trait verifies if the type can be converted to a Boost.Spirit.Qi parser
|
Chris@16
|
36 template< typename T >
|
Chris@16
|
37 struct is_spirit_qi_parser< T, true > :
|
Chris@16
|
38 public spirit::traits::is_component< spirit::qi::domain, T >
|
Chris@16
|
39 {
|
Chris@16
|
40 };
|
Chris@16
|
41
|
Chris@16
|
42 //! The matching functor implementation
|
Chris@16
|
43 template< >
|
Chris@16
|
44 struct matches_fun_impl< boost_spirit_qi_expression_tag >
|
Chris@16
|
45 {
|
Chris@16
|
46 template< typename StringT, typename ParserT >
|
Chris@16
|
47 static bool matches(
|
Chris@16
|
48 StringT const& str,
|
Chris@16
|
49 ParserT const& expr)
|
Chris@16
|
50 {
|
Chris@16
|
51 typedef typename StringT::const_iterator const_iterator;
|
Chris@16
|
52 const_iterator it = str.begin(), end = str.end();
|
Chris@16
|
53 return (spirit::qi::parse(it, end, expr) && it == end);
|
Chris@16
|
54 }
|
Chris@16
|
55 };
|
Chris@16
|
56
|
Chris@16
|
57 } // namespace aux
|
Chris@16
|
58
|
Chris@16
|
59 BOOST_LOG_CLOSE_NAMESPACE // namespace log
|
Chris@16
|
60
|
Chris@16
|
61 } // namespace boost
|
Chris@16
|
62
|
Chris@16
|
63 #include <boost/log/detail/footer.hpp>
|
Chris@16
|
64
|
Chris@16
|
65 #endif // BOOST_LOG_SUPPORT_SPIRIT_QI_HPP_INCLUDED_
|