1 /*=============================================================================
2 Copyright (c) 2001-2003 Joel de Guzman
3 Copyright (c) 2001-2003 Daniel Nuffer
4 http://spirit.sourceforge.net/
6 Use, modification and distribution is subject to the Boost Software
7 License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8 http://www.boost.org/LICENSE_1_0.txt)
9 =============================================================================*/
10 #ifndef BOOST_SPIRIT_BASIC_CHSET_IPP
11 #define BOOST_SPIRIT_BASIC_CHSET_IPP
13 ///////////////////////////////////////////////////////////////////////////////
15 #include <boost/spirit/home/classic/utility/impl/chset/basic_chset.hpp>
17 ///////////////////////////////////////////////////////////////////////////////
18 namespace boost { namespace spirit {
20 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
22 ///////////////////////////////////////////////////////////////////////////////
24 // basic_chset: character set implementation
26 ///////////////////////////////////////////////////////////////////////////////
27 template <typename CharT>
28 inline basic_chset<CharT>::basic_chset() {}
30 //////////////////////////////////
31 template <typename CharT>
32 inline basic_chset<CharT>::basic_chset(basic_chset const& arg_)
35 //////////////////////////////////
36 template <typename CharT>
38 basic_chset<CharT>::test(CharT v) const
39 { return rr.test(v); }
41 //////////////////////////////////
42 template <typename CharT>
44 basic_chset<CharT>::set(CharT from, CharT to)
45 { rr.set(utility::impl::range<CharT>(from, to)); }
47 //////////////////////////////////
48 template <typename CharT>
50 basic_chset<CharT>::set(CharT c)
51 { rr.set(utility::impl::range<CharT>(c, c)); }
53 //////////////////////////////////
54 template <typename CharT>
56 basic_chset<CharT>::clear(CharT from, CharT to)
57 { rr.clear(utility::impl::range<CharT>(from, to)); }
59 //////////////////////////////////
60 template <typename CharT>
62 basic_chset<CharT>::clear()
65 /////////////////////////////////
66 template <typename CharT>
68 basic_chset<CharT>::inverse()
72 (std::numeric_limits<CharT>::min)(),
73 (std::numeric_limits<CharT>::max)()
79 /////////////////////////////////
80 template <typename CharT>
82 basic_chset<CharT>::swap(basic_chset& x)
85 /////////////////////////////////
86 template <typename CharT>
87 inline basic_chset<CharT>&
88 basic_chset<CharT>::operator|=(basic_chset<CharT> const& x)
90 typedef typename utility::impl::range_run<CharT>::const_iterator const_iterator;
91 for (const_iterator iter = x.rr.begin(); iter != x.rr.end(); ++iter)
96 /////////////////////////////////
97 template <typename CharT>
98 inline basic_chset<CharT>&
99 basic_chset<CharT>::operator&=(basic_chset<CharT> const& x)
103 (std::numeric_limits<CharT>::min)(),
104 (std::numeric_limits<CharT>::max)()
111 /////////////////////////////////
112 template <typename CharT>
113 inline basic_chset<CharT>&
114 basic_chset<CharT>::operator-=(basic_chset<CharT> const& x)
116 typedef typename utility::impl::range_run<CharT>::const_iterator const_iterator;
117 for (const_iterator iter = x.rr.begin(); iter != x.rr.end(); ++iter)
122 /////////////////////////////////
123 template <typename CharT>
124 inline basic_chset<CharT>&
125 basic_chset<CharT>::operator^=(basic_chset<CharT> const& x)
136 ///////////////////////////////////////////////////////////////////////////////
138 // basic_chset: specializations for 8 bit chars using std::bitset
140 ///////////////////////////////////////////////////////////////////////////////
141 template <typename CharT>
142 inline basic_chset_8bit<CharT>::basic_chset_8bit() {}
144 /////////////////////////////////
145 template <typename CharT>
146 inline basic_chset_8bit<CharT>::basic_chset_8bit(basic_chset_8bit const& arg_)
149 /////////////////////////////////
150 template <typename CharT>
152 basic_chset_8bit<CharT>::test(CharT v) const
153 { return bset.test((unsigned char)v); }
155 /////////////////////////////////
156 template <typename CharT>
158 basic_chset_8bit<CharT>::set(CharT from, CharT to)
160 for (int i = from; i <= to; ++i)
161 bset.set((unsigned char)i);
164 /////////////////////////////////
165 template <typename CharT>
167 basic_chset_8bit<CharT>::set(CharT c)
168 { bset.set((unsigned char)c); }
170 /////////////////////////////////
171 template <typename CharT>
173 basic_chset_8bit<CharT>::clear(CharT from, CharT to)
175 for (int i = from; i <= to; ++i)
176 bset.reset((unsigned char)i);
179 /////////////////////////////////
180 template <typename CharT>
182 basic_chset_8bit<CharT>::clear(CharT c)
183 { bset.reset((unsigned char)c); }
185 /////////////////////////////////
186 template <typename CharT>
188 basic_chset_8bit<CharT>::clear()
191 /////////////////////////////////
192 template <typename CharT>
194 basic_chset_8bit<CharT>::inverse()
197 /////////////////////////////////
198 template <typename CharT>
200 basic_chset_8bit<CharT>::swap(basic_chset_8bit& x)
201 { std::swap(bset, x.bset); }
203 /////////////////////////////////
204 template <typename CharT>
205 inline basic_chset_8bit<CharT>&
206 basic_chset_8bit<CharT>::operator|=(basic_chset_8bit const& x)
212 /////////////////////////////////
213 template <typename CharT>
214 inline basic_chset_8bit<CharT>&
215 basic_chset_8bit<CharT>::operator&=(basic_chset_8bit const& x)
221 /////////////////////////////////
222 template <typename CharT>
223 inline basic_chset_8bit<CharT>&
224 basic_chset_8bit<CharT>::operator-=(basic_chset_8bit const& x)
230 /////////////////////////////////
231 template <typename CharT>
232 inline basic_chset_8bit<CharT>&
233 basic_chset_8bit<CharT>::operator^=(basic_chset_8bit const& x)
241 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
243 }} // namespace boost::spirit