bump product version to 5.0.4.1
[LibreOffice.git] / sfx2 / inc / bitset.hxx
blob79a6981088c8173e5b711368c0f9356b1a07248d
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 INCLUDED_SFX2_INC_BITSET_HXX
20 #define INCLUDED_SFX2_INC_BITSET_HXX
22 class BitSet
24 private:
25 void CopyFrom( const BitSet& rSet );
26 sal_uInt16 nBlocks;
27 sal_uInt16 nCount;
28 sal_uInt32* pBitmap;
29 public:
30 BitSet operator<<( sal_uInt16 nOffset ) const;
31 BitSet operator>>( sal_uInt16 nOffset ) const;
32 static sal_uInt16 CountBits(sal_uInt32 nBits);
33 bool operator!() const;
34 BitSet();
35 BitSet( const BitSet& rOrig );
36 ~BitSet();
37 sal_uInt16 Count() const;
38 BitSet& operator=( const BitSet& rOrig );
39 BitSet& operator=( sal_uInt16 nBit );
40 BitSet operator|( const BitSet& rSet ) const;
41 BitSet operator|( sal_uInt16 nBit ) const;
42 BitSet& operator|=( const BitSet& rSet );
43 BitSet& operator|=( sal_uInt16 nBit );
44 BitSet operator-( const BitSet& rSet ) const;
45 BitSet operator-( sal_uInt16 nId ) const;
46 BitSet& operator-=( const BitSet& rSet );
47 BitSet& operator-=( sal_uInt16 nBit );
48 BitSet operator&( const BitSet& rSet ) const;
49 BitSet& operator&=( const BitSet& rSet );
50 BitSet operator^( const BitSet& rSet ) const;
51 BitSet operator^( sal_uInt16 nBit ) const;
52 BitSet& operator^=( const BitSet& rSet );
53 BitSet& operator^=( sal_uInt16 nBit );
54 bool Contains( sal_uInt16 nBit ) const;
55 bool operator==( const BitSet& rSet ) const;
56 bool operator!=( const BitSet& rSet ) const;
60 // returns sal_True if the set is empty
61 inline bool BitSet::operator!() const
63 return nCount == 0;
66 // returns the number of bits in the bitset
67 inline sal_uInt16 BitSet::Count() const
69 return nCount;
72 // creates the union of two bitset
73 inline BitSet BitSet::operator|( const BitSet& rSet ) const
75 return BitSet(*this) |= rSet;
78 // creates the union of a bitset with a single bit
79 inline BitSet BitSet::operator|( sal_uInt16 nBit ) const
81 return BitSet(*this) |= nBit;
84 // creates the asymetric difference
85 inline BitSet BitSet::operator-( const BitSet& ) const
87 return BitSet();
90 // creates the asymetric difference with a single bit
91 inline BitSet BitSet::operator-( sal_uInt16 ) const
93 return BitSet();
96 // removes the bits contained in rSet
97 inline BitSet& BitSet::operator-=( const BitSet& )
99 return *this;
102 // creates the intersection with another bitset
103 inline BitSet BitSet::operator&( const BitSet& ) const
105 return BitSet();
108 // intersects with another bitset
109 inline BitSet& BitSet::operator&=( const BitSet& )
111 return *this;
114 // creates the symetric difference with another bitset
115 inline BitSet BitSet::operator^( const BitSet& ) const
117 return BitSet();
120 // creates the symetric difference with a single bit
121 inline BitSet BitSet::operator^( sal_uInt16 ) const
123 return BitSet();
126 // builds the symetric difference with another bitset
127 inline BitSet& BitSet::operator^=( const BitSet& )
129 return *this;
132 #ifdef BITSET_READY
133 // builds the symetric difference with a single bit
134 inline BitSet& BitSet::operator^=( sal_uInt16 )
136 // crash!!!
137 return BitSet();
139 #endif
141 // determines if the bitsets aren't equal
142 inline bool BitSet::operator!=( const BitSet& rSet ) const
144 return !( *this == rSet );
147 class IndexBitSet : BitSet
149 public:
150 sal_uInt16 GetFreeIndex();
151 void ReleaseIndex(sal_uInt16 i){*this-=i;}
155 #endif
157 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */