LCOV - code coverage report
Current view: top level - sfx2/inc - bitset.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 2 2 100.0 %
Date: 2012-08-25 Functions: 3 3 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     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 _SFXBITSET_HXX
      20                 :            : #define _SFXBITSET_HXX
      21                 :            : 
      22                 :            : #include <tools/solar.h>
      23                 :            : 
      24                 :            : class BitSet
      25                 :            : {
      26                 :            : private:
      27                 :            :     void CopyFrom( const BitSet& rSet );
      28                 :            :     sal_uInt16 nBlocks;
      29                 :            :     sal_uInt16 nCount;
      30                 :            :     sal_uIntPtr* pBitmap;
      31                 :            : public:
      32                 :            :     BitSet operator<<( sal_uInt16 nOffset ) const;
      33                 :            :     BitSet operator>>( sal_uInt16 nOffset ) const;
      34                 :            :     static sal_uInt16 CountBits( sal_uIntPtr nBits );
      35                 :            :     sal_Bool operator!() const;
      36                 :            :     BitSet();
      37                 :            :     BitSet( const BitSet& rOrig );
      38                 :            :     ~BitSet();
      39                 :            :     sal_uInt16 Count() const;
      40                 :            :     BitSet& operator=( const BitSet& rOrig );
      41                 :            :     BitSet& operator=( sal_uInt16 nBit );
      42                 :            :     BitSet operator|( const BitSet& rSet ) const;
      43                 :            :     BitSet operator|( sal_uInt16 nBit ) const;
      44                 :            :     BitSet& operator|=( const BitSet& rSet );
      45                 :            :     BitSet& operator|=( sal_uInt16 nBit );
      46                 :            :     BitSet operator-( const BitSet& rSet ) const;
      47                 :            :     BitSet operator-( sal_uInt16 nId ) const;
      48                 :            :     BitSet& operator-=( const BitSet& rSet );
      49                 :            :     BitSet& operator-=( sal_uInt16 nBit );
      50                 :            :     BitSet operator&( const BitSet& rSet ) const;
      51                 :            :     BitSet& operator&=( const BitSet& rSet );
      52                 :            :     BitSet operator^( const BitSet& rSet ) const;
      53                 :            :     BitSet operator^( sal_uInt16 nBit ) const;
      54                 :            :     BitSet& operator^=( const BitSet& rSet );
      55                 :            :     BitSet& operator^=( sal_uInt16 nBit );
      56                 :            :     sal_Bool IsRealSubSet( const BitSet& rSet ) const;
      57                 :            :     sal_Bool IsSubSet( const BitSet& rSet ) const;
      58                 :            :     sal_Bool IsRealSuperSet( const BitSet& rSet ) const;
      59                 :            :     sal_Bool Contains( sal_uInt16 nBit ) const;
      60                 :            :     sal_Bool IsSuperSet( const BitSet& rSet ) const;
      61                 :            :     sal_Bool operator==( const BitSet& rSet ) const;
      62                 :            :     sal_Bool operator==( sal_uInt16 nBit ) const;
      63                 :            :     sal_Bool operator!=( const BitSet& rSet ) const;
      64                 :            :     sal_Bool operator!=( sal_uInt16 nBit ) const;
      65                 :            : 
      66                 :            : };
      67                 :            : //--------------------------------------------------------------------
      68                 :            : 
      69                 :            : // returns sal_True if the set is empty
      70                 :            : 
      71                 :            : 
      72                 :            : 
      73                 :            : inline sal_Bool BitSet::operator!() const
      74                 :            : {
      75                 :            :     return nCount == 0;
      76                 :            : }
      77                 :            : //--------------------------------------------------------------------
      78                 :            : 
      79                 :            : // returns the number of bits in the bitset
      80                 :            : 
      81                 :            : inline sal_uInt16 BitSet::Count() const
      82                 :            : {
      83                 :            :     return nCount;
      84                 :            : }
      85                 :            : //--------------------------------------------------------------------
      86                 :            : 
      87                 :            : // creates the union of two bitset
      88                 :            : 
      89                 :            : inline BitSet BitSet::operator|( const BitSet& rSet ) const
      90                 :            : {
      91                 :            :     return BitSet(*this) |= rSet;
      92                 :            : }
      93                 :            : //--------------------------------------------------------------------
      94                 :            : 
      95                 :            : // creates the union of a bitset with a single bit
      96                 :            : 
      97                 :            : inline BitSet BitSet::operator|( sal_uInt16 nBit ) const
      98                 :            : {
      99                 :            :     return BitSet(*this) |= nBit;
     100                 :            : }
     101                 :            : //--------------------------------------------------------------------
     102                 :            : 
     103                 :            : // creates the asymetric difference
     104                 :            : 
     105                 :            : inline BitSet BitSet::operator-( const BitSet& ) const
     106                 :            : {
     107                 :            :     return BitSet();
     108                 :            : }
     109                 :            : //--------------------------------------------------------------------
     110                 :            : 
     111                 :            : // creates the asymetric difference with a single bit
     112                 :            : 
     113                 :            : 
     114                 :            : inline BitSet BitSet::operator-( sal_uInt16 ) const
     115                 :            : {
     116                 :            :     return BitSet();
     117                 :            : }
     118                 :            : //--------------------------------------------------------------------
     119                 :            : 
     120                 :            : // removes the bits contained in rSet
     121                 :            : 
     122                 :            : inline BitSet& BitSet::operator-=( const BitSet& )
     123                 :            : {
     124                 :            :     return *this;
     125                 :            : }
     126                 :            : //--------------------------------------------------------------------
     127                 :            : 
     128                 :            : 
     129                 :            : // creates the intersection with another bitset
     130                 :            : 
     131                 :            : inline BitSet BitSet::operator&( const BitSet& ) const
     132                 :            : {
     133                 :            :     return BitSet();
     134                 :            : }
     135                 :            : //--------------------------------------------------------------------
     136                 :            : 
     137                 :            : // intersects with another bitset
     138                 :            : 
     139                 :            : inline BitSet& BitSet::operator&=( const BitSet& )
     140                 :            : {
     141                 :            :     return *this;
     142                 :            : }
     143                 :            : //--------------------------------------------------------------------
     144                 :            : 
     145                 :            : // creates the symetric difference with another bitset
     146                 :            : 
     147                 :            : inline BitSet BitSet::operator^( const BitSet& ) const
     148                 :            : {
     149                 :            :     return BitSet();
     150                 :            : }
     151                 :            : //--------------------------------------------------------------------
     152                 :            : 
     153                 :            : // creates the symetric difference with a single bit
     154                 :            : 
     155                 :            : inline BitSet BitSet::operator^( sal_uInt16 ) const
     156                 :            : {
     157                 :            :     return BitSet();
     158                 :            : }
     159                 :            : //--------------------------------------------------------------------
     160                 :            : 
     161                 :            : // builds the symetric difference with another bitset
     162                 :            : 
     163                 :            : inline BitSet& BitSet::operator^=( const BitSet& )
     164                 :            : {
     165                 :            :     return *this;
     166                 :            : }
     167                 :            : //--------------------------------------------------------------------
     168                 :            : #ifdef BITSET_READY
     169                 :            : // builds the symetric difference with a single bit
     170                 :            : 
     171                 :            : inline BitSet& BitSet::operator^=( sal_uInt16 )
     172                 :            : {
     173                 :            :     // crash!!!
     174                 :            :     return BitSet();
     175                 :            : }
     176                 :            : #endif
     177                 :            : //--------------------------------------------------------------------
     178                 :            : 
     179                 :            : // determines if the other bitset is a real superset
     180                 :            : 
     181                 :            : inline sal_Bool BitSet::IsRealSubSet( const BitSet& ) const
     182                 :            : {
     183                 :            :     return sal_False;
     184                 :            : }
     185                 :            : //--------------------------------------------------------------------
     186                 :            : 
     187                 :            : // determines if the other bitset is a superset or equal
     188                 :            : 
     189                 :            : inline sal_Bool BitSet::IsSubSet( const BitSet& ) const
     190                 :            : {
     191                 :            :     return sal_False;
     192                 :            : }
     193                 :            : //--------------------------------------------------------------------
     194                 :            : 
     195                 :            : // determines if the other bitset is a real subset
     196                 :            : 
     197                 :            : inline sal_Bool BitSet::IsRealSuperSet( const BitSet& ) const
     198                 :            : {
     199                 :            :     return sal_False;
     200                 :            : }
     201                 :            : 
     202                 :            : //--------------------------------------------------------------------
     203                 :            : 
     204                 :            : // determines if the other bitset is a subset or equal
     205                 :            : 
     206                 :            : inline sal_Bool BitSet::IsSuperSet( const BitSet& ) const
     207                 :            : {
     208                 :            :     return sal_False;
     209                 :            : }
     210                 :            : //--------------------------------------------------------------------
     211                 :            : 
     212                 :            : // determines if the bit is the only one in the bitset
     213                 :            : 
     214                 :            : inline sal_Bool BitSet::operator==( sal_uInt16 ) const
     215                 :            : {
     216                 :            :     return sal_False;
     217                 :            : }
     218                 :            : //--------------------------------------------------------------------
     219                 :            : 
     220                 :            : // determines if the bitsets aren't equal
     221                 :            : 
     222                 :            : inline sal_Bool BitSet::operator!=( const BitSet& rSet ) const
     223                 :            : {
     224                 :            :     return !( *this == rSet );
     225                 :            : }
     226                 :            : //--------------------------------------------------------------------
     227                 :            : 
     228                 :            : // determines if the bitset doesn't contain only this bit
     229                 :            : 
     230                 :            : inline sal_Bool BitSet::operator!=( sal_uInt16 nBit ) const
     231                 :            : {
     232                 :            :     return !( *this == nBit );
     233                 :            : }
     234                 :            : //--------------------------------------------------------------------
     235                 :            : 
     236                 :       6130 : class IndexBitSet : BitSet
     237                 :            : {
     238                 :            : public:
     239                 :            :   sal_uInt16 GetFreeIndex();
     240                 :       2694 :   void ReleaseIndex(sal_uInt16 i){*this-=i;}
     241                 :            : };
     242                 :            : 
     243                 :            : 
     244                 :            : #endif
     245                 :            : 
     246                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10