Esempio n. 1
0
        public override ScalarValue Decode(Stream inStream)
        {
            ScalarValue decode = NullableUnsignedInteger.Decode(inStream);

            if (decode == null)
            {
                return(null);
            }
            int length   = decode.ToInt();
            var encoding = new byte[length];

            for (int i = 0; i < length; i++)
            {
                try
                {
                    encoding[i] = (byte)inStream.ReadByte();
                }
                catch (IOException e)
                {
                    Global.ErrorHandler.OnError(e, DynError.IoError, "An error occurred while decoding a nullable byte vector.");
                    // BUG? Continue processing on IO exception???
                }
            }

            return(new ByteVectorValue(encoding));
        }
Esempio n. 2
0
 public void TestToIntWithLargeValue()
 {
     try
     {
         ScalarValue value = String("2147483648");
         value.ToInt();
         Assert.Fail();
     }
     catch (FastException e)
     {
         Assert.AreEqual(FastConstants.R4_NUMERIC_VALUE_TOO_LARGE, e.Code);
     }
 }
Esempio n. 3
0
 public void TestToIntWithLargeValue()
 {
     try
     {
         ScalarValue value = String("2147483648");
         value.ToInt();
         Assert.Fail();
     }
     catch (RepErrorException e)
     {
         Assert.AreEqual(RepError.NumericValueTooLarge, e.Error);
     }
 }
Esempio n. 4
0
        public override ScalarValue Decode(Stream inStream)
        {
            ScalarValue exp = NullableInteger.Decode(inStream);

            if ((exp == null) || exp.IsNull)
            {
                return(null);
            }

            int  exponent     = exp.ToInt();
            long mantissa     = Integer.Decode(inStream).ToLong();
            var  decimalValue = new DecimalValue(mantissa, exponent);

            return(decimalValue);
        }
        public override ScalarValue Decode(System.IO.Stream in_Renamed)
        {
            ScalarValue exp = NULLABLE_INTEGER.Decode(in_Renamed);

            if ((exp == null) || exp.Null)
            {
                return(null);
            }

            int  exponent     = exp.ToInt();
            long mantissa     = INTEGER.Decode(in_Renamed).ToLong();
            var  decimalValue = new DecimalValue(mantissa, exponent);

            return(decimalValue);
        }
Esempio n. 6
0
        public override ScalarValue Decode(System.IO.Stream in_Renamed)
        {
            ScalarValue decode = NULLABLE_UNSIGNED_INTEGER.Decode(in_Renamed);

            if (decode == null)
            {
                return(null);
            }
            int length   = decode.ToInt();
            var encoding = new byte[length];

            for (int i = 0; i < length; i++)
            {
                try
                {
                    encoding[i] = (byte)in_Renamed.ReadByte();
                }
                catch (System.IO.IOException e)
                {
                    Global.HandleError(Error.FastConstants.IO_ERROR, "An error occurred while decoding a nullable byte vector.", e);
                }
            }
            return(new ByteVectorValue(encoding));
        }
Esempio n. 7
0
        public void TestToInt()
        {
            ScalarValue value = String("32768");

            Assert.AreEqual(32768, value.ToInt());
        }