~ubuntu-branches/ubuntu/warty/aqsis/warty

« back to all changes in this revision

Viewing changes to boost/boost/spirit/utility/chset.hpp

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2004-08-24 07:25:04 UTC
  • Revision ID: james.westby@ubuntu.com-20040824072504-zf993vnevvisdsvb
Tags: upstream-0.9.1
ImportĀ upstreamĀ versionĀ 0.9.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*=============================================================================
 
2
    Spirit v1.6.1
 
3
    Copyright (c) 2001-2003 Joel de Guzman
 
4
    Copyright (c) 2001-2003 Daniel Nuffer
 
5
    http://spirit.sourceforge.net/
 
6
 
 
7
    Permission to copy, use, modify, sell and distribute this software is
 
8
    granted provided this copyright notice appears in all copies. This
 
9
    software is provided "as is" without express or implied warranty, and
 
10
    with no claim as to its suitability for any purpose.
 
11
=============================================================================*/
 
12
#ifndef BOOST_SPIRIT_CHSET_HPP
 
13
#define BOOST_SPIRIT_CHSET_HPP
 
14
 
 
15
///////////////////////////////////////////////////////////////////////////////
 
16
#include <boost/shared_ptr.hpp>
 
17
#include <boost/spirit/core/primitives/primitives.hpp>
 
18
#include <boost/spirit/utility/impl/chset/basic_chset.hpp>
 
19
 
 
20
///////////////////////////////////////////////////////////////////////////////
 
