Esempio n. 1
0
        public void Write(ushort source)
        {
            int num = this.bitLength + 16;

            this.A(num);
            BytesUtil.WriteUInt32((uint)source, 16, this.dataBytes, this.bitLength);
            this.bitLength = num;
        }
Esempio n. 2
0
        public void Write(ushort source, int numberOfBits)
        {
            int num = this.bitLength + numberOfBits;

            this.A(num);
            BytesUtil.WriteUInt32((uint)source, numberOfBits, this.dataBytes, this.bitLength);
            this.bitLength = num;
        }
Esempio n. 3
0
        public void Write(byte source)
        {
            int num = this.bitLength + 8;

            this.A(num);
            BytesUtil.WriteByte(source, 8, this.dataBytes, this.bitLength);
            this.bitLength = num;
        }
Esempio n. 4
0
        public void Write(long source, int numberOfBits)
        {
            int num = this.bitLength + numberOfBits;

            this.A(num);
            BytesUtil.WriteUInt64((ulong)source, numberOfBits, this.dataBytes, this.bitLength);
            this.bitLength = num;
        }
Esempio n. 5
0
        public void Write(byte source, int numberOfBits)
        {
            int num = this.bitLength + numberOfBits;

            this.A(num);
            BytesUtil.WriteByte(source, numberOfBits, this.dataBytes, this.bitLength);
            this.bitLength = num;
        }
Esempio n. 6
0
        public void Write(bool source)
        {
            int num = this.bitLength + 1;

            this.A(num);
            BytesUtil.WriteByte((byte)(source ? 1 : 0), 1, this.dataBytes, this.bitLength);
            this.bitLength = num;
        }
Esempio n. 7
0
        public void Write(byte[] source, int byteOffset, int byteLength)
        {
            int num = this.bitLength + byteLength * 8;

            this.A(num);
            BytesUtil.WriteBytes(source, byteOffset, byteLength, this.dataBytes, this.bitLength);
            this.bitLength = num;
        }
Esempio n. 8
0
        public void Write(ulong source)
        {
            int num = this.bitLength + 64;

            this.A(num);
            BytesUtil.WriteUInt64(source, 64, this.dataBytes, this.bitLength);
            this.bitLength = num;
        }
Esempio n. 9
0
        public void ReadBuffer(byte[] destination, int byteOffset, int byteLength)
        {
            int num = this.bitPosition + byteLength * 8;

            if (this.overflow_ || num > this.endBitPosition)
            {
                this.overflow_ = true;
                return;
            }
            BytesUtil.ReadBytes(this.dataBytes, byteLength, this.bitPosition, destination, byteOffset);
            this.bitPosition = num;
        }
Esempio n. 10
0
        public uint ReadUInt32(int numberOfBits)
        {
            int num = this.bitPosition + numberOfBits;

            if (this.overflow_ || num > this.endBitPosition)
            {
                this.overflow_ = true;
                return(0u);
            }
            uint result = BytesUtil.ReadUInt32(this.dataBytes, numberOfBits, this.bitPosition);

            this.bitPosition += numberOfBits;
            return(result);
        }
Esempio n. 11
0
        public uint ReadUInt32()
        {
            int num = this.bitPosition + 32;

            if (this.overflow_ || num > this.endBitPosition)
            {
                this.overflow_ = true;
                return(0u);
            }
            uint result = BytesUtil.ReadUInt32(this.dataBytes, 32, this.bitPosition);

            this.bitPosition += 32;
            return(result);
        }
Esempio n. 12
0
        public ushort ReadUInt16()
        {
            int num = this.bitPosition + 16;

            if (this.overflow_ || num > this.endBitPosition)
            {
                this.overflow_ = true;
                return(0);
            }
            uint num2 = BytesUtil.ReadUInt32(this.dataBytes, 16, this.bitPosition);

            this.bitPosition = num;
            return((ushort)num2);
        }
Esempio n. 13
0
        public bool ReadBoolean()
        {
            int num = this.bitPosition + 1;

            if (this.overflow_ || num > this.endBitPosition)
            {
                this.overflow_ = true;
                return(false);
            }
            byte b = BytesUtil.ReadByte(this.dataBytes, 1, this.bitPosition);

            this.bitPosition = num;
            return(b > 0);
        }
Esempio n. 14
0
        public byte ReadByte()
        {
            int num = this.bitPosition + 8;

            if (this.overflow_ || num > this.endBitPosition)
            {
                this.overflow_ = true;
                return(0);
            }
            byte result = BytesUtil.ReadByte(this.dataBytes, 8, this.bitPosition);

            this.bitPosition = num;
            return(result);
        }
Esempio n. 15
0
        public ulong ReadUInt64()
        {
            int num = this.bitPosition + 64;

            if (this.overflow_ || num > this.endBitPosition)
            {
                this.overflow_ = true;
                return(0uL);
            }
            ulong num2 = (ulong)BytesUtil.ReadUInt32(this.dataBytes, 32, this.bitPosition);

            this.bitPosition += 32;
            ulong num3 = (ulong)BytesUtil.ReadUInt32(this.dataBytes, 32, this.bitPosition);

            this.bitPosition += 32;
            return(num2 + (num3 << 32));
        }
