1*3334a7e6SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*3334a7e6SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*3334a7e6SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*3334a7e6SAndrew Rist * distributed with this work for additional information
6*3334a7e6SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*3334a7e6SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*3334a7e6SAndrew Rist * "License"); you may not use this file except in compliance
9*3334a7e6SAndrew Rist * with the License. You may obtain a copy of the License at
10*3334a7e6SAndrew Rist *
11*3334a7e6SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*3334a7e6SAndrew Rist *
13*3334a7e6SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*3334a7e6SAndrew Rist * software distributed under the License is distributed on an
15*3334a7e6SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*3334a7e6SAndrew Rist * KIND, either express or implied. See the License for the
17*3334a7e6SAndrew Rist * specific language governing permissions and limitations
18*3334a7e6SAndrew Rist * under the License.
19*3334a7e6SAndrew Rist *
20*3334a7e6SAndrew Rist *************************************************************/
21*3334a7e6SAndrew Rist
22*3334a7e6SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir #ifndef _SVDSOB_HXX
25cdf0e10cSrcweir #define _SVDSOB_HXX
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx>
28cdf0e10cSrcweir #include <tools/stream.hxx>
29cdf0e10cSrcweir
30cdf0e10cSrcweir #ifndef _STRING_H
31cdf0e10cSrcweir #include <tools/string.hxx> //wg. memset
32cdf0e10cSrcweir #define _STRING_H
33cdf0e10cSrcweir #endif
34cdf0e10cSrcweir #include "svx/svxdllapi.h"
35cdf0e10cSrcweir
36cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
37cdf0e10cSrcweir /*
38cdf0e10cSrcweir Deklaration eines statischen Mengentyps. Die Menge kann die Elemente
39cdf0e10cSrcweir 0..255 aufnehmen und verbraucht stets 32 Bytes.
40cdf0e10cSrcweir */
41cdf0e10cSrcweir
42cdf0e10cSrcweir class SVX_DLLPUBLIC SetOfByte
43cdf0e10cSrcweir {
44cdf0e10cSrcweir protected:
45cdf0e10cSrcweir sal_uInt8 aData[32];
46cdf0e10cSrcweir
47cdf0e10cSrcweir public:
SetOfByte(sal_Bool bInitVal=sal_False)48cdf0e10cSrcweir SetOfByte(sal_Bool bInitVal = sal_False)
49cdf0e10cSrcweir {
50cdf0e10cSrcweir memset(aData, bInitVal ? 0xFF : 0x00, sizeof(aData));
51cdf0e10cSrcweir }
52cdf0e10cSrcweir
operator ==(const SetOfByte & rCmpSet) const53cdf0e10cSrcweir sal_Bool operator==(const SetOfByte& rCmpSet) const
54cdf0e10cSrcweir {
55cdf0e10cSrcweir return (memcmp(aData, rCmpSet.aData, sizeof(aData)) == 0);
56cdf0e10cSrcweir }
57cdf0e10cSrcweir
operator !=(const SetOfByte & rCmpSet) const58cdf0e10cSrcweir sal_Bool operator!=(const SetOfByte& rCmpSet) const
59cdf0e10cSrcweir {
60cdf0e10cSrcweir return (memcmp(aData, rCmpSet.aData, sizeof(aData))!=0);
61cdf0e10cSrcweir }
62cdf0e10cSrcweir
Set(sal_uInt8 a)63cdf0e10cSrcweir void Set(sal_uInt8 a)
64cdf0e10cSrcweir {
65cdf0e10cSrcweir aData[a/8] |= 1<<a%8;
66cdf0e10cSrcweir }
67cdf0e10cSrcweir
Clear(sal_uInt8 a)68cdf0e10cSrcweir void Clear(sal_uInt8 a)
69cdf0e10cSrcweir {
70cdf0e10cSrcweir aData[a/8] &= ~(1<<a%8);
71cdf0e10cSrcweir }
72cdf0e10cSrcweir
Set(sal_uInt8 a,sal_Bool b)73cdf0e10cSrcweir void Set(sal_uInt8 a, sal_Bool b)
74cdf0e10cSrcweir {
75cdf0e10cSrcweir if(b)
76cdf0e10cSrcweir Set(a);
77cdf0e10cSrcweir else
78cdf0e10cSrcweir Clear(a);
79cdf0e10cSrcweir }
80cdf0e10cSrcweir
IsSet(sal_uInt8 a) const81cdf0e10cSrcweir sal_Bool IsSet(sal_uInt8 a) const
82cdf0e10cSrcweir {
83cdf0e10cSrcweir return (aData[a/8] & 1<<a%8) != 0;
84cdf0e10cSrcweir }
85cdf0e10cSrcweir
SetAll()86cdf0e10cSrcweir void SetAll()
87cdf0e10cSrcweir {
88cdf0e10cSrcweir memset(aData, 0xFF, sizeof(aData));
89cdf0e10cSrcweir }
90cdf0e10cSrcweir
ClearAll()91cdf0e10cSrcweir void ClearAll()
92cdf0e10cSrcweir {
93cdf0e10cSrcweir memset(aData, 0x00, sizeof(aData));
94cdf0e10cSrcweir }
95cdf0e10cSrcweir
96cdf0e10cSrcweir sal_Bool IsEmpty() const;
97cdf0e10cSrcweir sal_Bool IsFull() const;
98cdf0e10cSrcweir
99cdf0e10cSrcweir sal_uInt16 GetSetCount() const;
100cdf0e10cSrcweir sal_uInt8 GetSetBit(sal_uInt16 nNum) const;
101cdf0e10cSrcweir sal_uInt16 GetClearCount() const;
102cdf0e10cSrcweir sal_uInt8 GetClearBit(sal_uInt16 nNum) const;
103cdf0e10cSrcweir void operator&=(const SetOfByte& r2ndSet);
104cdf0e10cSrcweir void operator|=(const SetOfByte& r2ndSet);
105cdf0e10cSrcweir
106cdf0e10cSrcweir friend inline SvStream& operator<<(SvStream& rOut, const SetOfByte& rSet);
107cdf0e10cSrcweir friend inline SvStream& operator>>(SvStream& rIn, SetOfByte& rSet);
108cdf0e10cSrcweir
109cdf0e10cSrcweir // initialize this set with a uno sequence of sal_Int8
110cdf0e10cSrcweir void PutValue(const com::sun::star::uno::Any & rAny);
111cdf0e10cSrcweir
112cdf0e10cSrcweir // returns a uno sequence of sal_Int8
113cdf0e10cSrcweir void QueryValue(com::sun::star::uno::Any & rAny) const;
114cdf0e10cSrcweir };
115cdf0e10cSrcweir
operator <<(SvStream & rOut,const SetOfByte & rSet)116cdf0e10cSrcweir inline SvStream& operator<<(SvStream& rOut, const SetOfByte& rSet)
117cdf0e10cSrcweir {
118cdf0e10cSrcweir rOut.Write((char*)rSet.aData,32);
119cdf0e10cSrcweir return rOut;
120cdf0e10cSrcweir }
121cdf0e10cSrcweir
operator >>(SvStream & rIn,SetOfByte & rSet)122cdf0e10cSrcweir inline SvStream& operator>>(SvStream& rIn, SetOfByte& rSet)
123cdf0e10cSrcweir {
124cdf0e10cSrcweir rIn.Read((char*)rSet.aData,32);
125cdf0e10cSrcweir return rIn;
126cdf0e10cSrcweir }
127cdf0e10cSrcweir
128cdf0e10cSrcweir #endif // _SVDSOB_HXX
129cdf0e10cSrcweir
130