1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef _SFXBITSET_HXX
20 #define _SFXBITSET_HXX
22 #include <tools/solar.h>
27 void CopyFrom( const BitSet
& rSet
);
32 BitSet
operator<<( sal_uInt16 nOffset
) const;
33 BitSet
operator>>( sal_uInt16 nOffset
) const;
34 static sal_uInt16
CountBits( sal_uIntPtr nBits
);
35 sal_Bool
operator!() const;
37 BitSet( const BitSet
& rOrig
);
39 sal_uInt16
Count() const;
40 BitSet
& operator=( const BitSet
& rOrig
);
41 BitSet
& operator=( sal_uInt16 nBit
);
42 BitSet
operator|( const BitSet
& rSet
) const;
43 BitSet
operator|( sal_uInt16 nBit
) const;
44 BitSet
& operator|=( const BitSet
& rSet
);
45 BitSet
& operator|=( sal_uInt16 nBit
);
46 BitSet
operator-( const BitSet
& rSet
) const;
47 BitSet
operator-( sal_uInt16 nId
) const;
48 BitSet
& operator-=( const BitSet
& rSet
);
49 BitSet
& operator-=( sal_uInt16 nBit
);
50 BitSet
operator&( const BitSet
& rSet
) const;
51 BitSet
& operator&=( const BitSet
& rSet
);
52 BitSet
operator^( const BitSet
& rSet
) const;
53 BitSet
operator^( sal_uInt16 nBit
) const;
54 BitSet
& operator^=( const BitSet
& rSet
);
55 BitSet
& operator^=( sal_uInt16 nBit
);
56 sal_Bool
IsRealSubSet( const BitSet
& rSet
) const;
57 sal_Bool
IsSubSet( const BitSet
& rSet
) const;
58 sal_Bool
IsRealSuperSet( const BitSet
& rSet
) const;
59 sal_Bool
Contains( sal_uInt16 nBit
) const;
60 sal_Bool
IsSuperSet( const BitSet
& rSet
) const;
61 sal_Bool
operator==( const BitSet
& rSet
) const;
62 sal_Bool
operator==( sal_uInt16 nBit
) const;
63 sal_Bool
operator!=( const BitSet
& rSet
) const;
64 sal_Bool
operator!=( sal_uInt16 nBit
) const;
67 //--------------------------------------------------------------------
69 // returns sal_True if the set is empty
73 inline sal_Bool
BitSet::operator!() const
77 //--------------------------------------------------------------------
79 // returns the number of bits in the bitset
81 inline sal_uInt16
BitSet::Count() const
85 //--------------------------------------------------------------------
87 // creates the union of two bitset
89 inline BitSet
BitSet::operator|( const BitSet
& rSet
) const
91 return BitSet(*this) |= rSet
;
93 //--------------------------------------------------------------------
95 // creates the union of a bitset with a single bit
97 inline BitSet
BitSet::operator|( sal_uInt16 nBit
) const
99 return BitSet(*this) |= nBit
;
101 //--------------------------------------------------------------------
103 // creates the asymetric difference
105 inline BitSet
BitSet::operator-( const BitSet
& ) const
109 //--------------------------------------------------------------------
111 // creates the asymetric difference with a single bit
114 inline BitSet
BitSet::operator-( sal_uInt16
) const
118 //--------------------------------------------------------------------
120 // removes the bits contained in rSet
122 inline BitSet
& BitSet::operator-=( const BitSet
& )
126 //--------------------------------------------------------------------
129 // creates the intersection with another bitset
131 inline BitSet
BitSet::operator&( const BitSet
& ) const
135 //--------------------------------------------------------------------
137 // intersects with another bitset
139 inline BitSet
& BitSet::operator&=( const BitSet
& )
143 //--------------------------------------------------------------------
145 // creates the symetric difference with another bitset
147 inline BitSet
BitSet::operator^( const BitSet
& ) const
151 //--------------------------------------------------------------------
153 // creates the symetric difference with a single bit
155 inline BitSet
BitSet::operator^( sal_uInt16
) const
159 //--------------------------------------------------------------------
161 // builds the symetric difference with another bitset
163 inline BitSet
& BitSet::operator^=( const BitSet
& )
167 //--------------------------------------------------------------------
169 // builds the symetric difference with a single bit
171 inline BitSet
& BitSet::operator^=( sal_uInt16
)
177 //--------------------------------------------------------------------
179 // determines if the other bitset is a real superset
181 inline sal_Bool
BitSet::IsRealSubSet( const BitSet
& ) const
185 //--------------------------------------------------------------------
187 // determines if the other bitset is a superset or equal
189 inline sal_Bool
BitSet::IsSubSet( const BitSet
& ) const
193 //--------------------------------------------------------------------
195 // determines if the other bitset is a real subset
197 inline sal_Bool
BitSet::IsRealSuperSet( const BitSet
& ) const
202 //--------------------------------------------------------------------
204 // determines if the other bitset is a subset or equal
206 inline sal_Bool
BitSet::IsSuperSet( const BitSet
& ) const
210 //--------------------------------------------------------------------
212 // determines if the bit is the only one in the bitset
214 inline sal_Bool
BitSet::operator==( sal_uInt16
) const
218 //--------------------------------------------------------------------
220 // determines if the bitsets aren't equal
222 inline sal_Bool
BitSet::operator!=( const BitSet
& rSet
) const
224 return !( *this == rSet
);
226 //--------------------------------------------------------------------
228 // determines if the bitset doesn't contain only this bit
230 inline sal_Bool
BitSet::operator!=( sal_uInt16 nBit
) const
232 return !( *this == nBit
);
234 //--------------------------------------------------------------------
236 class IndexBitSet
: BitSet
239 sal_uInt16
GetFreeIndex();
240 void ReleaseIndex(sal_uInt16 i
){*this-=i
;}
246 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */