]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /*============================================================================= |
2 | Copyright (c) 2001-2011 Hartmut Kaiser | |
3 | http://spirit.sourceforge.net/ | |
4 | ||
5 | Distributed under the Boost Software License, Version 1.0. (See accompanying | |
6 | file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
7 | =============================================================================*/ | |
8 | #if !defined(BOOST_SPIRIT_CONSTRUCT_MAR_24_2007_0629PM) | |
9 | #define BOOST_SPIRIT_CONSTRUCT_MAR_24_2007_0629PM | |
10 | ||
11 | #if defined(_MSC_VER) | |
12 | #pragma once | |
13 | #endif | |
14 | ||
15 | #include <boost/config.hpp> | |
16 | #include <boost/spirit/home/qi/parse.hpp> | |
17 | #include <boost/spirit/home/support/common_terminals.hpp> | |
18 | #include <boost/spirit/home/support/attributes_fwd.hpp> | |
19 | ||
20 | namespace boost { namespace spirit { namespace traits | |
21 | { | |
22 | /////////////////////////////////////////////////////////////////////////// | |
23 | // We provide overloads for the assign_to_attribute_from_iterators | |
24 | // customization point for all built in types | |
25 | /////////////////////////////////////////////////////////////////////////// | |
26 | template <typename Iterator> | |
27 | struct assign_to_attribute_from_iterators<char, Iterator> | |
28 | { | |
29 | static void | |
30 | call(Iterator const& first, Iterator const&, char& attr) | |
31 | { | |
32 | attr = *first; | |
33 | } | |
34 | }; | |
35 | ||
36 | template <typename Iterator> | |
37 | struct assign_to_attribute_from_iterators<signed char, Iterator> | |
38 | { | |
39 | static void | |
40 | call(Iterator const& first, Iterator const&, signed char& attr) | |
41 | { | |
42 | attr = *first; | |
43 | } | |
44 | }; | |
45 | ||
46 | template <typename Iterator> | |
47 | struct assign_to_attribute_from_iterators<unsigned char, Iterator> | |
48 | { | |
49 | static void | |
50 | call(Iterator const& first, Iterator const&, unsigned char& attr) | |
51 | { | |
52 | attr = *first; | |
53 | } | |
54 | }; | |
55 | ||
56 | // wchar_t is intrinsic | |
57 | template <typename Iterator> | |
58 | struct assign_to_attribute_from_iterators<wchar_t, Iterator> | |
59 | { | |
60 | static void | |
61 | call(Iterator const& first, Iterator const&, wchar_t& attr) | |
62 | { | |
63 | attr = *first; | |
64 | } | |
65 | }; | |
66 | ||
67 | #if !defined(BOOST_NO_INTRINSIC_WCHAR_T) | |
68 | // wchar_t is intrinsic, have separate overload for unsigned short | |
69 | template <typename Iterator> | |
70 | struct assign_to_attribute_from_iterators<unsigned short, Iterator> | |
71 | { | |
72 | static void | |
73 | call(Iterator const& first, Iterator const&, unsigned short& attr) | |
74 | { | |
75 | attr = *first; | |
76 | } | |
77 | }; | |
78 | #endif | |
79 | ||
80 | template <typename Iterator> | |
81 | struct assign_to_attribute_from_iterators<bool, Iterator> | |
82 | { | |
83 | static void | |
84 | call(Iterator const& first, Iterator const& last, bool& attr) | |
85 | { | |
86 | Iterator first_ = first; | |
87 | qi::parse(first_, last, bool_type(), attr); | |
88 | } | |
89 | }; | |
90 | ||
91 | template <typename Iterator> | |
92 | struct assign_to_attribute_from_iterators<short, Iterator> | |
93 | { | |
94 | static void | |
95 | call(Iterator const& first, Iterator const& last, short& attr) | |
96 | { | |
97 | Iterator first_ = first; | |
98 | qi::parse(first_, last, short_type(), attr); | |
99 | } | |
100 | }; | |
101 | ||
102 | template <typename Iterator> | |
103 | struct assign_to_attribute_from_iterators<int, Iterator> | |
104 | { | |
105 | static void | |
106 | call(Iterator const& first, Iterator const& last, int& attr) | |
107 | { | |
108 | Iterator first_ = first; | |
109 | qi::parse(first_, last, int_type(), attr); | |
110 | } | |
111 | }; | |
112 | template <typename Iterator> | |
113 | struct assign_to_attribute_from_iterators<unsigned int, Iterator> | |
114 | { | |
115 | static void | |
116 | call(Iterator const& first, Iterator const& last, unsigned int& attr) | |
117 | { | |
118 | Iterator first_ = first; | |
119 | qi::parse(first_, last, uint_type(), attr); | |
120 | } | |
121 | }; | |
122 | ||
123 | template <typename Iterator> | |
124 | struct assign_to_attribute_from_iterators<long, Iterator> | |
125 | { | |
126 | static void | |
127 | call(Iterator const& first, Iterator const& last, long& attr) | |
128 | { | |
129 | Iterator first_ = first; | |
130 | qi::parse(first_, last, long_type(), attr); | |
131 | } | |
132 | }; | |
133 | template <typename Iterator> | |
134 | struct assign_to_attribute_from_iterators<unsigned long, Iterator> | |
135 | { | |
136 | static void | |
137 | call(Iterator const& first, Iterator const& last, unsigned long& attr) | |
138 | { | |
139 | Iterator first_ = first; | |
140 | qi::parse(first_, last, ulong_type(), attr); | |
141 | } | |
142 | }; | |
143 | ||
144 | #ifdef BOOST_HAS_LONG_LONG | |
145 | template <typename Iterator> | |
146 | struct assign_to_attribute_from_iterators<long_long_type, Iterator> | |
147 | { | |
148 | static void | |
149 | call(Iterator const& first, Iterator const& last, long_long_type& attr) | |
150 | { | |
151 | Iterator first_ = first; | |
152 | qi::parse(first_, last, long_long_type(), attr); | |
153 | } | |
154 | }; | |
155 | template <typename Iterator> | |
156 | struct assign_to_attribute_from_iterators<ulong_long_type, Iterator> | |
157 | { | |
158 | static void | |
159 | call(Iterator const& first, Iterator const& last, ulong_long_type& attr) | |
160 | { | |
161 | Iterator first_ = first; | |
162 | qi::parse(first_, last, ulong_long_type(), attr); | |
163 | } | |
164 | }; | |
165 | #endif | |
166 | ||
167 | template <typename Iterator> | |
168 | struct assign_to_attribute_from_iterators<float, Iterator> | |
169 | { | |
170 | static void | |
171 | call(Iterator const& first, Iterator const& last, float& attr) | |
172 | { | |
173 | Iterator first_ = first; | |
174 | qi::parse(first_, last, float_type(), attr); | |
175 | } | |
176 | }; | |
177 | ||
178 | template <typename Iterator> | |
179 | struct assign_to_attribute_from_iterators<double, Iterator> | |
180 | { | |
181 | static void | |
182 | call(Iterator const& first, Iterator const& last, double& attr) | |
183 | { | |
184 | Iterator first_ = first; | |
185 | qi::parse(first_, last, double_type(), attr); | |
186 | } | |
187 | }; | |
188 | ||
189 | template <typename Iterator> | |
190 | struct assign_to_attribute_from_iterators<long double, Iterator> | |
191 | { | |
192 | static void | |
193 | call(Iterator const& first, Iterator const& last, long double& attr) | |
194 | { | |
195 | Iterator first_ = first; | |
196 | qi::parse(first_, last, long_double_type(), attr); | |
197 | } | |
198 | }; | |
199 | ||
200 | }}} | |
201 | ||
202 | #endif |