Beispiel #1
0
        internal UInt64 ReadUInt64WithOutTypeHead()
        {
            var val = BssomBinaryPrimitives.ReadUInt64LittleEndian(ref BssomBuffer.ReadRef(BssomBinaryPrimitives.UInt64Size));

            BssomBuffer.SeekWithOutVerify(BssomBinaryPrimitives.UInt64Size, BssomSeekOrgin.Current);
            return(val);
        }
Beispiel #2
0
        internal UInt64 ReadUInt64()
        {
            EnsureTypeWithSkipBlankCharacter(BssomType.UInt64Code);
            var val = BssomBinaryPrimitives.ReadUInt64LittleEndian(ref BssomBuffer.ReadRef(BssomBinaryPrimitives.UInt64Size));

            BssomBuffer.SeekWithOutVerify(BssomBinaryPrimitives.UInt64Size, BssomSeekOrgin.Current);
            return(val);
        }
        private static ulong[] ConvertULong(byte[] bin)
        {
            int ul = (int)Math.Ceiling((decimal)bin.Length / 8);

            ulong[] u = new ulong[ul];
            Unsafe.CopyBlock(ref Unsafe.As <ulong, byte>(ref u[0]), ref bin[0], (uint)bin.Length);
            for (int i = 0; i < u.Length; i++)
            {
                u[i] = BssomBinaryPrimitives.ReadUInt64LittleEndian(ref Unsafe.As <ulong, byte>(ref u[i]));
            }
            return(u);
        }
Beispiel #4
0
        private ulong ReadVariableNumberCore()
        {
            ReadStreamToBuffer(1);
            byte  code = buffer[position - 1];
            ulong val;

            switch (code)
            {
            case BssomBinaryPrimitives.VariableUInt9:
            {
                ReadStreamToBuffer(1);
                val = (ulong)(BssomBinaryPrimitives.VariableUInt8Max + buffer[position - 1]);
                break;
            }

            case BssomBinaryPrimitives.FixUInt8:
            {
                ReadStreamToBuffer(1);
                val = buffer[position - 1];
                break;
            }

            case BssomBinaryPrimitives.FixUInt16:
            {
                ReadStreamToBuffer(2);
                val = BssomBinaryPrimitives.ReadUInt16LittleEndian(ref buffer[position - 2]);
                break;
            }

            case BssomBinaryPrimitives.FixUInt32:
            {
                ReadStreamToBuffer(4);
                val = BssomBinaryPrimitives.ReadUInt32LittleEndian(ref buffer[position - 4]);
                break;
            }

            case BssomBinaryPrimitives.FixUInt64:
            {
                ReadStreamToBuffer(8);
                val = BssomBinaryPrimitives.ReadUInt64LittleEndian(ref buffer[position - 8]);
                break;
            }

            default:
                return(code);
            }
            return(val);
        }
Beispiel #5
0
        public unsafe ulong this[int i]
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get
            {
                if (i != _uint64Count - 1 || _lastUInt64ByteCount == 8)
                {
                    return(BssomBinaryPrimitives.ReadUInt64LittleEndian(ref _us[i * 8]));
                }

                int   startPos = (_uint64Count - 1) * 8;
                ulong value1   = 0;
                Unsafe.CopyBlock(ref Unsafe.As <ulong, byte>(ref value1), ref _us[startPos], (uint)_lastUInt64ByteCount);
                return(BssomBinaryPrimitives.ReadRawUInt64LittleEndian(value1));
            }
        }