userlibandfileserver/fileserver/sfat32/inc/sl_std.inl
changeset 11 329ab0095843
parent 10 36bfc973b146
child 19 4a8fed1c0ef6
equal deleted inserted replaced
10:36bfc973b146 11:329ab0095843
   533     {
   533     {
   534     return NULL;
   534     return NULL;
   535     }
   535     }
   536 
   536 
   537 //---------------------------------------------------------------------------------------------------------------------------------	
   537 //---------------------------------------------------------------------------------------------------------------------------------	
   538 //-- class RBitVector
       
   539 
       
   540 /** @return size of the vector (number of bits) */
       
   541 inline TUint32 RBitVector::Size() const
       
   542     {
       
   543     return iNumBits;
       
   544     } 
       
   545 
       
   546 /**
       
   547     Get a bit by index
       
   548     
       
   549     @param aIndex  index in a bit vector
       
   550     @return 0 if the bit at pos aIndex is 0, not zero otherwise
       
   551     @panic EIndexOutOfRange if aIndex is out of range
       
   552 */
       
   553 inline TBool RBitVector::operator[](TUint32 aIndex) const
       
   554     {
       
   555     __ASSERT_ALWAYS(aIndex < iNumBits, Panic(EIndexOutOfRange));
       
   556     return (ipData[WordNum(aIndex)] & (1<<BitInWord(aIndex)));
       
   557     }
       
   558 
       
   559 /**
       
   560     Set a bit at pos aIndex to '1'
       
   561     @param aIndex  index in a bit vector
       
   562     @panic EIndexOutOfRange if aIndex is out of range
       
   563 */
       
   564 inline void RBitVector::SetBit(TUint32 aIndex)
       
   565     {
       
   566     __ASSERT_ALWAYS(aIndex < iNumBits, Panic(EIndexOutOfRange));
       
   567     ipData[WordNum(aIndex)] |= (1<<BitInWord(aIndex));
       
   568     }
       
   569 
       
   570 /**
       
   571     Set a bit at pos aIndex to '0'
       
   572     @param aIndex  index in a bit vector
       
   573     @panic EIndexOutOfRange if aIndex is out of range
       
   574 */
       
   575 inline void RBitVector::ResetBit(TUint32 aIndex)
       
   576     {
       
   577     __ASSERT_ALWAYS(aIndex < iNumBits, Panic(EIndexOutOfRange));
       
   578     ipData[WordNum(aIndex)] &= ~(1<<BitInWord(aIndex));
       
   579     }
       
   580 
       
   581 /**
       
   582     Invert a bit at pos aIndex
       
   583     @param aIndex  index in a bit vector
       
   584     @panic EIndexOutOfRange if aIndex is out of range
       
   585 */
       
   586 inline void RBitVector::InvertBit(TUint32 aIndex)
       
   587     {
       
   588     __ASSERT_ALWAYS(aIndex < iNumBits, Panic(EIndexOutOfRange));
       
   589     ipData[WordNum(aIndex)] ^= (1<<BitInWord(aIndex));
       
   590     }
       
   591 
       
   592 /**
       
   593     Set bit value at position aIndex
       
   594     @param aIndex  index in a bit vector
       
   595     @panic EIndexOutOfRange if aIndex is out of range
       
   596 */
       
   597 inline void RBitVector::SetBitVal(TUint32 aIndex, TBool aVal)
       
   598     {
       
   599     if(aVal) 
       
   600         SetBit(aIndex);
       
   601     else 
       
   602         ResetBit(aIndex);
       
   603     }
       
   604 
       
   605 
       
   606 inline TUint32 RBitVector::MaskLastWord(TUint32 aVal) const
       
   607     {
       
   608     const TUint32 shift = (32-(iNumBits & 0x1F)) & 0x1F;
       
   609     return (aVal << shift) >> shift; //-- mask unused high bits
       
   610     }
       
   611 
       
   612 
       
   613 
       
   614 inline TUint32 RBitVector::WordNum(TUint32 aBitPos)  const
       
   615     {
       
   616     return aBitPos >> 5;
       
   617     }
       
   618 
       
   619 inline TUint32 RBitVector::BitInWord(TUint32 aBitPos) const 
       
   620     {
       
   621     return aBitPos & 0x1F;
       
   622     }
       
   623 
   538 
   624 /**
   539 /**
   625     Calculate offset of the page starting position in the cluster 
   540     Calculate offset of the page starting position in the cluster 
   626     @param aPos  the current entry position in bytes in the cluster
   541     @param aPos  the current entry position in bytes in the cluster
   627     @param aPageSzLog2	page size in log2
   542     @param aPageSzLog2	page size in log2