public byte GetSessionID(int index) { if ((uint)index >= 10) { ThrowHelper.ThrowIndexOutOfRangeException(index); } return(_buffer.CharGet(_offset + 0 + (index * 1))); }
public byte GetQuoteEntryID(int index) { if (index < 0 || index >= 10) { throw new IndexOutOfRangeException("index out of range: index=" + index); } return(_buffer.CharGet(_offset + 0 + (index * 1))); }
public byte GetSecurityGroup(int index) { if (index < 0 || index >= 6) { throw new IndexOutOfRangeException("index out of range: index=" + index); } return(_buffer.CharGet(_offset + 10 + (index * 1))); }
public byte GetEnteringTrader(int index) { if ((uint)index >= 5) { ThrowHelper.ThrowIndexOutOfRangeException(index); } return(_buffer.CharGet(_offset + 44 + (index * 1))); }
private static long GetLong(DirectBuffer buffer, int index, Encoding encoding) { switch (encoding.PrimitiveType.Type) { case SbePrimitiveType.Char: return(buffer.CharGet(index)); case SbePrimitiveType.Int8: return(buffer.Int8Get(index)); case SbePrimitiveType.Int16: return(buffer.Int16GetLittleEndian(index)); case SbePrimitiveType.Int32: return(buffer.Int32GetLittleEndian(index)); case SbePrimitiveType.Int64: return(buffer.Int64GetLittleEndian(index)); case SbePrimitiveType.UInt8: return(buffer.Uint8Get(index)); case SbePrimitiveType.UInt16: return(buffer.Uint16GetLittleEndian(index)); case SbePrimitiveType.UInt32: return(buffer.Uint32GetLittleEndian(index)); case SbePrimitiveType.UInt64: return((long)buffer.Uint64GetLittleEndian(index)); // TODO this is incorrect default: throw new ArgumentException("Unsupported type for long: " + encoding.PrimitiveType); } }
public void ShouldGetByte(byte value, int index) { _buffer[index] = value; var result = _directBuffer.CharGet(index); Assert.AreEqual(value, result); }
public byte GetManufacturerCode(int index) { if (index < 0 || index >= 3) { throw new IndexOutOfRangeException("index out of range: index=" + index); } return(_buffer.CharGet(_offset + 3 + (index * 1))); }
public byte GetVehicleCode(int index) { if (index < 0 || index >= 6) { throw new IndexOutOfRangeException("index out of range: index=" + index); } return(_buffer.CharGet(_offset + 32 + (index * 1))); }
public byte GetValue(int index) { if (index < 0 || index >= 30) { throw new IndexOutOfRangeException("index out of range: index=" + index); } return _buffer.CharGet(_offset + 0 + (index * 1)); }
public byte GetVehicleCode(int index) { if ((uint)index >= 6) { ThrowHelper.ThrowIndexOutOfRangeException(index); } return(_buffer.CharGet(_offset + 28 + (index * 1))); }
public byte GetManufacturerCode(int index) { if ((uint)index >= 3) { ThrowHelper.ThrowIndexOutOfRangeException(index); } return(_buffer.CharGet(_offset + 3 + (index * 1))); }
public static PrimitiveValue Get(DirectBuffer buffer, PrimitiveType type, int length) { if (length == 0) { return(null); } switch (type.Type) { case SbePrimitiveType.Char: if (length == 1) { return(new PrimitiveValue(buffer.CharGet(0), 1)); } else { var array = new byte[length]; buffer.GetBytes(0, array, 0, array.Length); return(new PrimitiveValue(array, "UTF-8", array.Length)); } case SbePrimitiveType.Int8: return(new PrimitiveValue(buffer.Int8Get(0), 1)); case SbePrimitiveType.Int16: return(new PrimitiveValue(buffer.Int16GetLittleEndian(0), 2)); case SbePrimitiveType.Int32: return(new PrimitiveValue(buffer.Int32GetLittleEndian(0), 4)); case SbePrimitiveType.Int64: return(new PrimitiveValue(buffer.Int64GetLittleEndian(0), 8)); case SbePrimitiveType.UInt8: return(new PrimitiveValue(buffer.Uint8Get(0), 1)); case SbePrimitiveType.UInt16: return(new PrimitiveValue(buffer.Uint16GetLittleEndian(0), 2)); case SbePrimitiveType.UInt32: return(new PrimitiveValue(buffer.Uint32GetLittleEndian(0), 4)); case SbePrimitiveType.UInt64: return(new PrimitiveValue(buffer.Uint64GetLittleEndian(0), 8)); case SbePrimitiveType.Float: return(new PrimitiveValue(buffer.FloatGetLittleEndian(0), 4)); case SbePrimitiveType.Double: return(new PrimitiveValue(buffer.DoubleGetLittleEndian(0), 8)); default: return(null); } }
public static PrimitiveValue Get(DirectBuffer buffer, PrimitiveType type, int length) { if (length == 0) { return null; } switch (type.Type) { case SbePrimitiveType.Char: if (length == 1) { return new PrimitiveValue(buffer.CharGet(0), 1); } else { var array = new byte[length]; buffer.GetBytes(0, array, 0, array.Length); return new PrimitiveValue(array, "UTF-8", array.Length); } case SbePrimitiveType.Int8: return new PrimitiveValue(buffer.Int8Get(0), 1); case SbePrimitiveType.Int16: return new PrimitiveValue(buffer.Int16GetLittleEndian(0), 2); case SbePrimitiveType.Int32: return new PrimitiveValue(buffer.Int32GetLittleEndian(0), 4); case SbePrimitiveType.Int64: return new PrimitiveValue(buffer.Int64GetLittleEndian(0), 8); case SbePrimitiveType.UInt8: return new PrimitiveValue(buffer.Uint8Get(0), 1); case SbePrimitiveType.UInt16: return new PrimitiveValue(buffer.Uint16GetLittleEndian(0), 2); case SbePrimitiveType.UInt32: return new PrimitiveValue(buffer.Uint32GetLittleEndian(0), 4); case SbePrimitiveType.UInt64: return new PrimitiveValue(buffer.Uint64GetLittleEndian(0), 8); case SbePrimitiveType.Float: return new PrimitiveValue(buffer.FloatGetLittleEndian(0), 4); case SbePrimitiveType.Double: return new PrimitiveValue(buffer.DoubleGetLittleEndian(0), 8); default: return null; } }
//TODO big endian private static void MapEncodingToString(StringBuilder sb, DirectBuffer buffer, int index, Encoding encoding) { switch (encoding.PrimitiveType.Type) { case SbePrimitiveType.Char: sb.Append('\'').Append(buffer.CharGet(index)).Append('\''); break; case SbePrimitiveType.Int8: sb.Append(buffer.Int8Get(index)); break; case SbePrimitiveType.Int16: sb.Append(buffer.Int16GetLittleEndian(index)); break; case SbePrimitiveType.Int32: sb.Append(buffer.Int32GetLittleEndian(index)); break; case SbePrimitiveType.Int64: sb.Append(buffer.Int64GetLittleEndian(index)); break; case SbePrimitiveType.UInt8: sb.Append(buffer.Uint8Get(index)); break; case SbePrimitiveType.UInt16: sb.Append(buffer.Uint16GetLittleEndian(index)); break; case SbePrimitiveType.UInt32: sb.Append(buffer.Uint32GetLittleEndian(index)); break; case SbePrimitiveType.UInt64: sb.Append(buffer.Uint64GetLittleEndian(index)); break; case SbePrimitiveType.Float: sb.Append(buffer.FloatGetLittleEndian(index)); break; case SbePrimitiveType.Double: sb.Append(buffer.DoubleGetLittleEndian(index)); break; } }
private int WriteFieldsToTable(IWritableReactiveTable table, IReactiveColumn column, int rowId, DirectBuffer buffer, int bufferOffset, int read) { var columnId = column.ColumnId; var remaining = read - bufferOffset; if (column.Type == typeof(int)) { if (remaining < sizeof(int)) { return(-1); } table.SetValue(columnId, rowId, buffer.Int32GetLittleEndian(bufferOffset)); return(sizeof(int)); } else if (column.Type == typeof(short)) { if (remaining < sizeof(short)) { return(-1); } table.SetValue(columnId, rowId, buffer.Int16GetLittleEndian(bufferOffset)); return(sizeof(short)); } else if (column.Type == typeof(string)) { if (remaining < sizeof(ushort)) { return(-1); } var stringLength = buffer.Uint16GetLittleEndian(bufferOffset); bufferOffset += sizeof(ushort); remaining = read - bufferOffset; if (remaining < stringLength) { return(-1); } var bytesRead = buffer.GetBytes(bufferOffset, _stringTempBuffer, 0, stringLength); var value = Encoding.Default.GetString(_stringTempBuffer, 0, bytesRead); table.SetValue(columnId, rowId, value); return(sizeof(ushort) + bytesRead); } else if (column.Type == typeof(bool)) { if (remaining < sizeof(byte)) { return(-1); } var b = buffer.CharGet(bufferOffset); table.SetValue(columnId, rowId, b == 1); return(sizeof(byte)); } else if (column.Type == typeof(double)) { if (remaining < sizeof(double)) { return(-1); } var value = buffer.DoubleGetLittleEndian(bufferOffset); table.SetValue(columnId, rowId, value); return(sizeof(double)); } else if (column.Type == typeof(long)) { if (remaining < sizeof(long)) { return(-1); } table.SetValue(columnId, rowId, buffer.Int64GetLittleEndian(bufferOffset)); return(sizeof(long)); } else if (column.Type == typeof(decimal)) { if (remaining < sizeof(decimal)) { return(-1); } Buffer.BlockCopy(_byteArray, bufferOffset, _decimalBuffer, 0, _decimalBuffer.Length); table.SetValue(columnId, rowId, _bytesToDecimal(_decimalBuffer)); return(_decimalBuffer.Length); } else if (column.Type == typeof(DateTime)) { // table.SetValue(columnId, rowId, BclHelpers.ReadDateTime(reader)); } else if (column.Type == typeof(TimeSpan)) { // table.SetValue(columnId, rowId, BclHelpers.ReadTimeSpan(reader)); } else if (column.Type == typeof(Guid)) { // table.SetValue(columnId, rowId, BclHelpers.ReadGuid(reader)); } else if (column.Type == typeof(byte)) { if (remaining < sizeof(byte)) { return(-1); } table.SetValue(columnId, rowId, buffer.CharGet(bufferOffset)); return(sizeof(byte)); } else if (column.Type == typeof(char)) { if (remaining < sizeof(char)) { return(-1); } table.SetValue(columnId, rowId, (char)buffer.Uint16GetLittleEndian(bufferOffset)); return(sizeof(char)); } else if (column.Type == typeof(float)) { if (remaining < sizeof(float)) { return(-1); } table.SetValue(columnId, rowId, buffer.FloatGetLittleEndian(bufferOffset)); return(sizeof(float)); } return(0); }
private static long GetLong(DirectBuffer buffer, int index, Encoding encoding) { switch (encoding.PrimitiveType.Type) { case SbePrimitiveType.Char: return buffer.CharGet(index); case SbePrimitiveType.Int8: return buffer.Int8Get(index); case SbePrimitiveType.Int16: return buffer.Int16GetLittleEndian(index); case SbePrimitiveType.Int32: return buffer.Int32GetLittleEndian(index); case SbePrimitiveType.Int64: return buffer.Int64GetLittleEndian(index); case SbePrimitiveType.UInt8: return buffer.Uint8Get(index); case SbePrimitiveType.UInt16: return buffer.Uint16GetLittleEndian(index); case SbePrimitiveType.UInt32: return buffer.Uint32GetLittleEndian(index); case SbePrimitiveType.UInt64: return (long) buffer.Uint64GetLittleEndian(index); // TODO this is incorrect default: throw new ArgumentException("Unsupported type for long: " + encoding.PrimitiveType); } }
private void FillValue(DirectBuffer buffer, SbeField field2, ref int offset) { if (field2.Presence.ToLower().Contains("constant")) { return; } SbeField field = field2.Clone(); if (field.PrimitiveType == null) { field.PrimitiveType = field.Type; } if (field.PrimitiveType.ToLower().Equals("uint8")) { field2.Value = buffer.Uint8Get(offset).ToString(); offset += 1; } else if (field.PrimitiveType.ToLower().Equals("uint16")) { field2.Value = buffer.Uint16GetLittleEndian(offset).ToString(); offset += 2; } else if (field.PrimitiveType.ToLower().Equals("uint32")) { field2.Value = buffer.Uint32GetLittleEndian(offset).ToString(); offset += 4; } else if (field.PrimitiveType.ToLower().Equals("uint64")) { field2.Value = buffer.Uint64GetLittleEndian(offset).ToString(); offset += 8; } else if (field.PrimitiveType.ToLower().Equals("int8")) { field2.Value = buffer.Int8Get(offset).ToString(); offset += 1; } else if (field.PrimitiveType.ToLower().Equals("int16")) { field2.Value = buffer.Int16GetLittleEndian(offset).ToString(); offset += 2; } else if (field.PrimitiveType.ToLower().Equals("int32")) { field2.Value = buffer.Int32GetLittleEndian(offset).ToString(); offset += 4; } else if (field.PrimitiveType.ToLower().Equals("int64")) { field2.Value = buffer.Int64GetLittleEndian(offset).ToString(); offset += 8; } else if (field.PrimitiveType.ToLower().Equals("char")) { if (!String.IsNullOrEmpty(field.CharacterEncoding)) { List <byte> charString = new List <byte>(); for (int i = 0; i < field.Length; i++) { charString.Add(buffer.CharGet(offset + i)); } field2.Value = Encoding.GetEncoding(field.CharacterEncoding).GetString(charString.ToArray()); } else { byte[] charString = Encoding.GetEncoding("UTF-8").GetBytes(field.Value); buffer.CharPut(offset, charString[0]); } offset += field.Length.Value; } if (field2.Fields != null && field2.Fields.Count > 0) { if (!field2.Type.ToLower().EndsWith("encoding")) { foreach (SbeField child in field2.Fields) { FillValue(buffer, child, ref offset); } } else { FillValue(buffer, field2.Fields[0], ref offset); List <byte> charString = new List <byte>(); int len = int.Parse(field2.Fields[0].Value); for (int i = 0; i < len; i++) { charString.Add(buffer.CharGet(offset + i)); } field2.Fields[1].Value = Encoding.GetEncoding(field2.Fields[1].CharacterEncoding).GetString(charString.ToArray()); offset += len; } } }