summaryrefslogtreecommitdiffstats
blob: 5d8122f6a57fff7c684c4e07c23d425413f61774 (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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/*=============================================================================
    Copyright (c) 2001-2011 Hartmut Kaiser
    http://spirit.sourceforge.net/

    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_CONSTRUCT_MAR_24_2007_0629PM)
#define BOOST_SPIRIT_CONSTRUCT_MAR_24_2007_0629PM

#if defined(_MSC_VER)
#pragma once
#endif

#include <boost/config.hpp>
#include <boost/spirit/home/qi/parse.hpp>
#include <boost/spirit/home/support/common_terminals.hpp>
#include <boost/spirit/home/support/attributes_fwd.hpp>

namespace boost { namespace spirit { namespace traits
{
    ///////////////////////////////////////////////////////////////////////////
    //  We provide overloads for the assign_to_attribute_from_iterators
    //  customization point for all built in types
    ///////////////////////////////////////////////////////////////////////////
    template <typename Iterator>
    struct assign_to_attribute_from_iterators<char, Iterator>
    {
        static void
        call(Iterator const& first, Iterator const&, char& attr)
        {
            attr = *first;
        }
    };

    template <typename Iterator>
    struct assign_to_attribute_from_iterators<signed char, Iterator>
    {
        static void
        call(Iterator const& first, Iterator const&, signed char& attr)
        {
            attr = *first;
        }
    };

    template <typename Iterator>
    struct assign_to_attribute_from_iterators<unsigned char, Iterator>
    {
        static void
        call(Iterator const& first, Iterator const&, unsigned char& attr)
        {
            attr = *first;
        }
    };

    // wchar_t is intrinsic
    template <typename Iterator>
    struct assign_to_attribute_from_iterators<wchar_t, Iterator>
    {
        static void
        call(Iterator const& first, Iterator const&, wchar_t& attr)
        {
            attr = *first;
        }
    };

#if !defined(BOOST_NO_INTRINSIC_WCHAR_T)
    // wchar_t is intrinsic, have separate overload for unsigned short
    template <typename Iterator>
    struct assign_to_attribute_from_iterators<unsigned short, Iterator>
    {
        static void
        call(Iterator const& first, Iterator const&, unsigned short& attr)
        {
            attr = *first;
        }
    };
#endif

    template <typename Iterator>
    struct assign_to_attribute_from_iterators<bool, Iterator>
    {
        static void
        call(Iterator const& first, Iterator const& last, bool& attr)
        {
            Iterator first_ = first;
            qi::parse(first_, last, bool_type(), attr);
        }
    };

    template <typename Iterator>
    struct assign_to_attribute_from_iterators<short, Iterator>
    {
        static void
        call(Iterator const& first, Iterator const& last, short& attr)
        {
            Iterator first_ = first;
            qi::parse(first_, last, short_type(), attr);
        }
    };

    template <typename Iterator>
    struct assign_to_attribute_from_iterators<int, Iterator>
    {
        static void
        call(Iterator const& first, Iterator const& last, int& attr)
        {
            Iterator first_ = first;
            qi::parse(first_, last, int_type(), attr);
        }
    };
    template <typename Iterator>
    struct assign_to_attribute_from_iterators<unsigned int, Iterator>
    {
        static void
        call(Iterator const& first, Iterator const& last, unsigned int& attr)
        {
            Iterator first_ = first;
            qi::parse(first_, last, uint_type(), attr);
        }
    };

    template <typename Iterator>
    struct assign_to_attribute_from_iterators<long, Iterator>
    {
        static void
        call(Iterator const& first, Iterator const& last, long& attr)
        {
            Iterator first_ = first;
            qi::parse(first_, last, long_type(), attr);
        }
    };
    template <typename Iterator>
    struct assign_to_attribute_from_iterators<unsigned long, Iterator>
    {
        static void
        call(Iterator const& first, Iterator const& last, unsigned long& attr)
        {
            Iterator first_ = first;
            qi::parse(first_, last, ulong_type(), attr);
        }
    };

#ifdef BOOST_HAS_LONG_LONG
    template <typename Iterator>
    struct assign_to_attribute_from_iterators<long_long_type, Iterator>
    {
        static void
        call(Iterator const& first, Iterator const& last, long_long_type& attr)
        {
            Iterator first_ = first;
            qi::parse(first_, last, long_long_type(), attr);
        }
    };
    template <typename Iterator>
    struct assign_to_attribute_from_iterators<ulong_long_type, Iterator>
    {
        static void
        call(Iterator const& first, Iterator const& last, ulong_long_type& attr)
        {
            Iterator first_ = first;
            qi::parse(first_, last, ulong_long_type(), attr);
        }
    };
#endif

    template <typename Iterator>
    struct assign_to_attribute_from_iterators<float, Iterator>
    {
        static void
        call(Iterator const& first, Iterator const& last, float& attr)
        {
            Iterator first_ = first;
            qi::parse(first_, last, float_type(), attr);
        }
    };

    template <typename Iterator>
    struct assign_to_attribute_from_iterators<double, Iterator>
    {
        static void
        call(Iterator const& first, Iterator const& last, double& attr)
        {
            Iterator first_ = first;
            qi::parse(first_, last, double_type(), attr);
        }
    };

    template <typename Iterator>
    struct assign_to_attribute_from_iterators<long double, Iterator>
    {
        static void
        call(Iterator const& first, Iterator const& last, long double& attr)
        {
            Iterator first_ = first;
            qi::parse(first_, last, long_double_type(), attr);
        }
    };

}}}

#endif