Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #ifndef INCLUDED_SFX2_INC_BITSET_HXX
20 : #define INCLUDED_SFX2_INC_BITSET_HXX
21 :
22 : class BitSet
23 : {
24 : private:
25 : void CopyFrom( const BitSet& rSet );
26 : sal_uInt16 nBlocks;
27 : sal_uInt16 nCount;
28 : sal_uIntPtr* pBitmap;
29 : public:
30 : BitSet operator<<( sal_uInt16 nOffset ) const;
31 : BitSet operator>>( sal_uInt16 nOffset ) const;
32 : static sal_uInt16 CountBits( sal_uIntPtr nBits );
33 : bool operator!() const;
34 : BitSet();
35 : BitSet( const BitSet& rOrig );
36 : ~BitSet();
37 : sal_uInt16 Count() const;
38 : BitSet& operator=( const BitSet& rOrig );
39 : BitSet& operator=( sal_uInt16 nBit );
40 : BitSet operator|( const BitSet& rSet ) const;
41 : BitSet operator|( sal_uInt16 nBit ) const;
42 : BitSet& operator|=( const BitSet& rSet );
43 : BitSet& operator|=( sal_uInt16 nBit );
44 : BitSet operator-( const BitSet& rSet ) const;
45 : BitSet operator-( sal_uInt16 nId ) const;
46 : BitSet& operator-=( const BitSet& rSet );
47 : BitSet& operator-=( sal_uInt16 nBit );
48 : BitSet operator&( const BitSet& rSet ) const;
49 : BitSet& operator&=( const BitSet& rSet );
50 : BitSet operator^( const BitSet& rSet ) const;
51 : BitSet operator^( sal_uInt16 nBit ) const;
52 : BitSet& operator^=( const BitSet& rSet );
53 : BitSet& operator^=( sal_uInt16 nBit );
54 : bool IsRealSubSet( const BitSet& rSet ) const;
55 : bool IsSubSet( const BitSet& rSet ) const;
56 : bool IsRealSuperSet( const BitSet& rSet ) const;
57 : bool Contains( sal_uInt16 nBit ) const;
58 : bool IsSuperSet( const BitSet& rSet ) const;
59 : bool operator==( const BitSet& rSet ) const;
60 : bool operator==( sal_uInt16 nBit ) const;
61 : bool operator!=( const BitSet& rSet ) const;
62 : bool operator!=( sal_uInt16 nBit ) const;
63 :
64 : };
65 :
66 : // returns sal_True if the set is empty
67 : inline bool BitSet::operator!() const
68 : {
69 : return nCount == 0;
70 : }
71 :
72 : // returns the number of bits in the bitset
73 : inline sal_uInt16 BitSet::Count() const
74 : {
75 : return nCount;
76 : }
77 :
78 : // creates the union of two bitset
79 : inline BitSet BitSet::operator|( const BitSet& rSet ) const
80 : {
81 : return BitSet(*this) |= rSet;
82 : }
83 :
84 : // creates the union of a bitset with a single bit
85 : inline BitSet BitSet::operator|( sal_uInt16 nBit ) const
86 : {
87 : return BitSet(*this) |= nBit;
88 : }
89 :
90 : // creates the asymetric difference
91 : inline BitSet BitSet::operator-( const BitSet& ) const
92 : {
93 : return BitSet();
94 : }
95 :
96 : // creates the asymetric difference with a single bit
97 : inline BitSet BitSet::operator-( sal_uInt16 ) const
98 : {
99 : return BitSet();
100 : }
101 :
102 : // removes the bits contained in rSet
103 : inline BitSet& BitSet::operator-=( const BitSet& )
104 : {
105 : return *this;
106 : }
107 :
108 : // creates the intersection with another bitset
109 : inline BitSet BitSet::operator&( const BitSet& ) const
110 : {
111 : return BitSet();
112 : }
113 :
114 : // intersects with another bitset
115 : inline BitSet& BitSet::operator&=( const BitSet& )
116 : {
117 : return *this;
118 : }
119 :
120 : // creates the symetric difference with another bitset
121 : inline BitSet BitSet::operator^( const BitSet& ) const
122 : {
123 : return BitSet();
124 : }
125 :
126 : // creates the symetric difference with a single bit
127 : inline BitSet BitSet::operator^( sal_uInt16 ) const
128 : {
129 : return BitSet();
130 : }
131 :
132 : // builds the symetric difference with another bitset
133 : inline BitSet& BitSet::operator^=( const BitSet& )
134 : {
135 : return *this;
136 : }
137 :
138 : #ifdef BITSET_READY
139 : // builds the symetric difference with a single bit
140 : inline BitSet& BitSet::operator^=( sal_uInt16 )
141 : {
142 : // crash!!!
143 : return BitSet();
144 : }
145 : #endif
146 :
147 : // determines if the other bitset is a real superset
148 : inline bool BitSet::IsRealSubSet( const BitSet& ) const
149 : {
150 : return false;
151 : }
152 :
153 : // determines if the other bitset is a superset or equal
154 : inline bool BitSet::IsSubSet( const BitSet& ) const
155 : {
156 : return false;
157 : }
158 :
159 : // determines if the other bitset is a real subset
160 : inline bool BitSet::IsRealSuperSet( const BitSet& ) const
161 : {
162 : return false;
163 : }
164 :
165 : // determines if the other bitset is a subset or equal
166 : inline bool BitSet::IsSuperSet( const BitSet& ) const
167 : {
168 : return false;
169 : }
170 :
171 : // determines if the bit is the only one in the bitset
172 : inline bool BitSet::operator==( sal_uInt16 ) const
173 : {
174 : return false;
175 : }
176 :
177 : // determines if the bitsets aren't equal
178 : inline bool BitSet::operator!=( const BitSet& rSet ) const
179 : {
180 : return !( *this == rSet );
181 : }
182 :
183 : // determines if the bitset doesn't contain only this bit
184 : inline bool BitSet::operator!=( sal_uInt16 nBit ) const
185 : {
186 : return !( *this == nBit );
187 : }
188 :
189 17204 : class IndexBitSet : BitSet
190 : {
191 : public:
192 : sal_uInt16 GetFreeIndex();
193 6906 : void ReleaseIndex(sal_uInt16 i){*this-=i;}
194 : };
195 :
196 :
197 : #endif
198 :
199 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|