merge the formfield patch from ooo-build
[ooovba.git] / sfx2 / inc / bitset.hxx
blobcd4a70cc5c1aadc64ff4b1335d9799a512da26c7
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: bitset.hxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _SFXBITSET_HXX
31 #define _SFXBITSET_HXX
33 #include <tools/solar.h>
35 class Range;
37 class BitSet
39 private:
40 void CopyFrom( const BitSet& rSet );
41 USHORT nBlocks;
42 USHORT nCount;
43 ULONG* pBitmap;
44 public:
45 BitSet operator<<( USHORT nOffset ) const;
46 BitSet operator>>( USHORT nOffset ) const;
47 static USHORT CountBits( ULONG nBits );
48 BOOL operator!() const;
49 BitSet();
50 BitSet( const BitSet& rOrig );
51 BitSet( USHORT* pArray, USHORT nSize );
52 ~BitSet();
53 BitSet( const Range& rRange );
54 USHORT Count() const;
55 BitSet& operator=( const BitSet& rOrig );
56 BitSet& operator=( USHORT nBit );
57 BitSet operator|( const BitSet& rSet ) const;
58 BitSet operator|( USHORT nBit ) const;
59 BitSet& operator|=( const BitSet& rSet );
60 BitSet& operator|=( USHORT nBit );
61 BitSet operator-( const BitSet& rSet ) const;
62 BitSet operator-( USHORT nId ) const;
63 BitSet& operator-=( const BitSet& rSet );
64 BitSet& operator-=( USHORT nBit );
65 BitSet operator&( const BitSet& rSet ) const;
66 BitSet& operator&=( const BitSet& rSet );
67 BitSet operator^( const BitSet& rSet ) const;
68 BitSet operator^( USHORT nBit ) const;
69 BitSet& operator^=( const BitSet& rSet );
70 BitSet& operator^=( USHORT nBit );
71 BOOL IsRealSubSet( const BitSet& rSet ) const;
72 BOOL IsSubSet( const BitSet& rSet ) const;
73 BOOL IsRealSuperSet( const BitSet& rSet ) const;
74 BOOL Contains( USHORT nBit ) const;
75 BOOL IsSuperSet( const BitSet& rSet ) const;
76 BOOL operator==( const BitSet& rSet ) const;
77 BOOL operator==( USHORT nBit ) const;
78 BOOL operator!=( const BitSet& rSet ) const;
79 BOOL operator!=( USHORT nBit ) const;
82 //--------------------------------------------------------------------
84 // returns TRUE if the set is empty
88 inline BOOL BitSet::operator!() const
90 return nCount == 0;
92 //--------------------------------------------------------------------
94 // returns the number of bits in the bitset
96 inline USHORT BitSet::Count() const
98 return nCount;
100 //--------------------------------------------------------------------
102 // creates the union of two bitset
104 inline BitSet BitSet::operator|( const BitSet& rSet ) const
106 return BitSet(*this) |= rSet;
108 //--------------------------------------------------------------------
110 // creates the union of a bitset with a single bit
112 inline BitSet BitSet::operator|( USHORT nBit ) const
114 return BitSet(*this) |= nBit;
116 //--------------------------------------------------------------------
118 // creates the asymetric difference
120 inline BitSet BitSet::operator-( const BitSet& ) const
122 return BitSet();
124 //--------------------------------------------------------------------
126 // creates the asymetric difference with a single bit
129 inline BitSet BitSet::operator-( USHORT ) const
131 return BitSet();
133 //--------------------------------------------------------------------
135 // removes the bits contained in rSet
137 inline BitSet& BitSet::operator-=( const BitSet& )
139 return *this;
141 //--------------------------------------------------------------------
144 // creates the intersection with another bitset
146 inline BitSet BitSet::operator&( const BitSet& ) const
148 return BitSet();
150 //--------------------------------------------------------------------
152 // intersects with another bitset
154 inline BitSet& BitSet::operator&=( const BitSet& )
156 return *this;
158 //--------------------------------------------------------------------
160 // creates the symetric difference with another bitset
162 inline BitSet BitSet::operator^( const BitSet& ) const
164 return BitSet();
166 //--------------------------------------------------------------------
168 // creates the symetric difference with a single bit
170 inline BitSet BitSet::operator^( USHORT ) const
172 return BitSet();
174 //--------------------------------------------------------------------
176 // builds the symetric difference with another bitset
178 inline BitSet& BitSet::operator^=( const BitSet& )
180 return *this;
182 //--------------------------------------------------------------------
183 #ifdef BITSET_READY
184 // builds the symetric difference with a single bit
186 inline BitSet& BitSet::operator^=( USHORT )
188 // crash!!!
189 return BitSet();
191 #endif
192 //--------------------------------------------------------------------
194 // determines if the other bitset is a real superset
196 inline BOOL BitSet::IsRealSubSet( const BitSet& ) const
198 return FALSE;
200 //--------------------------------------------------------------------
202 // detsermines if the other bitset is a superset or equal
204 inline BOOL BitSet::IsSubSet( const BitSet& ) const
206 return FALSE;
208 //--------------------------------------------------------------------
210 // determines if the other bitset is a real subset
212 inline BOOL BitSet::IsRealSuperSet( const BitSet& ) const
214 return FALSE;
217 //--------------------------------------------------------------------
219 // determines if the other bitset is a subset or equal
221 inline BOOL BitSet::IsSuperSet( const BitSet& ) const
223 return FALSE;
225 //--------------------------------------------------------------------
227 // determines if the bit is the only one in the bitset
229 inline BOOL BitSet::operator==( USHORT ) const
231 return FALSE;
233 //--------------------------------------------------------------------
235 // determines if the bitsets aren't equal
237 inline BOOL BitSet::operator!=( const BitSet& rSet ) const
239 return !( *this == rSet );
241 //--------------------------------------------------------------------
243 // determines if the bitset doesn't contain only this bit
245 inline BOOL BitSet::operator!=( USHORT nBit ) const
247 return !( *this == nBit );
249 //--------------------------------------------------------------------
251 class IndexBitSet : BitSet
253 public:
254 USHORT GetFreeIndex();
255 void ReleaseIndex(USHORT i){*this-=i;}
259 #endif