Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef INCLUDED_SFX2_INC_BITSET_HXX
20 : #define INCLUDED_SFX2_INC_BITSET_HXX
21 :
22 : class BitSet
23 : {
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;
57 :
58 : };
59 :
60 : // returns sal_True if the set is empty
61 : inline bool BitSet::operator!() const
62 : {
63 : return nCount == 0;
64 : }
65 :
66 : // returns the number of bits in the bitset
67 : inline sal_uInt16 BitSet::Count() const
68 : {
69 : return nCount;
70 : }
71 :
72 : // creates the union of two bitset
73 : inline BitSet BitSet::operator|( const BitSet& rSet ) const
74 : {
75 : return BitSet(*this) |= rSet;
76 : }
77 :
78 : // creates the union of a bitset with a single bit
79 : inline BitSet BitSet::operator|( sal_uInt16 nBit ) const
80 : {
81 : return BitSet(*this) |= nBit;
82 : }
83 :
84 : // creates the asymetric difference
85 : inline BitSet BitSet::operator-( const BitSet& ) const
86 : {
87 : return BitSet();
88 : }
89 :
90 : // creates the asymetric difference with a single bit
91 : inline BitSet BitSet::operator-( sal_uInt16 ) const
92 : {
93 : return BitSet();
94 : }
95 :
96 : // removes the bits contained in rSet
97 : inline BitSet& BitSet::operator-=( const BitSet& )
98 : {
99 : return *this;
100 : }
101 :
102 : // creates the intersection with another bitset
103 : inline BitSet BitSet::operator&( const BitSet& ) const
104 : {
105 : return BitSet();
106 : }
107 :
108 : // intersects with another bitset
109 : inline BitSet& BitSet::operator&=( const BitSet& )
110 : {
111 : return *this;
112 : }
113 :
114 : // creates the symetric difference with another bitset
115 : inline BitSet BitSet::operator^( const BitSet& ) const
116 : {
117 : return BitSet();
118 : }
119 :
120 : // creates the symetric difference with a single bit
121 : inline BitSet BitSet::operator^( sal_uInt16 ) const
122 : {
123 : return BitSet();
124 : }
125 :
126 : // builds the symetric difference with another bitset
127 : inline BitSet& BitSet::operator^=( const BitSet& )
128 : {
129 : return *this;
130 : }
131 :
132 : #ifdef BITSET_READY
133 : // builds the symetric difference with a single bit
134 : inline BitSet& BitSet::operator^=( sal_uInt16 )
135 : {
136 : // crash!!!
137 : return BitSet();
138 : }
139 : #endif
140 :
141 : // determines if the bitsets aren't equal
142 : inline bool BitSet::operator!=( const BitSet& rSet ) const
143 : {
144 : return !( *this == rSet );
145 : }
146 :
147 10149 : class IndexBitSet : BitSet
148 : {
149 : public:
150 : sal_uInt16 GetFreeIndex();
151 3871 : void ReleaseIndex(sal_uInt16 i){*this-=i;}
152 : };
153 :
154 :
155 : #endif
156 :
157 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|