[857] | 1 | /*=============================================================================
|
---|
| 2 | Copyright (c) 2001-2003 Joel de Guzman
|
---|
| 3 | Copyright (c) 2001-2003 Daniel Nuffer
|
---|
| 4 | http://spirit.sourceforge.net/
|
---|
| 5 |
|
---|
| 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_HPP
|
---|
| 11 | #define BOOST_SPIRIT_BASIC_CHSET_HPP
|
---|
| 12 |
|
---|
| 13 | ///////////////////////////////////////////////////////////////////////////////
|
---|
| 14 | #include <bitset>
|
---|
| 15 | #include <boost/spirit/utility/impl/chset/range_run.hpp>
|
---|
| 16 |
|
---|
| 17 | namespace boost { namespace spirit {
|
---|
| 18 |
|
---|
| 19 | ///////////////////////////////////////////////////////////////////////////
|
---|
| 20 | //
|
---|
| 21 | // basic_chset: basic character set implementation using range_run
|
---|
| 22 | //
|
---|
| 23 | ///////////////////////////////////////////////////////////////////////////
|
---|
| 24 | template <typename CharT>
|
---|
| 25 | class basic_chset
|
---|
| 26 | {
|
---|
| 27 | public:
|
---|
| 28 | basic_chset();
|
---|
| 29 | basic_chset(basic_chset const& arg_);
|
---|
| 30 |
|
---|
| 31 | bool test(CharT v) const;
|
---|
| 32 | void set(CharT from, CharT to);
|
---|
| 33 | void set(CharT c);
|
---|
| 34 | void clear(CharT from, CharT to);
|
---|
| 35 | void clear(CharT c);
|
---|
| 36 | void clear();
|
---|
| 37 |
|
---|
| 38 | void inverse();
|
---|
| 39 | void swap(basic_chset& x);
|
---|
| 40 |
|
---|
| 41 | basic_chset& operator|=(basic_chset const& x);
|
---|
| 42 | basic_chset& operator&=(basic_chset const& x);
|
---|
| 43 | basic_chset& operator-=(basic_chset const& x);
|
---|
| 44 | basic_chset& operator^=(basic_chset const& x);
|
---|
| 45 |
|
---|
| 46 | private: utility::impl::range_run<CharT> rr;
|
---|
| 47 | };
|
---|
| 48 |
|
---|
| 49 | #if (CHAR_BIT == 8)
|
---|
| 50 |
|
---|
| 51 | ///////////////////////////////////////////////////////////////////////////
|
---|
| 52 | //
|
---|
| 53 | // basic_chset: specializations for 8 bit chars using std::bitset
|
---|
| 54 | //
|
---|
| 55 | ///////////////////////////////////////////////////////////////////////////
|
---|
| 56 | template <typename CharT>
|
---|
| 57 | class basic_chset_8bit {
|
---|
| 58 |
|
---|
| 59 | public:
|
---|
| 60 | basic_chset_8bit();
|
---|
| 61 | basic_chset_8bit(basic_chset_8bit const& arg_);
|
---|
| 62 |
|
---|
| 63 | bool test(CharT v) const;
|
---|
| 64 | void set(CharT from, CharT to);
|
---|
| 65 | void set(CharT c);
|
---|
| 66 | void clear(CharT from, CharT to);
|
---|
| 67 | void clear(CharT c);
|
---|
| 68 | void clear();
|
---|
| 69 |
|
---|
| 70 | void inverse();
|
---|
| 71 | void swap(basic_chset_8bit& x);
|
---|
| 72 |
|
---|
| 73 | basic_chset_8bit& operator|=(basic_chset_8bit const& x);
|
---|
| 74 | basic_chset_8bit& operator&=(basic_chset_8bit const& x);
|
---|
| 75 | basic_chset_8bit& operator-=(basic_chset_8bit const& x);
|
---|
| 76 | basic_chset_8bit& operator^=(basic_chset_8bit const& x);
|
---|
| 77 |
|
---|
| 78 | private: std::bitset<256> bset;
|
---|
| 79 | };
|
---|
| 80 |
|
---|
| 81 | /////////////////////////////////
|
---|
| 82 | template <>
|
---|
| 83 | class basic_chset<char>
|
---|
| 84 | : public basic_chset_8bit<char> {};
|
---|
| 85 |
|
---|
| 86 | /////////////////////////////////
|
---|
| 87 | template <>
|
---|
| 88 | class basic_chset<signed char>
|
---|
| 89 | : public basic_chset_8bit<signed char> {};
|
---|
| 90 |
|
---|
| 91 | /////////////////////////////////
|
---|
| 92 | template <>
|
---|
| 93 | class basic_chset<unsigned char>
|
---|
| 94 | : public basic_chset_8bit<unsigned char> {};
|
---|
| 95 |
|
---|
| 96 | #endif
|
---|
| 97 |
|
---|
| 98 | }} // namespace boost::spirit
|
---|
| 99 |
|
---|
| 100 | #endif
|
---|
| 101 |
|
---|
| 102 | #include <boost/spirit/utility/impl/chset/basic_chset.ipp>
|
---|