sl@0
|
1 |
/*=============================================================================
|
sl@0
|
2 |
Copyright (c) 2001-2003 Joel de Guzman
|
sl@0
|
3 |
Copyright (c) 2001-2003 Daniel Nuffer
|
sl@0
|
4 |
http://spirit.sourceforge.net/
|
sl@0
|
5 |
|
sl@0
|
6 |
Use, modification and distribution is subject to the Boost Software
|
sl@0
|
7 |
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
sl@0
|
8 |
http://www.boost.org/LICENSE_1_0.txt)
|
sl@0
|
9 |
=============================================================================*/
|
sl@0
|
10 |
#ifndef BOOST_SPIRIT_CHSET_HPP
|
sl@0
|
11 |
#define BOOST_SPIRIT_CHSET_HPP
|
sl@0
|
12 |
|
sl@0
|
13 |
///////////////////////////////////////////////////////////////////////////////
|
sl@0
|
14 |
#include <boost/shared_ptr.hpp>
|
sl@0
|
15 |
#include <boost/spirit/core/primitives/primitives.hpp>
|
sl@0
|
16 |
#include <boost/spirit/utility/impl/chset/basic_chset.hpp>
|
sl@0
|
17 |
|
sl@0
|
18 |
///////////////////////////////////////////////////////////////////////////////
|
sl@0
|
19 |
namespace boost { namespace spirit {
|
sl@0
|
20 |
|
sl@0
|
21 |
namespace utility { namespace impl {
|
sl@0
|
22 |
|
sl@0
|
23 |
// This is here because some compilers choke on out-of-line member
|
sl@0
|
24 |
// template functions. And we don't want to put the whole algorithm
|
sl@0
|
25 |
// in the chset constructor in the class definition.
|
sl@0
|
26 |
template <typename CharT, typename CharT2>
|
sl@0
|
27 |
void construct_chset(boost::shared_ptr<basic_chset<CharT> >& ptr,
|
sl@0
|
28 |
CharT2 const* definition);
|
sl@0
|
29 |
|
sl@0
|
30 |
}} // namespace utility::impl
|
sl@0
|
31 |
|
sl@0
|
32 |
///////////////////////////////////////////////////////////////////////////////
|
sl@0
|
33 |
//
|
sl@0
|
34 |
// chset class
|
sl@0
|
35 |
//
|
sl@0
|
36 |
///////////////////////////////////////////////////////////////////////////////
|
sl@0
|
37 |
template <typename CharT = char>
|
sl@0
|
38 |
class chset: public char_parser<chset<CharT> > {
|
sl@0
|
39 |
|
sl@0
|
40 |
public:
|
sl@0
|
41 |
chset();
|
sl@0
|
42 |
chset(chset const& arg_);
|
sl@0
|
43 |
explicit chset(CharT arg_);
|
sl@0
|
44 |
explicit chset(anychar_parser arg_);
|
sl@0
|
45 |
explicit chset(nothing_parser arg_);
|
sl@0
|
46 |
explicit chset(chlit<CharT> const& arg_);
|
sl@0
|
47 |
explicit chset(range<CharT> const& arg_);
|
sl@0
|
48 |
explicit chset(negated_char_parser<chlit<CharT> > const& arg_);
|
sl@0
|
49 |
explicit chset(negated_char_parser<range<CharT> > const& arg_);
|
sl@0
|
50 |
|
sl@0
|
51 |
template <typename CharT2>
|
sl@0
|
52 |
explicit chset(CharT2 const* definition)
|
sl@0
|
53 |
: ptr(new basic_chset<CharT>())
|
sl@0
|
54 |
{
|
sl@0
|
55 |
utility::impl::construct_chset(ptr, definition);
|
sl@0
|
56 |
}
|
sl@0
|
57 |
~chset();
|
sl@0
|
58 |
|
sl@0
|
59 |
chset& operator=(chset const& rhs);
|
sl@0
|
60 |
chset& operator=(CharT rhs);
|
sl@0
|
61 |
chset& operator=(anychar_parser rhs);
|
sl@0
|
62 |
chset& operator=(nothing_parser rhs);
|
sl@0
|
63 |
chset& operator=(chlit<CharT> const& rhs);
|
sl@0
|
64 |
chset& operator=(range<CharT> const& rhs);
|
sl@0
|
65 |
chset& operator=(negated_char_parser<chlit<CharT> > const& rhs);
|
sl@0
|
66 |
chset& operator=(negated_char_parser<range<CharT> > const& rhs);
|
sl@0
|
67 |
|
sl@0
|
68 |
void set(range<CharT> const& arg_);
|
sl@0
|
69 |
void set(negated_char_parser<chlit<CharT> > const& arg_);
|
sl@0
|
70 |
void set(negated_char_parser<range<CharT> > const& arg_);
|
sl@0
|
71 |
|
sl@0
|
72 |
void clear(range<CharT> const& arg_);
|
sl@0
|
73 |
void clear(negated_char_parser<range<CharT> > const& arg_);
|
sl@0
|
74 |
bool test(CharT ch) const;
|
sl@0
|
75 |
chset& inverse();
|
sl@0
|
76 |
void swap(chset& x);
|
sl@0
|
77 |
|
sl@0
|
78 |
chset& operator|=(chset const& x);
|
sl@0
|
79 |
chset& operator&=(chset const& x);
|
sl@0
|
80 |
chset& operator-=(chset const& x);
|
sl@0
|
81 |
chset& operator^=(chset const& x);
|
sl@0
|
82 |
|
sl@0
|
83 |
private:
|
sl@0
|
84 |
|
sl@0
|
85 |
boost::shared_ptr<basic_chset<CharT> > ptr;
|
sl@0
|
86 |
};
|
sl@0
|
87 |
|
sl@0
|
88 |
///////////////////////////////////////////////////////////////////////////////
|
sl@0
|
89 |
//
|
sl@0
|
90 |
// Generator functions
|
sl@0
|
91 |
//
|
sl@0
|
92 |
///////////////////////////////////////////////////////////////////////////////
|
sl@0
|
93 |
template <typename CharT>
|
sl@0
|
94 |
inline chset<CharT>
|
sl@0
|
95 |
chset_p(chlit<CharT> const& arg_)
|
sl@0
|
96 |
{ return chset<CharT>(arg_); }
|
sl@0
|
97 |
|
sl@0
|
98 |
//////////////////////////////////
|
sl@0
|
99 |
template <typename CharT>
|
sl@0
|
100 |
inline chset<CharT>
|
sl@0
|
101 |
chset_p(range<CharT> const& arg_)
|
sl@0
|
102 |
{ return chset<CharT>(arg_); }
|
sl@0
|
103 |
|
sl@0
|
104 |
template <typename CharT>
|
sl@0
|
105 |
inline chset<CharT>
|
sl@0
|
106 |
chset_p(negated_char_parser<chlit<CharT> > const& arg_)
|
sl@0
|
107 |
{ return chset<CharT>(arg_); }
|
sl@0
|
108 |
|
sl@0
|
109 |
template <typename CharT>
|
sl@0
|
110 |
inline chset<CharT>
|
sl@0
|
111 |
chset_p(negated_char_parser<range<CharT> > const& arg_)
|
sl@0
|
112 |
{ return chset<CharT>(arg_); }
|
sl@0
|
113 |
|
sl@0
|
114 |
//////////////////////////////////
|
sl@0
|
115 |
inline chset<char>
|
sl@0
|
116 |
chset_p(char const* init)
|
sl@0
|
117 |
{ return chset<char>(init); }
|
sl@0
|
118 |
|
sl@0
|
119 |
//////////////////////////////////
|
sl@0
|
120 |
inline chset<wchar_t>
|
sl@0
|
121 |
chset_p(wchar_t const* init)
|
sl@0
|
122 |
{ return chset<wchar_t>(init); }
|
sl@0
|
123 |
|
sl@0
|
124 |
//////////////////////////////////
|
sl@0
|
125 |
inline chset<char>
|
sl@0
|
126 |
chset_p(char ch)
|
sl@0
|
127 |
{ return chset<char>(ch); }
|
sl@0
|
128 |
|
sl@0
|
129 |
//////////////////////////////////
|
sl@0
|
130 |
inline chset<wchar_t>
|
sl@0
|
131 |
chset_p(wchar_t ch)
|
sl@0
|
132 |
{ return chset<wchar_t>(ch); }
|
sl@0
|
133 |
|
sl@0
|
134 |
//////////////////////////////////
|
sl@0
|
135 |
inline chset<int>
|
sl@0
|
136 |
chset_p(int ch)
|
sl@0
|
137 |
{ return chset<int>(ch); }
|
sl@0
|
138 |
|
sl@0
|
139 |
//////////////////////////////////
|
sl@0
|
140 |
inline chset<unsigned int>
|
sl@0
|
141 |
chset_p(unsigned int ch)
|
sl@0
|
142 |
{ return chset<unsigned int>(ch); }
|
sl@0
|
143 |
|
sl@0
|
144 |
//////////////////////////////////
|
sl@0
|
145 |
inline chset<short>
|
sl@0
|
146 |
chset_p(short ch)
|
sl@0
|
147 |
{ return chset<short>(ch); }
|
sl@0
|
148 |
|
sl@0
|
149 |
#if !defined(BOOST_NO_INTRINSIC_WCHAR_T)
|
sl@0
|
150 |
//////////////////////////////////
|
sl@0
|
151 |
inline chset<unsigned short>
|
sl@0
|
152 |
chset_p(unsigned short ch)
|
sl@0
|
153 |
{ return chset<unsigned short>(ch); }
|
sl@0
|
154 |
#endif
|
sl@0
|
155 |
//////////////////////////////////
|
sl@0
|
156 |
inline chset<long>
|
sl@0
|
157 |
chset_p(long ch)
|
sl@0
|
158 |
{ return chset<long>(ch); }
|
sl@0
|
159 |
|
sl@0
|
160 |
//////////////////////////////////
|
sl@0
|
161 |
inline chset<unsigned long>
|
sl@0
|
162 |
chset_p(unsigned long ch)
|
sl@0
|
163 |
{ return chset<unsigned long>(ch); }
|
sl@0
|
164 |
|
sl@0
|
165 |
#ifdef BOOST_HAS_LONG_LONG
|
sl@0
|
166 |
//////////////////////////////////
|
sl@0
|
167 |
inline chset< ::boost::long_long_type>
|
sl@0
|
168 |
chset_p( ::boost::long_long_type ch)
|
sl@0
|
169 |
{ return chset< ::boost::long_long_type>(ch); }
|
sl@0
|
170 |
|
sl@0
|
171 |
//////////////////////////////////
|
sl@0
|
172 |
inline chset< ::boost::ulong_long_type>
|
sl@0
|
173 |
chset_p( ::boost::ulong_long_type ch)
|
sl@0
|
174 |
{ return chset< ::boost::ulong_long_type>(ch); }
|
sl@0
|
175 |
#endif
|
sl@0
|
176 |
|
sl@0
|
177 |
///////////////////////////////////////////////////////////////////////////////
|
sl@0
|
178 |
}} // namespace boost::spirit
|
sl@0
|
179 |
|
sl@0
|
180 |
#endif
|
sl@0
|
181 |
|
sl@0
|
182 |
#include <boost/spirit/utility/impl/chset.ipp>
|
sl@0
|
183 |
#include <boost/spirit/utility/chset_operators.hpp>
|