Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/spirit/home/classic/utility/impl/chset/basic_chset.ipp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*=============================================================================
0002     Copyright (c) 2001-2003 Joel de Guzman
0003     Copyright (c) 2001-2003 Daniel Nuffer
0004     http://spirit.sourceforge.net/
0005 
0006     Use, modification and distribution is subject to the Boost Software
0007     License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0008     http://www.boost.org/LICENSE_1_0.txt)
0009 =============================================================================*/
0010 #ifndef BOOST_SPIRIT_BASIC_CHSET_IPP
0011 #define BOOST_SPIRIT_BASIC_CHSET_IPP
0012 
0013 ///////////////////////////////////////////////////////////////////////////////
0014 #include <bitset>
0015 #include <boost/spirit/home/classic/utility/impl/chset/basic_chset.hpp>
0016 
0017 ///////////////////////////////////////////////////////////////////////////////
0018 namespace boost { namespace spirit {
0019 
0020 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
0021 
0022 ///////////////////////////////////////////////////////////////////////////////
0023 //
0024 //  basic_chset: character set implementation
0025 //
0026 ///////////////////////////////////////////////////////////////////////////////
0027 template <typename CharT>
0028 inline basic_chset<CharT>::basic_chset() {}
0029 
0030 //////////////////////////////////
0031 template <typename CharT>
0032 inline basic_chset<CharT>::basic_chset(basic_chset const& arg_)
0033 : rr(arg_.rr) {}
0034 
0035 //////////////////////////////////
0036 template <typename CharT>
0037 inline bool
0038 basic_chset<CharT>::test(CharT v) const
0039 { return rr.test(v); }
0040 
0041 //////////////////////////////////
0042 template <typename CharT>
0043 inline void
0044 basic_chset<CharT>::set(CharT from, CharT to)
0045 { rr.set(utility::impl::range<CharT>(from, to)); }
0046 
0047 //////////////////////////////////
0048 template <typename CharT>
0049 inline void
0050 basic_chset<CharT>::set(CharT c)
0051 { rr.set(utility::impl::range<CharT>(c, c)); }
0052 
0053 //////////////////////////////////
0054 template <typename CharT>
0055 inline void
0056 basic_chset<CharT>::clear(CharT from, CharT to)
0057 { rr.clear(utility::impl::range<CharT>(from, to)); }
0058 
0059 //////////////////////////////////
0060 template <typename CharT>
0061 inline void
0062 basic_chset<CharT>::clear()
0063 { rr.clear(); }
0064 
0065 /////////////////////////////////
0066 template <typename CharT>
0067 inline void
0068 basic_chset<CharT>::inverse()
0069 {
0070     basic_chset inv;
0071     inv.set(
0072         (std::numeric_limits<CharT>::min)(),
0073         (std::numeric_limits<CharT>::max)()
0074     );
0075     inv -= *this;
0076     swap(inv);
0077 }
0078 
0079 /////////////////////////////////
0080 template <typename CharT>
0081 inline void
0082 basic_chset<CharT>::swap(basic_chset& x)
0083 { rr.swap(x.rr); }
0084 
0085 /////////////////////////////////
0086 template <typename CharT>
0087 inline basic_chset<CharT>&
0088 basic_chset<CharT>::operator|=(basic_chset<CharT> const& x)
0089 {
0090     typedef typename utility::impl::range_run<CharT>::const_iterator const_iterator;
0091     for (const_iterator iter = x.rr.begin(); iter != x.rr.end(); ++iter)
0092         rr.set(*iter);
0093     return *this;
0094 }
0095 
0096 /////////////////////////////////
0097 template <typename CharT>
0098 inline basic_chset<CharT>&
0099 basic_chset<CharT>::operator&=(basic_chset<CharT> const& x)
0100 {
0101     basic_chset inv;
0102     inv.set(
0103         (std::numeric_limits<CharT>::min)(),
0104         (std::numeric_limits<CharT>::max)()
0105     );
0106     inv -= x;
0107     *this -= inv;
0108     return *this;
0109 }
0110 
0111 /////////////////////////////////
0112 template <typename CharT>
0113 inline basic_chset<CharT>&
0114 basic_chset<CharT>::operator-=(basic_chset<CharT> const& x)
0115 {
0116     typedef typename utility::impl::range_run<CharT>::const_iterator const_iterator;
0117     for (const_iterator iter = x.rr.begin(); iter != x.rr.end(); ++iter)
0118         rr.clear(*iter);
0119     return *this;
0120 }
0121 
0122 /////////////////////////////////
0123 template <typename CharT>
0124 inline basic_chset<CharT>&
0125 basic_chset<CharT>::operator^=(basic_chset<CharT> const& x)
0126 {
0127     basic_chset bma = x;
0128     bma -= *this;
0129     *this -= x;
0130     *this |= bma;
0131     return *this;
0132 }
0133 
0134 #if (CHAR_BIT == 8)
0135 
0136 ///////////////////////////////////////////////////////////////////////////////
0137 //
0138 //  basic_chset: specializations for 8 bit chars using std::bitset
0139 //
0140 ///////////////////////////////////////////////////////////////////////////////
0141 template <typename CharT>
0142 inline basic_chset_8bit<CharT>::basic_chset_8bit() {}
0143 
0144 /////////////////////////////////
0145 template <typename CharT>
0146 inline basic_chset_8bit<CharT>::basic_chset_8bit(basic_chset_8bit const& arg_)
0147 : bset(arg_.bset) {}
0148 
0149 /////////////////////////////////
0150 template <typename CharT>
0151 inline bool
0152 basic_chset_8bit<CharT>::test(CharT v) const
0153 { return bset.test((unsigned char)v); }
0154 
0155 /////////////////////////////////
0156 template <typename CharT>
0157 inline void
0158 basic_chset_8bit<CharT>::set(CharT from, CharT to)
0159 {
0160     for (int i = from; i <= to; ++i)
0161         bset.set((unsigned char)i);
0162 }
0163 
0164 /////////////////////////////////
0165 template <typename CharT>
0166 inline void
0167 basic_chset_8bit<CharT>::set(CharT c)
0168 { bset.set((unsigned char)c); }
0169 
0170 /////////////////////////////////
0171 template <typename CharT>
0172 inline void
0173 basic_chset_8bit<CharT>::clear(CharT from, CharT to)
0174 {
0175     for (int i = from; i <= to; ++i)
0176         bset.reset((unsigned char)i);
0177 }
0178 
0179 /////////////////////////////////
0180 template <typename CharT>
0181 inline void
0182 basic_chset_8bit<CharT>::clear(CharT c)
0183 { bset.reset((unsigned char)c); }
0184 
0185 /////////////////////////////////
0186 template <typename CharT>
0187 inline void
0188 basic_chset_8bit<CharT>::clear()
0189 { bset.reset(); }
0190 
0191 /////////////////////////////////
0192 template <typename CharT>
0193 inline void
0194 basic_chset_8bit<CharT>::inverse()
0195 { bset.flip(); }
0196 
0197 /////////////////////////////////
0198 template <typename CharT>
0199 inline void
0200 basic_chset_8bit<CharT>::swap(basic_chset_8bit& x)
0201 { std::swap(bset, x.bset); }
0202 
0203 /////////////////////////////////
0204 template <typename CharT>
0205 inline basic_chset_8bit<CharT>&
0206 basic_chset_8bit<CharT>::operator|=(basic_chset_8bit const& x)
0207 {
0208     bset |= x.bset;
0209     return *this;
0210 }
0211 
0212 /////////////////////////////////
0213 template <typename CharT>
0214 inline basic_chset_8bit<CharT>&
0215 basic_chset_8bit<CharT>::operator&=(basic_chset_8bit const& x)
0216 {
0217     bset &= x.bset;
0218     return *this;
0219 }
0220 
0221 /////////////////////////////////
0222 template <typename CharT>
0223 inline basic_chset_8bit<CharT>&
0224 basic_chset_8bit<CharT>::operator-=(basic_chset_8bit const& x)
0225 {
0226     bset &= ~x.bset;
0227     return *this;
0228 }
0229 
0230 /////////////////////////////////
0231 template <typename CharT>
0232 inline basic_chset_8bit<CharT>&
0233 basic_chset_8bit<CharT>::operator^=(basic_chset_8bit const& x)
0234 {
0235     bset ^= x.bset;
0236     return *this;
0237 }
0238 
0239 #endif
0240 
0241 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
0242 
0243 }} // namespace boost::spirit
0244 
0245 #endif
0246