summaryrefslogtreecommitdiff
path: root/boost/spirit/home/x3/char/char.hpp
blob: 8cd213a2bc232a65100ba7ed365189dd323deb06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/*=============================================================================
    Copyright (c) 2001-2014 Joel de Guzman

    Distributed under the Boost Software License, Version 1.0. (See accompanying
    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_SPIRIT_X3_CHAR_APRIL_16_2006_1051AM)
#define BOOST_SPIRIT_X3_CHAR_APRIL_16_2006_1051AM

#include <boost/spirit/home/x3/char/any_char.hpp>
#include <boost/spirit/home/support/char_encoding/ascii.hpp>
#include <boost/spirit/home/support/char_encoding/iso8859_1.hpp>
#include <boost/spirit/home/support/char_encoding/standard.hpp>
#include <boost/spirit/home/support/char_encoding/standard_wide.hpp>

namespace boost { namespace spirit { namespace x3
{
    namespace standard
    {
        typedef any_char<char_encoding::standard> char_type;
        auto const char_ = char_type{};

        inline literal_char<char_encoding::standard, unused_type>
        lit(char ch)
        {
            return { ch };
        }

        inline literal_char<char_encoding::standard, unused_type>
        lit(wchar_t ch)
        {
            return { ch };
        }

    }

    using standard::char_type;
    using standard::char_;
    using standard::lit;

#ifndef BOOST_SPIRIT_NO_STANDARD_WIDE
    namespace standard_wide
    {
        typedef any_char<char_encoding::standard_wide> char_type;
        auto const char_ = char_type{};

        inline literal_char<char_encoding::standard_wide, unused_type>
        lit(wchar_t ch)
        {
            return { ch };
        }
    }
#endif

    namespace ascii
    {
        typedef any_char<char_encoding::ascii> char_type;
        auto const char_ = char_type{};

        inline literal_char<char_encoding::ascii, unused_type>
        lit(char ch)
        {
            return { ch };
        }

        inline literal_char<char_encoding::ascii, unused_type>
        lit(wchar_t ch)
        {
            return { ch };
        }
    }

    namespace iso8859_1
    {
        typedef any_char<char_encoding::iso8859_1> char_type;
        auto const char_ = char_type{};

        inline literal_char<char_encoding::iso8859_1, unused_type>
        lit(char ch)
        {
            return { ch };
        }

        inline literal_char<char_encoding::iso8859_1, unused_type>
        lit(wchar_t ch)
        {
            return { ch };
        }
    }

    namespace extension
    {
        template <>
        struct as_parser<char>
        {
            typedef literal_char<
                char_encoding::standard, unused_type>
            type;

            typedef type value_type;

            static type call(char ch)
            {
                return { ch };
            }
        };

#ifndef BOOST_SPIRIT_NO_STANDARD_WIDE
        template <>
        struct as_parser<wchar_t>
        {
            typedef literal_char<
                char_encoding::standard_wide, unused_type>
            type;

            typedef type value_type;

            static type call(wchar_t ch)
            {
                return { ch };
            }
        };
#endif

        template <>
        struct as_parser<char [2]>
        {
            typedef literal_char<
                char_encoding::standard, unused_type>
            type;

            typedef type value_type;

            static type call(char const ch[])
            {
                return { ch[0] };
            }
        };

#ifndef BOOST_SPIRIT_NO_STANDARD_WIDE
        template <>
        struct as_parser<wchar_t [2]>
        {
            typedef literal_char<
                char_encoding::standard_wide, unused_type>
            type;

            typedef type value_type;

            static type call(wchar_t const ch[] )
            {
                return { ch[0] };
            }
        };
#endif

    }

}}}

#endif