Esempio n. 16
0
        public unsafe void Write(uint source)
        {
            int num = this.bitLength + 32;

            this.A(num);
            if (this.bitLength % 8 == 0)
            {
                fixed(byte *ptr = &this.dataBytes[this.bitLength / 8])
                {
                    *(int *)ptr = (int)source;
                }
            }
            else
            {
                BytesUtil.WriteUInt32(source, 32, this.dataBytes, this.bitLength);
            }
            this.bitLength = num;
        }
Esempio n. 17
0
        public void Write(int source, int numberOfBits)
        {
            int num = this.bitLength + numberOfBits;

            this.A(num);
            if (numberOfBits != 32)
            {
                int num2 = 1 << numberOfBits - 1;
                if (source < 0)
                {
                    source = (-source - 1 | num2);
                }
                else
                {
                    source &= ~num2;
                }
            }
            BytesUtil.WriteUInt32((uint)source, numberOfBits, this.dataBytes, this.bitLength);
            this.bitLength = num;
        }
Esempio n. 18
0
        public ulong ReadUInt64(int numberOfBits)
        {
            int num = this.bitPosition + numberOfBits;

            if (this.overflow_ || num > this.endBitPosition)
            {
                this.overflow_ = true;
                return(0uL);
            }
            ulong num2;

            if (numberOfBits <= 32)
            {
                num2 = (ulong)BytesUtil.ReadUInt32(this.dataBytes, numberOfBits, this.bitPosition);
            }
            else
            {
                num2  = (ulong)BytesUtil.ReadUInt32(this.dataBytes, 32, this.bitPosition);
                num2 |= (ulong)BytesUtil.ReadUInt32(this.dataBytes, numberOfBits - 32, this.bitPosition);
            }
            this.bitPosition += numberOfBits;
            return(num2);
        }
Esempio n. 19
0
        public static int WriteUInt64(ulong source, int numberOfBits, byte[] destination, int destinationBitOffset)
        {
            int result = destinationBitOffset + numberOfBits;

            if (numberOfBits <= 8)
            {
                BytesUtil.WriteByte((byte)source, numberOfBits, destination, destinationBitOffset);
                return(result);
            }
            BytesUtil.WriteByte((byte)source, 8, destination, destinationBitOffset);
            destinationBitOffset += 8;
            numberOfBits         -= 8;
            if (numberOfBits <= 8)
            {
                BytesUtil.WriteByte((byte)(source >> 8), numberOfBits, destination, destinationBitOffset);
                return(result);
            }
            BytesUtil.WriteByte((byte)(source >> 8), 8, destination, destinationBitOffset);
            destinationBitOffset += 8;
            numberOfBits         -= 8;
            if (numberOfBits <= 8)
            {
                BytesUtil.WriteByte((byte)(source >> 16), numberOfBits, destination, destinationBitOffset);
                return(result);
            }
            BytesUtil.WriteByte((byte)(source >> 16), 8, destination, destinationBitOffset);
            destinationBitOffset += 8;
            numberOfBits         -= 8;
            if (numberOfBits <= 8)
            {
                BytesUtil.WriteByte((byte)(source >> 24), numberOfBits, destination, destinationBitOffset);
                return(result);
            }
            BytesUtil.WriteByte((byte)(source >> 24), 8, destination, destinationBitOffset);
            destinationBitOffset += 8;
            numberOfBits         -= 8;
            if (numberOfBits <= 8)
            {
                BytesUtil.WriteByte((byte)(source >> 32), numberOfBits, destination, destinationBitOffset);
                return(result);
            }
            BytesUtil.WriteByte((byte)(source >> 32), 8, destination, destinationBitOffset);
            destinationBitOffset += 8;
            numberOfBits         -= 8;
            if (numberOfBits <= 8)
            {
                BytesUtil.WriteByte((byte)(source >> 40), numberOfBits, destination, destinationBitOffset);
                return(result);
            }
            BytesUtil.WriteByte((byte)(source >> 40), 8, destination, destinationBitOffset);
            destinationBitOffset += 8;
            numberOfBits         -= 8;
            if (numberOfBits <= 8)
            {
                BytesUtil.WriteByte((byte)(source >> 48), numberOfBits, destination, destinationBitOffset);
                return(result);
            }
            BytesUtil.WriteByte((byte)(source >> 48), 8, destination, destinationBitOffset);
            destinationBitOffset += 8;
            numberOfBits         -= 8;
            if (numberOfBits <= 8)
            {
                BytesUtil.WriteByte((byte)(source >> 56), numberOfBits, destination, destinationBitOffset);
                return(result);
            }
            BytesUtil.WriteByte((byte)(source >> 56), 8, destination, destinationBitOffset);
            destinationBitOffset += 8;
            numberOfBits         -= 8;
            return(result);
        }