Imported Upstream version 1.57.0
[platform/upstream/boost.git] / libs / log / src / spirit_encoding.hpp
1 /*
2  *          Copyright Andrey Semashev 2007 - 2014.
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   spirit_encoding.hpp
9  * \author Andrey Semashev
10  * \date   20.07.2012
11  *
12  * \brief  This header is the Boost.Log library implementation, see the library documentation
13  *         at http://www.boost.org/doc/libs/release/libs/log/doc/html/index.html.
14  */
15
16 #ifndef BOOST_LOG_SPIRIT_ENCODING_HPP_INCLUDED_
17 #define BOOST_LOG_SPIRIT_ENCODING_HPP_INCLUDED_
18
19 #include <boost/preprocessor/tuple/elem.hpp>
20 #include <boost/preprocessor/seq/for_each.hpp>
21 #include <boost/spirit/include/support_standard.hpp>
22 #include <boost/spirit/include/support_standard_wide.hpp>
23 #include <boost/spirit/home/support/common_terminals.hpp>
24 #include <boost/log/detail/config.hpp>
25 #include <boost/log/detail/header.hpp>
26
27 #ifdef BOOST_HAS_PRAGMA_ONCE
28 #pragma once
29 #endif
30
31 namespace boost {
32
33 BOOST_LOG_OPEN_NAMESPACE
34
35 namespace aux {
36
37 template< typename >
38 struct encoding;
39
40 template< >
41 struct encoding< char >
42 {
43     typedef spirit::char_encoding::standard type;
44 };
45 template< >
46 struct encoding< wchar_t >
47 {
48     typedef spirit::char_encoding::standard_wide type;
49 };
50
51 //! A simple trait that allows to use charset-specific Qi parsers in a generic way
52 template< typename EncodingT >
53 struct encoding_specific;
54
55 #define BOOST_LOG_CHARSET_PARSERS\
56     ((char_type, char_))\
57     ((string_type, string))\
58     ((alnum_type, alnum))\
59     ((alpha_type, alpha))\
60     ((blank_type, blank))\
61     ((cntrl_type, cntrl))\
62     ((digit_type, digit))\
63     ((graph_type, graph))\
64     ((print_type, print))\
65     ((punct_type, punct))\
66     ((space_type, space))\
67     ((xdigit_type, xdigit))\
68     ((no_case_type, no_case))\
69     ((lower_type, lower))\
70     ((upper_type, upper))\
71     ((lowernum_type, lowernum))\
72     ((uppernum_type, uppernum))
73
74 #define BOOST_LOG_DECLARE_CHARSET_PARSER(r, charset, parser)\
75     typedef spirit::charset::BOOST_PP_TUPLE_ELEM(2, 0, parser) BOOST_PP_TUPLE_ELEM(2, 0, parser);\
76     BOOST_LOG_API static BOOST_PP_TUPLE_ELEM(2, 0, parser) const& BOOST_PP_TUPLE_ELEM(2, 1, parser);
77
78 #define BOOST_LOG_DECLARE_CHARSET_PARSERS(charset)\
79     BOOST_PP_SEQ_FOR_EACH(BOOST_LOG_DECLARE_CHARSET_PARSER, charset, BOOST_LOG_CHARSET_PARSERS)
80
81 template< >
82 struct encoding_specific< spirit::char_encoding::standard >
83 {
84     BOOST_LOG_DECLARE_CHARSET_PARSERS(standard)
85 };
86
87 template< >
88 struct encoding_specific< spirit::char_encoding::standard_wide >
89 {
90     BOOST_LOG_DECLARE_CHARSET_PARSERS(standard_wide)
91 };
92
93 #undef BOOST_LOG_DECLARE_CHARSET_PARSERS
94 #undef BOOST_LOG_DECLARE_CHARSET_PARSER
95
96 } // namespace aux
97
98 BOOST_LOG_CLOSE_NAMESPACE // namespace log
99
100 } // namespace boost
101
102 #include <boost/log/detail/footer.hpp>
103
104 #endif // BOOST_LOG_SPIRIT_ENCODING_HPP_INCLUDED_