Logo Search packages:      
Sourcecode: kmess version File versions  Download package

bool DataSource::getBit ( bool *  ok = 0  ) 

Retrieve the next bit from the data.

Parameters:
ok If set, it will contain whether the call was successful or not.
Returns:
bool

Definition at line 331 of file datasource.cpp.

References currentBitIndex_, currentByte_, and moveByteToBitArray().

Referenced by getBits(), and getByte().

{
  if( currentBitIndex_ >= 8 )
  {
    // Also check the index again, in case somehow moveByteToBitArray()
    // fails to move the bit index
    if( ( ! moveByteToBitArray() ) || currentBitIndex_ >= 8 )
    {
      if( ok != 0 )
      {
        *ok = false;
      }
      return false;
    }

    Q_ASSERT( currentBitIndex_ == 0 );
  }

  Q_ASSERT( currentByte_.size() == 8 );

  if( ok != 0 )
  {
    *ok = true;
  }

  ++currentBitIndex_;

  return currentByte_.at( currentBitIndex_ - 1 );
}


Generated by  Doxygen 1.6.0   Back to index