1/*
2 * Copyright Andrey Semashev 2007 - 2015.
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/log/detail/config.hpp>
20#include <boost/preprocessor/tuple/elem.hpp>
21#include <boost/preprocessor/seq/for_each.hpp>
22#include <boost/spirit/include/support_standard.hpp>
23#include <boost/spirit/include/support_standard_wide.hpp>
24#include <boost/spirit/home/support/common_terminals.hpp>
25#include <boost/log/detail/header.hpp>
26
27#ifdef BOOST_HAS_PRAGMA_ONCE
28#pragma once
29#endif
30
31namespace boost {
32
33BOOST_LOG_OPEN_NAMESPACE
34
35namespace aux {
36
37template< typename >
38struct encoding;
39
40template< >
41struct encoding< char >
42{
43 typedef spirit::char_encoding::standard type;
44};
45template< >
46struct 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
52template< typename EncodingT >
53struct 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
81template< >
82struct encoding_specific< spirit::char_encoding::standard >
83{
84 BOOST_LOG_DECLARE_CHARSET_PARSERS(standard)
85};
86
87template< >
88struct 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
98BOOST_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_
105

source code of boost/libs/log/src/spirit_encoding.hpp