Beispiel #1
0
        public static ulong ReadCompressedULong(this IReadBytes stream)
        {
            ulong result    = 0;
            int   shiftBits = 0;
            ulong inputByte = (ulong)stream.ReadByte();

            while ((inputByte < MORE_MASK))
            {
                result    |= (inputByte) << shiftBits;
                inputByte  = (ulong)stream.ReadByte();
                shiftBits += 7;
            }
            return(result | ((inputByte & DATA_MASK) << shiftBits));
        }
        public static uint ReadCompressedUInt(this IReadBytes stream)
        {
            uint result    = 0;
            int  shiftBits = 0;

            int inputByte = stream.ReadByte();

            while ((inputByte < MORE_MASK))
            {
                result    |= (uint)((inputByte) << shiftBits);
                inputByte  = stream.ReadByte();
                shiftBits += 7;
            }

            return(result | (uint)((inputByte & DATA_MASK) << shiftBits));
        }
Beispiel #3
0
        public static bool?ReadCompressedNullableBool(this IReadBytes stream)
        {
            var byteValue = stream.ReadByte();

            if (byteValue == 2)
            {
                return(null);
            }
            return(byteValue == 1);
        }
Beispiel #4
0
 public static bool ReadCompressedBool(this IReadBytes stream)
 {
     return(stream.ReadByte() == 1);
 }