1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: bitset.hxx,v $
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
34 #include <tools/solar.h>
43 void CopyFrom( const BitSet
& rSet
);
48 BitSet
operator<<( USHORT nOffset
) const;
49 static USHORT
CountBits( ULONG nBits
);
50 BOOL
operator!() const;
52 BitSet( const BitSet
& rOrig
);
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
87 //--------------------------------------------------------------------
89 // returns the number of bits in the bitset
91 inline USHORT
BitSet::Count() const
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
119 //--------------------------------------------------------------------
121 // creates the asymetric difference with a single bit
124 inline BitSet
BitSet::operator-( USHORT nId
) const
128 //--------------------------------------------------------------------
130 // removes the bits contained in rSet
132 inline BitSet
& BitSet::operator-=( const BitSet
& rSet
)
136 //--------------------------------------------------------------------
139 // creates the intersection with another bitset
141 inline BitSet
BitSet::operator&( const BitSet
& rSet
) const
145 //--------------------------------------------------------------------
147 // intersects with another bitset
149 inline BitSet
& BitSet::operator&=( const BitSet
& rSet
)
153 //--------------------------------------------------------------------
155 // creates the symetric difference with another bitset
157 inline BitSet
BitSet::operator^( const BitSet
& rSet
) const
161 //--------------------------------------------------------------------
163 // creates the symetric difference with a single bit
165 inline BitSet
BitSet::operator^( USHORT nBit
) const
169 //--------------------------------------------------------------------
171 // builds the symetric difference with another bitset
173 inline BitSet
& BitSet::operator^=( const BitSet
& rSet
)
177 //--------------------------------------------------------------------
179 // builds the symetric difference with a single bit
181 inline BitSet
& BitSet::operator^=( USHORT nBit
)
187 //--------------------------------------------------------------------
189 // determines if the other bitset is a real superset
191 inline BOOL
BitSet::IsRealSubSet( const BitSet
& rSet
) const
195 //--------------------------------------------------------------------
197 // detsermines if the other bitset is a superset or equal
199 inline BOOL
BitSet::IsSubSet( const BitSet
& rSet
) const
203 //--------------------------------------------------------------------
205 // determines if the other bitset is a real subset
207 inline BOOL
BitSet::IsRealSuperSet( const BitSet
& rSet
) const
212 //--------------------------------------------------------------------
214 // determines if the other bitset is a subset or equal
216 inline BOOL
BitSet::IsSuperSet( const BitSet
& rSet
) const
220 //--------------------------------------------------------------------
222 // determines if the bit is the only one in the bitset
224 inline BOOL
BitSet::operator==( USHORT nBit
) const
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
245 void ReleaseIndex(USHORT i
){*this-=i
;}
249 }//end of namespace binfilter