Update ooo320-m1
[ooovba.git] / binfilter / inc / bf_sfx2 / bitset.hxx
blobab2b844e04f7a2ecc6ff51a4c1c92ee0054b8ba2
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.6 $
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 #ifndef _SOLAR_H
34 #include <tools/solar.h>
35 #endif
36 class Range;
37 namespace binfilter {
40 class BitSet
42 private:
43 void CopyFrom( const BitSet& rSet );
44 USHORT nBlocks;
45 USHORT nCount;
46 ULONG* pBitmap;
47 public:
48 BitSet operator<<( USHORT nOffset ) const;
49 static USHORT CountBits( ULONG nBits );
50 BOOL operator!() const;
51 BitSet();
52 BitSet( const BitSet& rOrig );
53 ~BitSet();
54 USHORT Count() const;
55 BitSet operator|( const BitSet& rSet ) const;
56 BitSet operator|( USHORT nBit ) const;
57 BitSet& operator|=( const BitSet& rSet );
58 BitSet& operator|=( USHORT nBit );
59 BitSet operator-( const BitSet& rSet ) const;
60 BitSet operator-( USHORT nId ) const;
61 BitSet& operator-=( const BitSet& rSet );
62 BitSet& operator-=( USHORT nBit );
63 BitSet operator&( const BitSet& rSet ) const;
64 BitSet& operator&=( const BitSet& rSet );
65 BitSet operator^( const BitSet& rSet ) const;
66 BitSet operator^( USHORT nBit ) const;
67 BitSet& operator^=( const BitSet& rSet );
68 BitSet& operator^=( USHORT nBit );
69 BOOL IsRealSubSet( const BitSet& rSet ) const;
70 BOOL IsSubSet( const BitSet& rSet ) const;
71 BOOL IsRealSuperSet( const BitSet& rSet ) const;
72 BOOL IsSuperSet( const BitSet& rSet ) const;
73 BOOL operator==( USHORT nBit ) const;
74 BOOL operator!=( USHORT nBit ) const;
77 //--------------------------------------------------------------------
79 // returns TRUE if the set is empty
83 inline BOOL BitSet::operator!() const
85 return nCount == 0;
87 //--------------------------------------------------------------------
89 // returns the number of bits in the bitset
91 inline USHORT BitSet::Count() const
93 return nCount;
95 //--------------------------------------------------------------------
97 // creates the union of two bitset
99 inline BitSet BitSet::operator|( const BitSet& rSet ) const
101 return BitSet(*this) |= rSet;
103 //--------------------------------------------------------------------
105 // creates the union of a bitset with a single bit
107 inline BitSet BitSet::operator|( USHORT nBit ) const
109 return BitSet(*this) |= nBit;
111 //--------------------------------------------------------------------
113 // creates the asymetric difference
115 inline BitSet BitSet::operator-( const BitSet& rSet ) const
117 return BitSet();
119 //--------------------------------------------------------------------
121 // creates the asymetric difference with a single bit
124 inline BitSet BitSet::operator-( USHORT nId ) const
126 return BitSet();
128 //--------------------------------------------------------------------
130 // removes the bits contained in rSet
132 inline BitSet& BitSet::operator-=( const BitSet& rSet )
134 return *this;
136 //--------------------------------------------------------------------
139 // creates the intersection with another bitset
141 inline BitSet BitSet::operator&( const BitSet& rSet ) const
143 return BitSet();
145 //--------------------------------------------------------------------
147 // intersects with another bitset
149 inline BitSet& BitSet::operator&=( const BitSet& rSet )
151 return *this;
153 //--------------------------------------------------------------------
155 // creates the symetric difference with another bitset
157 inline BitSet BitSet::operator^( const BitSet& rSet ) const
159 return BitSet();
161 //--------------------------------------------------------------------
163 // creates the symetric difference with a single bit
165 inline BitSet BitSet::operator^( USHORT nBit ) const
167 return BitSet();
169 //--------------------------------------------------------------------
171 // builds the symetric difference with another bitset
173 inline BitSet& BitSet::operator^=( const BitSet& rSet )
175 return *this;
177 //--------------------------------------------------------------------
178 #ifdef BITSET_READY
179 // builds the symetric difference with a single bit
181 inline BitSet& BitSet::operator^=( USHORT nBit )
183 // crash!!!
184 return BitSet();
186 #endif
187 //--------------------------------------------------------------------
189 // determines if the other bitset is a real superset
191 inline BOOL BitSet::IsRealSubSet( const BitSet& rSet ) const
193 return FALSE;
195 //--------------------------------------------------------------------
197 // detsermines if the other bitset is a superset or equal
199 inline BOOL BitSet::IsSubSet( const BitSet& rSet ) const
201 return FALSE;
203 //--------------------------------------------------------------------
205 // determines if the other bitset is a real subset
207 inline BOOL BitSet::IsRealSuperSet( const BitSet& rSet ) const
209 return FALSE;
212 //--------------------------------------------------------------------
214 // determines if the other bitset is a subset or equal
216 inline BOOL BitSet::IsSuperSet( const BitSet& rSet ) const
218 return FALSE;
220 //--------------------------------------------------------------------
222 // determines if the bit is the only one in the bitset
224 inline BOOL BitSet::operator==( USHORT nBit ) const
226 return FALSE;
228 //--------------------------------------------------------------------
230 // determines if the bitsets aren't equal
232 //--------------------------------------------------------------------
234 // determines if the bitset doesn't contain only this bit
236 inline BOOL BitSet::operator!=( USHORT nBit ) const
238 return !( *this == nBit );
240 //--------------------------------------------------------------------
242 class IndexBitSet : BitSet
244 public:
245 void ReleaseIndex(USHORT i){*this-=i;}
249 }//end of namespace binfilter
250 #endif