MiscUtil.IO.EndianBinaryReader.Read7BitEncodedInt C# (CSharp) Method

Read7BitEncodedInt() public method

Reads a 7-bit encoded integer from the stream. This is stored with the least significant information first, with 7 bits of information per byte of value, and the top bit as a continuation flag. This method is not affected by the endianness of the bit converter.
public Read7BitEncodedInt ( ) : int
return int
        public int Read7BitEncodedInt()
        {
            CheckDisposed();

            int ret=0;
            for (int shift = 0; shift < 35; shift+=7)
            {
                int b = stream.ReadByte();
                if (b==-1)
                {
                    throw new EndOfStreamException();
                }
                ret = ret | ((b&0x7f) << shift);
                if ((b & 0x80) == 0)
                {
                    return ret;
                }
            }
            // Still haven't seen a byte with the high bit unset? Dodgy data.
            throw new IOException("Invalid 7-bit encoded integer in stream.");
        }