Improve vacpp support.
[boost.git] / boost / boost / spirit / utility / chset.hpp
blob4273d1ce24e81b595916f11fe89ab45badff14e6
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_CHSET_HPP
11 #define BOOST_SPIRIT_CHSET_HPP
13 ///////////////////////////////////////////////////////////////////////////////
14 #include <boost/shared_ptr.hpp>
15 #include <boost/spirit/core/primitives/primitives.hpp>
16 #include <boost/spirit/utility/impl/chset/basic_chset.hpp>
18 ///////////////////////////////////////////////////////////////////////////////
19 namespace boost { namespace spirit {
21 namespace utility { namespace impl {
23 // This is here because some compilers choke on out-of-line member
24 // template functions. And we don't want to put the whole algorithm
25 // in the chset constructor in the class definition.
26 template <typename CharT, typename CharT2>
27 void construct_chset(boost::shared_ptr<basic_chset<CharT> >& ptr,
28 CharT2 const* definition);
30 }} // namespace utility::impl
32 ///////////////////////////////////////////////////////////////////////////////
34 // chset class
36 ///////////////////////////////////////////////////////////////////////////////
37 template <typename CharT = char>
38 class chset: public char_parser<chset<CharT> > {
40 public:
41 chset();
42 chset(chset const& arg_);
43 explicit chset(CharT arg_);
44 explicit chset(anychar_parser arg_);
45 explicit chset(nothing_parser arg_);
46 explicit chset(chlit<CharT> const& arg_);
47 explicit chset(range<CharT> const& arg_);
48 explicit chset(negated_char_parser<chlit<CharT> > const& arg_);
49 explicit chset(negated_char_parser<range<CharT> > const& arg_);
51 template <typename CharT2>
52 explicit chset(CharT2 const* definition)
53 : ptr(new basic_chset<CharT>())
55 utility::impl::construct_chset(ptr, definition);
57 ~chset();
59 chset& operator=(chset const& rhs);
60 chset& operator=(CharT rhs);
61 chset& operator=(anychar_parser rhs);
62 chset& operator=(nothing_parser rhs);
63 chset& operator=(chlit<CharT> const& rhs);
64 chset& operator=(range<CharT> const& rhs);
65 chset& operator=(negated_char_parser<chlit<CharT> > const& rhs);
66 chset& operator=(negated_char_parser<range<CharT> > const& rhs);
68 void set(range<CharT> const& arg_);
69 void set(negated_char_parser<chlit<CharT> > const& arg_);
70 void set(negated_char_parser<range<CharT> > const& arg_);
72 void clear(range<CharT> const& arg_);
73 void clear(negated_char_parser<range<CharT> > const& arg_);
74 bool test(CharT ch) const;
75 chset& inverse();
76 void swap(chset& x);
78 chset& operator|=(chset const& x);
79 chset& operator&=(chset const& x);
80 chset& operator-=(chset const& x);
81 chset& operator^=(chset const& x);
83 private:
85 boost::shared_ptr<basic_chset<CharT> > ptr;
88 ///////////////////////////////////////////////////////////////////////////////
90 // Generator functions
92 ///////////////////////////////////////////////////////////////////////////////
93 template <typename CharT>
94 inline chset<CharT>
95 chset_p(chlit<CharT> const& arg_)
96 { return chset<CharT>(arg_); }
98 //////////////////////////////////
99 template <typename CharT>
100 inline chset<CharT>
101 chset_p(range<CharT> const& arg_)
102 { return chset<CharT>(arg_); }
104 template <typename CharT>
105 inline chset<CharT>
106 chset_p(negated_char_parser<chlit<CharT> > const& arg_)
107 { return chset<CharT>(arg_); }
109 template <typename CharT>
110 inline chset<CharT>
111 chset_p(negated_char_parser<range<CharT> > const& arg_)
112 { return chset<CharT>(arg_); }
114 //////////////////////////////////
115 inline chset<char>
116 chset_p(char const* init)
117 { return chset<char>(init); }
119 //////////////////////////////////
120 inline chset<wchar_t>
121 chset_p(wchar_t const* init)
122 { return chset<wchar_t>(init); }
124 //////////////////////////////////
125 inline chset<char>
126 chset_p(char ch)
127 { return chset<char>(ch); }
129 //////////////////////////////////
130 inline chset<wchar_t>
131 chset_p(wchar_t ch)
132 { return chset<wchar_t>(ch); }
134 //////////////////////////////////
135 inline chset<int>
136 chset_p(int ch)
137 { return chset<int>(ch); }
139 //////////////////////////////////
140 inline chset<unsigned int>
141 chset_p(unsigned int ch)
142 { return chset<unsigned int>(ch); }
144 //////////////////////////////////
145 inline chset<short>
146 chset_p(short ch)
147 { return chset<short>(ch); }
149 #if !defined(BOOST_NO_INTRINSIC_WCHAR_T)
150 //////////////////////////////////
151 inline chset<unsigned short>
152 chset_p(unsigned short ch)
153 { return chset<unsigned short>(ch); }
154 #endif
155 //////////////////////////////////
156 inline chset<long>
157 chset_p(long ch)
158 { return chset<long>(ch); }
160 //////////////////////////////////
161 inline chset<unsigned long>
162 chset_p(unsigned long ch)
163 { return chset<unsigned long>(ch); }
165 #ifdef BOOST_HAS_LONG_LONG
166 //////////////////////////////////
167 inline chset< ::boost::long_long_type>
168 chset_p( ::boost::long_long_type ch)
169 { return chset< ::boost::long_long_type>(ch); }
171 //////////////////////////////////
172 inline chset< ::boost::ulong_long_type>
173 chset_p( ::boost::ulong_long_type ch)
174 { return chset< ::boost::ulong_long_type>(ch); }
175 #endif
177 ///////////////////////////////////////////////////////////////////////////////
178 }} // namespace boost::spirit
180 #endif
182 #include <boost/spirit/utility/impl/chset.ipp>
183 #include <boost/spirit/utility/chset_operators.hpp>