]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/xpressive/include/boost/xpressive/detail/utility/chset/basic_chset.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / xpressive / include / boost / xpressive / detail / utility / chset / basic_chset.hpp
CommitLineData
7c673cae
FG
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_XPRESSIVE_SPIRIT_BASIC_CHSET_HPP_EAN_10_04_2005
11#define BOOST_XPRESSIVE_SPIRIT_BASIC_CHSET_HPP_EAN_10_04_2005
12
13///////////////////////////////////////////////////////////////////////////////
14#include <bitset>
15#include <boost/mpl/bool.hpp>
16#include <boost/xpressive/detail/utility/chset/range_run.ipp>
17
18namespace boost { namespace xpressive { namespace detail
19{
20
21///////////////////////////////////////////////////////////////////////////
22//
23// basic_chset: basic character set implementation using range_run
24//
25///////////////////////////////////////////////////////////////////////////
26template<typename Char>
27struct basic_chset
28{
29 basic_chset();
30 basic_chset(basic_chset const &arg);
31
32 bool empty() const;
33 void set(Char from, Char to);
34 template<typename Traits>
35 void set(Char from, Char to, Traits const &tr);
36 void set(Char c);
37 template<typename Traits>
38 void set(Char c, Traits const &tr);
39
40 void clear(Char from, Char to);
41 template<typename Traits>
42 void clear(Char from, Char to, Traits const &tr);
43 void clear(Char c);
44 template<typename Traits>
45 void clear(Char c, Traits const &tr);
46 void clear();
47
48 template<typename Traits>
49 bool test(Char v, Traits const &tr, mpl::false_) const; // case-sensitive
50 template<typename Traits>
51 bool test(Char v, Traits const &tr, mpl::true_) const; // case-insensitive
52
53 void inverse();
54 void swap(basic_chset& x);
55
56 basic_chset &operator |=(basic_chset const &x);
57 basic_chset &operator &=(basic_chset const &x);
58 basic_chset &operator -=(basic_chset const &x);
59 basic_chset &operator ^=(basic_chset const &x);
60
61private:
62 range_run<Char> rr_;
63};
64
65#if(CHAR_BIT == 8)
66
67///////////////////////////////////////////////////////////////////////////
68//
69// basic_chset: specializations for 8 bit chars using std::bitset
70//
71///////////////////////////////////////////////////////////////////////////
72template<typename Char>
73struct basic_chset_8bit
74{
75 basic_chset_8bit();
76 basic_chset_8bit(basic_chset_8bit const &arg);
77
78 bool empty() const;
79
80 void set(Char from, Char to);
81 template<typename Traits>
82 void set(Char from, Char to, Traits const &tr);
83 void set(Char c);
84 template<typename Traits>
85 void set(Char c, Traits const &tr);
86
87 void clear(Char from, Char to);
88 template<typename Traits>
89 void clear(Char from, Char to, Traits const &tr);
90 void clear(Char c);
91 template<typename Traits>
92 void clear(Char c, Traits const &tr);
93 void clear();
94
95 template<typename Traits>
96 bool test(Char v, Traits const &tr, mpl::false_) const; // case-sensitive
97 template<typename Traits>
98 bool test(Char v, Traits const &tr, mpl::true_) const; // case-insensitive
99
100 void inverse();
101 void swap(basic_chset_8bit& x);
102
103 basic_chset_8bit &operator |=(basic_chset_8bit const &x);
104 basic_chset_8bit &operator &=(basic_chset_8bit const &x);
105 basic_chset_8bit &operator -=(basic_chset_8bit const &x);
106 basic_chset_8bit &operator ^=(basic_chset_8bit const &x);
107
108 std::bitset<256> const &base() const;
109
110private:
111 std::bitset<256> bset_; // BUGBUG range-checking slows this down
112};
113
114/////////////////////////////////
115template<>
116struct basic_chset<char>
117 : basic_chset_8bit<char>
118{
119};
120
121/////////////////////////////////
122template<>
123struct basic_chset<signed char>
124 : basic_chset_8bit<signed char>
125{
126};
127
128/////////////////////////////////
129template<>
130struct basic_chset<unsigned char>
131 : basic_chset_8bit<unsigned char>
132{
133};
134
135#endif
136
137///////////////////////////////////////////////////////////////////////////////
138// is_narrow_char
139template<typename Char>
140struct is_narrow_char
141 : mpl::false_
142{};
143
144template<>
145struct is_narrow_char<char>
146 : mpl::true_
147{};
148
149template<>
150struct is_narrow_char<signed char>
151 : mpl::true_
152{};
153
154template<>
155struct is_narrow_char<unsigned char>
156 : mpl::true_
157{};
158
159///////////////////////////////////////////////////////////////////////////////
160// helpers
161template<typename Char, typename Traits>
162void set_char(basic_chset<Char> &chset, Char ch, Traits const &tr, bool icase);
163
164template<typename Char, typename Traits>
165void set_range(basic_chset<Char> &chset, Char from, Char to, Traits const &tr, bool icase);
166
167template<typename Char, typename Traits>
168void set_class(basic_chset<Char> &chset, typename Traits::char_class_type char_class, bool no, Traits const &tr);
169
170}}} // namespace boost::xpressive::detail
171
172#endif