Beispiel #1
0
            public static byte Get(Stream stream, byte[] buffer)
            {
                byte one = ReadStreamByte(stream);

                if (one <= BssomType.MaxBlankCodeValue)
                {
                    if (one <= BssomType.MaxVarBlankCodeValue)
                    {
                        AdvanceStream(stream, buffer, one);
                    }
                    else
                    {
                        int len;
                        if (one == BssomType.BlankUInt16Code)
                        {
                            stream.Read(buffer, 0, buffer[2]);
                            len = BssomBinaryPrimitives.ReadUInt16LittleEndian(ref buffer[0]);
                        }
                        else /*if (one == BssomType.EmptyUInt32Code)*/
                        {
                            stream.Read(buffer, 0, buffer[4]);
                            len = checked ((int)BssomBinaryPrimitives.ReadUInt32LittleEndian(ref buffer[0]));
                        }
                        AdvanceStream(stream, buffer, len);
                    }

                    one = ReadStreamByte(stream);
                }

                return(one);
            }
Beispiel #2
0
        internal UInt16 ReadUInt16WithOutTypeHead()
        {
            var val = BssomBinaryPrimitives.ReadUInt16LittleEndian(ref BssomBuffer.ReadRef(BssomBinaryPrimitives.UInt16Size));

            BssomBuffer.SeekWithOutVerify(BssomBinaryPrimitives.UInt16Size, BssomSeekOrgin.Current);
            return(val);
        }
Beispiel #3
0
        internal UInt16 ReadUInt16()
        {
            EnsureTypeWithSkipBlankCharacter(BssomType.UInt16Code);
            var val = BssomBinaryPrimitives.ReadUInt16LittleEndian(ref BssomBuffer.ReadRef(BssomBinaryPrimitives.UInt16Size));

            BssomBuffer.SeekWithOutVerify(BssomBinaryPrimitives.UInt16Size, BssomSeekOrgin.Current);
            return(val);
        }
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);
        }