Example #1
0
        public uint GetBits <T>(int numBits, T attribute)
        {
            uint value = GetBits(numBits);

            Result.AddAttribute(attribute, value);
            return(value);
        }
Example #2
0
        public bool GetBit <T>(T attributeName)
        {
            bool value = GetBit();

            Result.AddAttribute(attributeName, value);
            return(value);
        }
Example #3
0
        public uint GetExpGolombCoded <T>(T attributeName, IValidityResultFormatter optionResultFormatter)
        {
            uint value = GetExpGolombCoded();

            // Add and verify the option attribute
            // FIXME: is the cast to 'int' necessary!?
            Result.AddAttribute(attributeName, (int)value, optionResultFormatter);
            return(value);
        }
Example #4
0
        public TEnum GetBits <TAttribute, TEnum>(int numBits, TAttribute attribute, EnumResultFormatter <TEnum> enumResultFormatter)
        {
            int value = (int)GetBits(numBits);

            // Add and verify the option attribute
            Result.AddAttribute(attribute, value, enumResultFormatter);
            if (!enumResultFormatter.IsValid(value))
            {
                return(default(TEnum));
            }
            return((TEnum)Enum.ToObject(typeof(TEnum), value));            // FIXME: this is possibly too slow!!
        }
Example #5
0
        public int GetSignedExpGolombCoded <T>(T attributeName, int minValue, int maxValue)
        {
            int value = GetSignedExpGolombCoded();

            if ((value < minValue) || (value > maxValue))
            {
                Result.AddInvalidAttribute(attributeName, value);
                return(maxValue);
            }

            Result.AddAttribute(attributeName, value);
            return(value);
        }
Example #6
0
        public uint GetExpGolombCoded <T>(T attributeName, uint maxCodeNum)
        {
            uint value = GetExpGolombCoded();

            if (value > maxCodeNum)
            {
                Result.AddInvalidAttribute(attributeName, value);
                return(maxCodeNum);
            }

            Result.AddAttribute(attributeName, value);
            return(value);
        }
Example #7
0
        public uint GetFixedBits <T>(int numBits, uint bitCode, T attributeName)
        {
            uint value = GetBits(numBits);

            if (value == bitCode)
            {
                Result.AddAttribute(attributeName, value);
            }
            else
            {
                Result.AddInvalidAttribute(attributeName, value);
            }
            return(value);
        }
Example #8
0
        public byte GetByte <T>(bool align, T attributeName, byte maxValue)
        {
            byte value = GetByte(align);

            if (value > maxValue)
            {
                Result.AddInvalidAttribute(attributeName, value);
            }
            else
            {
                Result.AddAttribute(attributeName, value);
            }
            return(Math.Min(value, maxValue));
        }