Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _SVDSOB_HXX
30 : : #define _SVDSOB_HXX
31 : :
32 : : #include <com/sun/star/uno/Any.hxx>
33 : : #include <tools/stream.hxx>
34 : :
35 : : #include "svx/svxdllapi.h"
36 : :
37 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
38 : : /*
39 : : Deklaration eines statischen Mengentyps. Die Menge kann die Elemente
40 : : 0..255 aufnehmen und verbraucht stets 32 Bytes.
41 : : */
42 : :
43 : : class SVX_DLLPUBLIC SetOfByte
44 : : {
45 : : protected:
46 : : sal_uInt8 aData[32];
47 : :
48 : : public:
49 : 1215 : explicit SetOfByte(sal_Bool bInitVal = sal_False)
50 : : {
51 [ - + ]: 1215 : memset(aData, bInitVal ? 0xFF : 0x00, sizeof(aData));
52 : 1215 : }
53 : :
54 : : sal_Bool operator==(const SetOfByte& rCmpSet) const
55 : : {
56 : : return (memcmp(aData, rCmpSet.aData, sizeof(aData)) == 0);
57 : : }
58 : :
59 : 4032 : sal_Bool operator!=(const SetOfByte& rCmpSet) const
60 : : {
61 : 4032 : return (memcmp(aData, rCmpSet.aData, sizeof(aData))!=0);
62 : : }
63 : :
64 : 138 : void Set(sal_uInt8 a)
65 : : {
66 : 138 : aData[a/8] |= 1<<a%8;
67 : 138 : }
68 : :
69 : 0 : void Clear(sal_uInt8 a)
70 : : {
71 : 0 : aData[a/8] &= ~(1<<a%8);
72 : 0 : }
73 : :
74 : 138 : void Set(sal_uInt8 a, sal_Bool b)
75 : : {
76 [ + - ]: 138 : if(b)
77 : 138 : Set(a);
78 : : else
79 : 0 : Clear(a);
80 : 138 : }
81 : :
82 : 90 : sal_Bool IsSet(sal_uInt8 a) const
83 : : {
84 : 90 : return (aData[a/8] & 1<<a%8) != 0;
85 : : }
86 : :
87 : 602 : void SetAll()
88 : : {
89 : 602 : memset(aData, 0xFF, sizeof(aData));
90 : 602 : }
91 : :
92 : : void ClearAll()
93 : : {
94 : : memset(aData, 0x00, sizeof(aData));
95 : : }
96 : :
97 : : sal_Bool IsEmpty() const;
98 : :
99 : : void operator&=(const SetOfByte& r2ndSet);
100 : : void operator|=(const SetOfByte& r2ndSet);
101 : :
102 : : friend inline SvStream& operator<<(SvStream& rOut, const SetOfByte& rSet);
103 : : friend inline SvStream& operator>>(SvStream& rIn, SetOfByte& rSet);
104 : :
105 : : // initialize this set with a uno sequence of sal_Int8
106 : : void PutValue(const com::sun::star::uno::Any & rAny);
107 : :
108 : : // returns a uno sequence of sal_Int8
109 : : void QueryValue(com::sun::star::uno::Any & rAny) const;
110 : : };
111 : :
112 : : inline SvStream& operator<<(SvStream& rOut, const SetOfByte& rSet)
113 : : {
114 : : rOut.Write((char*)rSet.aData,32);
115 : : return rOut;
116 : : }
117 : :
118 : : inline SvStream& operator>>(SvStream& rIn, SetOfByte& rSet)
119 : : {
120 : : rIn.Read((char*)rSet.aData,32);
121 : : return rIn;
122 : : }
123 : :
124 : : #endif // _SVDSOB_HXX
125 : :
126 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|