System.IO.Compression.InputBuffer.GetBits C# (CSharp) Méthode

GetBits() public méthode

public GetBits ( int count ) : int
count int
Résultat int
        public int GetBits(int count) {
            if (!this.EnsureBitsAvailable(count)) {
                return -1;
            }
            int num = (int)(this.bitBuffer & this.GetBitMask(count));
            this.bitBuffer = this.bitBuffer >> count;
            this.bitsInBuffer -= count;
            return num;
        }

Usage Example

        public bool ReadFooter(InputBuffer input)
        {
            input.SkipToByteBoundary();
            if (gzipFooterSubstate == GzipHeaderState.ReadingCRC)
            {
                while (loopCounter < 4)
                {
                    int bits = input.GetBits(8);
                    if (bits < 0)
                    {
                        return(false);
                    }

                    expectedCrc32 |= ((uint)bits << (8 * loopCounter));
                    loopCounter++;
                }
                gzipFooterSubstate = GzipHeaderState.ReadingFileSize;
                loopCounter        = 0;
            }

            if (gzipFooterSubstate == GzipHeaderState.ReadingFileSize)
            {
                if (loopCounter == 0)
                {
                    expectedOutputStreamSizeModulo = 0;
                }

                while (loopCounter < 4)
                {
                    int bits = input.GetBits(8);
                    if (bits < 0)
                    {
                        return(false);
                    }

                    expectedOutputStreamSizeModulo |= ((uint)bits << (8 * loopCounter));
                    loopCounter++;
                }
            }

            return(true);
        }
All Usage Examples Of System.IO.Compression.InputBuffer::GetBits