source: NonGTP/Boost/boost/spirit/utility/chset.hpp @ 857

Revision 857, 6.0 KB checked in by igarcia, 19 years ago (diff)
RevLine 
[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_CHSET_HPP
11#define BOOST_SPIRIT_CHSET_HPP
12
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>
17
18///////////////////////////////////////////////////////////////////////////////
19namespace boost { namespace spirit {
20
21namespace utility { namespace impl {
22
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);
29
30}} // namespace utility::impl
31
32///////////////////////////////////////////////////////////////////////////////
33//
34//  chset class
35//
36///////////////////////////////////////////////////////////////////////////////
37template <typename CharT = char>
38class chset: public char_parser<chset<CharT> > {
39
40public:
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_);
50
51                    template <typename CharT2>
52    explicit        chset(CharT2 const* definition)
53                    : ptr(new basic_chset<CharT>())
54                    {
55                        utility::impl::construct_chset(ptr, definition);
56                    }
57                    ~chset();
58
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);
67
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_);
71
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);
77
78    chset&          operator|=(chset const& x);
79    chset&          operator&=(chset const& x);
80    chset&          operator-=(chset const& x);
81    chset&          operator^=(chset const& x);
82
83private:
84
85    boost::shared_ptr<basic_chset<CharT> > ptr;
86};
87
88///////////////////////////////////////////////////////////////////////////////
89//
90//  Generator functions
91//
92///////////////////////////////////////////////////////////////////////////////
93template <typename CharT>
94inline chset<CharT>
95chset_p(chlit<CharT> const& arg_)
96{ return chset<CharT>(arg_); }
97
98//////////////////////////////////
99template <typename CharT>
100inline chset<CharT>
101chset_p(range<CharT> const& arg_)
102{ return chset<CharT>(arg_); }
103
104template <typename CharT>
105inline chset<CharT>
106chset_p(negated_char_parser<chlit<CharT> > const& arg_)
107{ return chset<CharT>(arg_); }
108
109template <typename CharT>
110inline chset<CharT>
111chset_p(negated_char_parser<range<CharT> > const& arg_)
112{ return chset<CharT>(arg_); }
113
114//////////////////////////////////
115inline chset<char>
116chset_p(char const* init)
117{ return chset<char>(init); }
118
119//////////////////////////////////
120inline chset<wchar_t>
121chset_p(wchar_t const* init)
122{ return chset<wchar_t>(init); }
123
124//////////////////////////////////
125inline chset<char>
126chset_p(char ch)
127{ return chset<char>(ch); }
128
129//////////////////////////////////
130inline chset<wchar_t>
131chset_p(wchar_t ch)
132{ return chset<wchar_t>(ch); }
133
134//////////////////////////////////
135inline chset<int>
136chset_p(int ch)
137{ return chset<int>(ch); }
138
139//////////////////////////////////
140inline chset<unsigned int>
141chset_p(unsigned int ch)
142{ return chset<unsigned int>(ch); }
143
144//////////////////////////////////
145inline chset<short>
146chset_p(short ch)
147{ return chset<short>(ch); }
148
149#if !defined(BOOST_NO_INTRINSIC_WCHAR_T)
150//////////////////////////////////
151inline chset<unsigned short>
152chset_p(unsigned short ch)
153{ return chset<unsigned short>(ch); }
154#endif
155//////////////////////////////////
156inline chset<long>
157chset_p(long ch)
158{ return chset<long>(ch); }
159
160//////////////////////////////////
161inline chset<unsigned long>
162chset_p(unsigned long ch)
163{ return chset<unsigned long>(ch); }
164
165#ifdef BOOST_HAS_LONG_LONG
166//////////////////////////////////
167inline chset< ::boost::long_long_type>
168chset_p( ::boost::long_long_type ch)
169{ return chset< ::boost::long_long_type>(ch); }
170
171//////////////////////////////////
172inline chset< ::boost::ulong_long_type>
173chset_p( ::boost::ulong_long_type ch)
174{ return chset< ::boost::ulong_long_type>(ch); }
175#endif
176
177///////////////////////////////////////////////////////////////////////////////
178}} // namespace boost::spirit
179
180#endif
181
182#include <boost/spirit/utility/impl/chset.ipp>
183#include <boost/spirit/utility/chset_operators.hpp>
Note: See TracBrowser for help on using the repository browser.