Пример #1
0
        /**
         * read res value, convert from different types to string.
         */
        public static async Task <ResourceValue> readResValue(ByteBuffer buffer, StringPool stringPool)
        {
            //        ResValue resValue = new ResValue();
            int size = await Buffers.readUShort(buffer);

            short res0     = Buffers.readUByte(buffer);
            short dataType = Buffers.readUByte(buffer);

            switch (dataType)
            {
            case ResValue.ResType.INT_DEC:
                return(ResourceValue.decimal_(buffer.getInt()));

            case ResValue.ResType.INT_HEX:
                return(ResourceValue.hexadecimal(buffer.getInt()));

            case ResValue.ResType.STRING:
                int strRef = buffer.getInt();
                if (strRef >= 0)
                {
                    return(ResourceValue.string_(strRef, stringPool));
                }
                else
                {
                    return(null);
                }

            case ResValue.ResType.REFERENCE:
                return(ResourceValue.reference(buffer.getInt()));

            case ResValue.ResType.INT_BOOLEAN:
                return(ResourceValue.bool_(buffer.getInt()));

            case ResValue.ResType.NULL:
                return(ResourceValue.nullValue());

            case ResValue.ResType.INT_COLOR_RGB8:
            case ResValue.ResType.INT_COLOR_RGB4:
                return(ResourceValue.rgb(buffer.getInt(), 6));

            case ResValue.ResType.INT_COLOR_ARGB8:
            case ResValue.ResType.INT_COLOR_ARGB4:
                return(ResourceValue.rgb(buffer.getInt(), 8));

            case ResValue.ResType.DIMENSION:
                return(ResourceValue.dimension(buffer.getInt()));

            case ResValue.ResType.FRACTION:
                return(ResourceValue.fraction(buffer.getInt()));

            default:
                return(ResourceValue.raw(buffer.getInt(), dataType));
            }
        }