1 /*=============================================================================
2 Copyright (c) 2001-2003 Joel de Guzman
3 Copyright (c) 2001-2003 Daniel Nuffer
4 http://spirit.sourceforge.net/
6 Distributed under the Boost Software License, Version 1.0. (See accompanying
7 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 =============================================================================*/
9 #ifndef BOOST_SPIRIT_BASIC_CHSET_HPP
10 #define BOOST_SPIRIT_BASIC_CHSET_HPP
12 ///////////////////////////////////////////////////////////////////////////////
15 #include <boost/spirit/home/classic/utility/impl/chset/range_run.hpp>
16 #include <boost/spirit/home/classic/namespace.hpp>
18 namespace boost { namespace spirit {
20 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
22 ///////////////////////////////////////////////////////////////////////////
24 // basic_chset: basic character set implementation using range_run
26 ///////////////////////////////////////////////////////////////////////////
27 template <typename CharT>
32 basic_chset(basic_chset const& arg_);
34 bool test(CharT v) const;
35 void set(CharT from, CharT to);
37 void clear(CharT from, CharT to);
42 void swap(basic_chset& x);
44 basic_chset& operator|=(basic_chset const& x);
45 basic_chset& operator&=(basic_chset const& x);
46 basic_chset& operator-=(basic_chset const& x);
47 basic_chset& operator^=(basic_chset const& x);
49 private: utility::impl::range_run<CharT> rr;
54 ///////////////////////////////////////////////////////////////////////////
56 // basic_chset: specializations for 8 bit chars using std::bitset
58 ///////////////////////////////////////////////////////////////////////////
59 template <typename CharT>
60 class basic_chset_8bit {
64 basic_chset_8bit(basic_chset_8bit const& arg_);
66 bool test(CharT v) const;
67 void set(CharT from, CharT to);
69 void clear(CharT from, CharT to);
74 void swap(basic_chset_8bit& x);
76 basic_chset_8bit& operator|=(basic_chset_8bit const& x);
77 basic_chset_8bit& operator&=(basic_chset_8bit const& x);
78 basic_chset_8bit& operator-=(basic_chset_8bit const& x);
79 basic_chset_8bit& operator^=(basic_chset_8bit const& x);
81 private: std::bitset<256> bset;
84 /////////////////////////////////
86 class basic_chset<char>
87 : public basic_chset_8bit<char> {};
89 /////////////////////////////////
91 class basic_chset<signed char>
92 : public basic_chset_8bit<signed char> {};
94 /////////////////////////////////
96 class basic_chset<unsigned char>
97 : public basic_chset_8bit<unsigned char> {};
101 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
103 }} // namespace BOOST_SPIRIT_CLASSIC_NS
107 #include <boost/spirit/home/classic/utility/impl/chset/basic_chset.ipp>