Exemplo n.º 1
0
        byte[] ReadStrPascal(IO.BitStream s, out int actualCount, int prefixBitLength)
        {
            actualCount = TypeExtensions.kNone;

            if (prefixBitLength.IsNone())
            {
                switch (mStorage.LengthPrefix)
                {
                case StringStorageLengthPrefix.Int8: prefixBitLength = Bits.kByteBitCount; break;

                case StringStorageLengthPrefix.Int16: prefixBitLength = Bits.kInt16BitCount; break;

                case StringStorageLengthPrefix.Int32: prefixBitLength = Bits.kInt32BitCount; break;
                }
            }

            int length;

            switch (mStorage.LengthPrefix)
            {
            case StringStorageLengthPrefix.Int7: throw new NotSupportedException();

            case StringStorageLengthPrefix.Int8: length = s.ReadByte(prefixBitLength); break;

            case StringStorageLengthPrefix.Int16: length = s.ReadInt16(prefixBitLength); break;

            case StringStorageLengthPrefix.Int32: length = s.ReadInt32(prefixBitLength); break;

            default: throw new Debug.UnreachableException();
            }

            return(s.ReadBytes(GetMaxCleanByteCount(length)));
        }