1 /*=============================================================================
2 Copyright (c) 2001-2011 Hartmut Kaiser
3 http://spirit.sourceforge.net/
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
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>
20 namespace boost { namespace spirit { namespace traits
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>
30 call(Iterator const& first, Iterator const&, char& attr)
36 template <typename Iterator>
37 struct assign_to_attribute_from_iterators<signed char, Iterator>
40 call(Iterator const& first, Iterator const&, signed char& attr)
46 template <typename Iterator>
47 struct assign_to_attribute_from_iterators<unsigned char, Iterator>
50 call(Iterator const& first, Iterator const&, unsigned char& attr)
56 // wchar_t is intrinsic
57 template <typename Iterator>
58 struct assign_to_attribute_from_iterators<wchar_t, Iterator>
61 call(Iterator const& first, Iterator const&, wchar_t& attr)
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>
73 call(Iterator const& first, Iterator const&, unsigned short& attr)
80 template <typename Iterator>
81 struct assign_to_attribute_from_iterators<bool, Iterator>
84 call(Iterator const& first, Iterator const& last, bool& attr)
86 Iterator first_ = first;
87 qi::parse(first_, last, bool_type(), attr);
91 template <typename Iterator>
92 struct assign_to_attribute_from_iterators<short, Iterator>
95 call(Iterator const& first, Iterator const& last, short& attr)
97 Iterator first_ = first;
98 qi::parse(first_, last, short_type(), attr);
102 template <typename Iterator>
103 struct assign_to_attribute_from_iterators<int, Iterator>
106 call(Iterator const& first, Iterator const& last, int& attr)
108 Iterator first_ = first;
109 qi::parse(first_, last, int_type(), attr);
112 template <typename Iterator>
113 struct assign_to_attribute_from_iterators<unsigned int, Iterator>
116 call(Iterator const& first, Iterator const& last, unsigned int& attr)
118 Iterator first_ = first;
119 qi::parse(first_, last, uint_type(), attr);
123 template <typename Iterator>
124 struct assign_to_attribute_from_iterators<long, Iterator>
127 call(Iterator const& first, Iterator const& last, long& attr)
129 Iterator first_ = first;
130 qi::parse(first_, last, long_type(), attr);
133 template <typename Iterator>
134 struct assign_to_attribute_from_iterators<unsigned long, Iterator>
137 call(Iterator const& first, Iterator const& last, unsigned long& attr)
139 Iterator first_ = first;
140 qi::parse(first_, last, ulong_type(), attr);
144 #ifdef BOOST_HAS_LONG_LONG
145 template <typename Iterator>
146 struct assign_to_attribute_from_iterators<long_long_type, Iterator>
149 call(Iterator const& first, Iterator const& last, long_long_type& attr)
151 Iterator first_ = first;
152 qi::parse(first_, last, long_long_type(), attr);
155 template <typename Iterator>
156 struct assign_to_attribute_from_iterators<ulong_long_type, Iterator>
159 call(Iterator const& first, Iterator const& last, ulong_long_type& attr)
161 Iterator first_ = first;
162 qi::parse(first_, last, ulong_long_type(), attr);
167 template <typename Iterator>
168 struct assign_to_attribute_from_iterators<float, Iterator>
171 call(Iterator const& first, Iterator const& last, float& attr)
173 Iterator first_ = first;
174 qi::parse(first_, last, float_type(), attr);
178 template <typename Iterator>
179 struct assign_to_attribute_from_iterators<double, Iterator>
182 call(Iterator const& first, Iterator const& last, double& attr)
184 Iterator first_ = first;
185 qi::parse(first_, last, double_type(), attr);
189 template <typename Iterator>
190 struct assign_to_attribute_from_iterators<long double, Iterator>
193 call(Iterator const& first, Iterator const& last, long double& attr)
195 Iterator first_ = first;
196 qi::parse(first_, last, long_double_type(), attr);