21
namespace boost { namespace spirit {
 
22
 
 
23
namespace utility { namespace impl {
 
24
 
 
25
    // This is here because some compilers choke on out-of-line member
 
26
    // template functions.  And we don't want to put the whole algorithm
 
27
    // in the chset constructor in the class definition.
 
28
    template <typename CharT, typename CharT2>
 
29
    void construct_chset(boost::shared_ptr<basic_chset<CharT> >& ptr,
 
30
            CharT2 const* definition);
 
31
 
 
32
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
 
33
 
 
34
    template <typename CharT, typename FakeT>
 
35
    void chset_negated_set(boost::shared_ptr<basic_chset<CharT> > &ptr, chlit<CharT> const &ch,
 
36
            FakeT);
 
37
    
 
38
    template <typename CharT, typename FakeT>
 
39
    void chset_negated_set(boost::shared_ptr<basic_chset<CharT> > &ptr,
 
40
            spirit::range<CharT> const &rng, FakeT);
 
41
 
 
42
#endif // BOOST_WORKAROUND(BOOST_MSVC, < 1300)
 
43
}} // namespace utility::impl
 
44
 
 
45
///////////////////////////////////////////////////////////////////////////////
 
46
//
 
47
//  chset class
 
48
//
 
49
///////////////////////////////////////////////////////////////////////////////
 
50
template <typename CharT = char>
 
51
class chset: public char_parser<chset<CharT> > {
 
52
 
 
53
public:
 
54
                    chset();
 
55
                    chset(chset const& arg);
 
56
    explicit        chset(CharT arg);
 
57
    explicit        chset(anychar_parser arg);
 
58
    explicit        chset(nothing_parser arg);
 
59
    explicit        chset(chlit<CharT> const& arg);
 
60
    explicit        chset(range<CharT> const& arg);
 
61
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
 
62
                    template <typename ParserT>
 
63
    explicit        chset(negated_char_parser<ParserT> const& arg)
 
64
                    : ptr(new basic_chset<CharT>())
 
65
                    {
 
66
                        set(arg);
 
67
                    }
 
68
#else
 
69
    explicit        chset(negated_char_parser<chlit<CharT> > const& arg);
 
70
    explicit        chset(negated_char_parser<range<CharT> > const& arg);
 
71
#endif
 
72
 
 
73
                    template <typename CharT2>
 
74
    explicit        chset(CharT2 const* definition)
 
75
                    : ptr(new basic_chset<CharT>())
 
76
                    {
 
77
                        utility::impl::construct_chset(ptr, definition);
 
78
                    }
 
79
                    ~chset();
 
80
 
 
81
    chset&          operator=(chset const& rhs);
 
82
    chset&          operator=(CharT rhs);
 
83
    chset&          operator=(anychar_parser rhs);
 
84
    chset&          operator=(nothing_parser rhs);
 
85
    chset&          operator=(chlit<CharT> const& rhs);
 
86
    chset&          operator=(range<CharT> const& rhs);
 
87
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
 
88
                    template <typename ParserT>
 
89
    chset&          operator=(negated_char_parser<ParserT> const& rhs)
 
90
                    {
 
91
                        utility::impl::detach_clear(ptr);
 
92
                        set(rhs);
 
93
                        return *this;
 
94
                    }
 
95
        
 
96
#else
 
97
    chset&          operator=(negated_char_parser<chlit<CharT> > const& rhs);
 
98
    chset&          operator=(negated_char_parser<range<CharT> > const& rhs);
 
99
#endif
 
100
 
 
101
    void            set(range<CharT> const& arg);
 
102
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
 
103
                    template <typename ParserT>
 
104
    void            set(negated_char_parser<ParserT> const& arg)
 
105
                    {
 
106
                        utility::impl::detach(ptr);
 
107
                        utility::impl::chset_negated_set(ptr, arg.positive, 0);
 
108
                    }
 
109
#else
 
110
    void            set(negated_char_parser<chlit<CharT> > const& arg);
 
111
    void            set(negated_char_parser<range<CharT> > const& arg);
 
112
#endif
 
113
    void            clear(range<CharT> const& arg);
 
114
    void            clear(negated_char_parser<range<CharT> > const& arg);
 
115
    bool            test(CharT ch) const;
 
116
    chset&          inverse();
 
117
    void            swap(chset& x);
 
118
 
 
119
    chset&          operator|=(chset const& x);
 
120
    chset&          operator&=(chset const& x);
 
121
    chset&          operator-=(chset const& x);
 
122
    chset&          operator^=(chset const& x);
 
123
 
 
124
private:
 
125
 
 
126
    boost::shared_ptr<basic_chset<CharT> > ptr;
 
127
};
 
128
 
 
129
///////////////////////////////////////////////////////////////////////////////
 
130
//
 
131
//  Generator functions
 
132
//
 
133
///////////////////////////////////////////////////////////////////////////////
 
134
template <typename CharT>
 
135
inline chset<wchar_t>
 
136
chset_p(chlit<CharT> const& arg)
 
137
{ return chset<CharT>(arg); }
 
138
 
 
139
//////////////////////////////////
 
140
template <typename CharT>
 
141
inline chset<wchar_t>
 
142
chset_p(range<CharT> const& arg)
 
143
{ return chset<CharT>(arg); }
 
144
 
 
145
//////////////////////////////////
 
146
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
 
147
 
 
148
template <typename ParserT>
 
149
inline chset<wchar_t>
 
150
chset_p(negated_char_parser<ParserT> const& arg)
 
151
{ return chset<typename ParserT::char_t>(arg); }
 
152
 
 
153
#else // BOOST_WORKAROUND(BOOST_MSVC, < 1300)
 
154
 
 
155
template <typename CharT>
 
156
inline chset<wchar_t>
 
157
chset_p(negated_char_parser<chlit<CharT> > const& arg)
 
158
{ return chset<CharT>(arg); }
 
159
 
 
160
template <typename CharT>
 
161
inline chset<wchar_t>
 
162
chset_p(negated_char_parser<range<CharT> > const& arg)
 
163
{ return chset<CharT>(arg); }
 
164
 
 
165
#endif // BOOST_WORKAROUND(BOOST_MSVC, < 1300)
 
166
 
 
167
//////////////////////////////////
 
168
inline chset<char>
 
169
chset_p(char const* init)
 
170
{ return chset<char>(init); }
 
171
 
 
172
//////////////////////////////////
 
173
inline chset<wchar_t>
 
174
chset_p(wchar_t const* init)
 
175
{ return chset<wchar_t>(init); }
 
176
 
 
177
//////////////////////////////////
 
178
inline chset<char>
 
179
chset_p(char ch)
 
180
{ return chset<char>(ch); }
 
181
 
 
182
//////////////////////////////////
 
183
inline chset<wchar_t>
 
184
chset_p(wchar_t ch)
 
185
{ return chset<wchar_t>(ch); }
 
186
 
 
187
//////////////////////////////////
 
188
inline chset<int>
 
189
chset_p(int ch)
 
190
{ return chset<int>(ch); }
 
191
 
 
192
//////////////////////////////////
 
193
inline chset<unsigned int>
 
194
chset_p(unsigned int ch)
 
195
{ return chset<unsigned int>(ch); }
 
196
 
 
197
//////////////////////////////////
 
198
inline chset<short>
 
199
chset_p(short ch)
 
200
{ return chset<short>(ch); }
 
201
 
 
202
#if !defined(BOOST_NO_INTRINSIC_WCHAR_T)
 
203
//////////////////////////////////
 
204
inline chset<unsigned short>
 
205
chset_p(unsigned short ch)
 
206
{ return chset<unsigned short>(ch); }
 
207
#endif
 
208
//////////////////////////////////
 
209
inline chset<long>
 
210
chset_p(long ch)
 
211
{ return chset<long>(ch); }
 
212
 
 
213
//////////////////////////////////
 
214
inline chset<unsigned long>
 
215
chset_p(unsigned long ch)
 
216
{ return chset<unsigned long>(ch); }
 
217
 
 
218
#ifdef BOOST_HAS_LONG_LONG
 
219
//////////////////////////////////
 
220
inline chset<long long>
 
221
chset_p(long long ch)
 
222
{ return chset<long long>(ch); }
 
223
 
 
224
//////////////////////////////////
 
225
inline chset<unsigned long long>
 
226
chset_p(unsigned long long ch)
 
227
{ return chset<unsigned long long>(ch); }
 
228
#endif
 
229
 
 
230
///////////////////////////////////////////////////////////////////////////////
 
231
}} // namespace boost::spirit
 
232
 
 
233
#endif
 
234
 
 
235
#include <boost/spirit/utility/impl/chset.ipp>
 
236
#include <boost/spirit/utility/chset_operators.hpp>