bump product version to 4.1.6.2
[LibreOffice.git] / sfx2 / inc / bitset.hxx
blobbb2f8409893fe7dcbbf13bbf1d519822bff3a18b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
24 class BitSet
26 private:
27 void CopyFrom( const BitSet& rSet );
28 sal_uInt16 nBlocks;
29 sal_uInt16 nCount;
30 sal_uIntPtr* pBitmap;
31 public:
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;
36 BitSet();
37 BitSet( const BitSet& rOrig );
38 ~BitSet();
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
75 return nCount == 0;
77 //--------------------------------------------------------------------
79 // returns the number of bits in the bitset
81 inline sal_uInt16 BitSet::Count() const
83 return nCount;
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
107 return BitSet();
109 //--------------------------------------------------------------------
111 // creates the asymetric difference with a single bit
114 inline BitSet BitSet::operator-( sal_uInt16 ) const
116 return BitSet();
118 //--------------------------------------------------------------------
120 // removes the bits contained in rSet
122 inline BitSet& BitSet::operator-=( const BitSet& )
124 return *this;
126 //--------------------------------------------------------------------
129 // creates the intersection with another bitset
131 inline BitSet BitSet::operator&( const BitSet& ) const
133 return BitSet();
135 //--------------------------------------------------------------------
137 // intersects with another bitset
139 inline BitSet& BitSet::operator&=( const BitSet& )
141 return *this;
143 //--------------------------------------------------------------------
145 // creates the symetric difference with another bitset
147 inline BitSet BitSet::operator^( const BitSet& ) const
149 return BitSet();
151 //--------------------------------------------------------------------
153 // creates the symetric difference with a single bit
155 inline BitSet BitSet::operator^( sal_uInt16 ) const
157 return BitSet();
159 //--------------------------------------------------------------------
161 // builds the symetric difference with another bitset
163 inline BitSet& BitSet::operator^=( const BitSet& )
165 return *this;
167 //--------------------------------------------------------------------
168 #ifdef BITSET_READY
169 // builds the symetric difference with a single bit
171 inline BitSet& BitSet::operator^=( sal_uInt16 )
173 // crash!!!
174 return BitSet();
176 #endif
177 //--------------------------------------------------------------------
179 // determines if the other bitset is a real superset
181 inline sal_Bool BitSet::IsRealSubSet( const BitSet& ) const
183 return sal_False;
185 //--------------------------------------------------------------------
187 // determines if the other bitset is a superset or equal
189 inline sal_Bool BitSet::IsSubSet( const BitSet& ) const
191 return sal_False;
193 //--------------------------------------------------------------------
195 // determines if the other bitset is a real subset
197 inline sal_Bool BitSet::IsRealSuperSet( const BitSet& ) const
199 return sal_False;
202 //--------------------------------------------------------------------
204 // determines if the other bitset is a subset or equal
206 inline sal_Bool BitSet::IsSuperSet( const BitSet& ) const
208 return sal_False;
210 //--------------------------------------------------------------------
212 // determines if the bit is the only one in the bitset
214 inline sal_Bool BitSet::operator==( sal_uInt16 ) const
216 return sal_False;
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
238 public:
239 sal_uInt16 GetFreeIndex();
240 void ReleaseIndex(sal_uInt16 i){*this-=i;}
244 #endif
246 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */