LCOV - code coverage report
Current view: top level - libreoffice/svx/inc/svx - svdsob.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 24 26 92.3 %
Date: 2012-12-27 Functions: 8 9 88.9 %
Legend: Lines: hit not hit

          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             : 
      20             : #ifndef _SVDSOB_HXX
      21             : #define _SVDSOB_HXX
      22             : 
      23             : #include <com/sun/star/uno/Any.hxx>
      24             : #include <tools/stream.hxx>
      25             : 
      26             : #include "svx/svxdllapi.h"
      27             : 
      28             : ////////////////////////////////////////////////////////////////////////////////////////////////////
      29             : /*
      30             :   Deklaration eines statischen Mengentyps. Die Menge kann die Elemente
      31             :   0..255 aufnehmen und verbraucht stets 32 Bytes.
      32             : */
      33             : 
      34             : class SVX_DLLPUBLIC SetOfByte
      35             : {
      36             : protected:
      37             :     sal_uInt8 aData[32];
      38             : 
      39             : public:
      40        4167 :     explicit SetOfByte(sal_Bool bInitVal = sal_False)
      41             :     {
      42        4167 :         memset(aData, bInitVal ? 0xFF : 0x00, sizeof(aData));
      43        4167 :     }
      44             : 
      45           0 :     sal_Bool operator==(const SetOfByte& rCmpSet) const
      46             :     {
      47           0 :         return (memcmp(aData, rCmpSet.aData, sizeof(aData)) == 0);
      48             :     }
      49             : 
      50          23 :     sal_Bool operator!=(const SetOfByte& rCmpSet) const
      51             :     {
      52          23 :         return (memcmp(aData, rCmpSet.aData, sizeof(aData))!=0);
      53             :     }
      54             : 
      55        5328 :     void Set(sal_uInt8 a)
      56             :     {
      57        5328 :         aData[a/8] |= 1<<a%8;
      58        5328 :     }
      59             : 
      60         714 :     void Clear(sal_uInt8 a)
      61             :     {
      62         714 :         aData[a/8] &= ~(1<<a%8);
      63         714 :     }
      64             : 
      65         716 :     void Set(sal_uInt8 a, sal_Bool b)
      66             :     {
      67         716 :         if(b)
      68           2 :             Set(a);
      69             :         else
      70         714 :             Clear(a);
      71         716 :     }
      72             : 
      73        8041 :     sal_Bool IsSet(sal_uInt8 a) const
      74             :     {
      75        8041 :         return (aData[a/8] & 1<<a%8) != 0;
      76             :     }
      77             : 
      78        1184 :     void SetAll()
      79             :     {
      80        1184 :         memset(aData, 0xFF, sizeof(aData));
      81        1184 :     }
      82             : 
      83         816 :     void ClearAll()
      84             :     {
      85         816 :         memset(aData, 0x00, sizeof(aData));
      86         816 :     }
      87             : 
      88             :     sal_Bool IsEmpty() const;
      89             : 
      90             :     void operator&=(const SetOfByte& r2ndSet);
      91             :     void operator|=(const SetOfByte& r2ndSet);
      92             : 
      93             :     friend inline SvStream& operator<<(SvStream& rOut, const SetOfByte& rSet);
      94             :     friend inline SvStream& operator>>(SvStream& rIn, SetOfByte& rSet);
      95             : 
      96             :     // initialize this set with a uno sequence of sal_Int8
      97             :     void PutValue(const com::sun::star::uno::Any & rAny);
      98             : 
      99             :     // returns a uno sequence of sal_Int8
     100             :     void QueryValue(com::sun::star::uno::Any & rAny) const;
     101             : };
     102             : 
     103             : inline SvStream& operator<<(SvStream& rOut, const SetOfByte& rSet)
     104             : {
     105             :     rOut.Write((char*)rSet.aData,32);
     106             :     return rOut;
     107             : }
     108             : 
     109             : inline SvStream& operator>>(SvStream& rIn, SetOfByte& rSet)
     110             : {
     111             :     rIn.Read((char*)rSet.aData,32);
     112             :     return rIn;
     113             : }
     114             : 
     115             : #endif // _SVDSOB_HXX
     116             : 
     117             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10