/** * */ protected void ConsumeFieldData() //throws IOException { sbyte fieldPrefix = Reader.ReadSByte(); int typeId = Reader.ReadByte(); int nRead = 2; bool fixedWidth = FudgeFieldPrefixCodec.IsFixedWidth(fieldPrefix); bool hasOrdinal = FudgeFieldPrefixCodec.HasOrdinal(fieldPrefix); bool hasName = FudgeFieldPrefixCodec.HasName(fieldPrefix); int?ordinal = null; if (hasOrdinal) { ordinal = Reader.ReadInt16(); nRead += 2; } string name = null; if (hasName) { int nameSize = Reader.ReadByte(); nRead++; name = StringFieldType.ReadString(Reader, nameSize); nRead += nameSize; } else if (ordinal != null) { if (Taxonomy != null) { name = Taxonomy.GetFieldName((short)ordinal.Value); } } FudgeFieldType type = FudgeContext.TypeDictionary.GetByTypeId(typeId); if (type == null) { if (fixedWidth) { throw new FudgeRuntimeException("Unknown fixed width type " + typeId + " for field " + ordinal + ":" + name + " cannot be handled."); } type = FudgeContext.TypeDictionary.GetUnknownType(typeId); } int varSize = 0; if (!fixedWidth) { int varSizeBytes = FudgeFieldPrefixCodec.GetFieldWidthByteCount(fieldPrefix); switch (varSizeBytes) { case 0: varSize = 0; break; case 1: varSize = Reader.ReadByte(); nRead += 1; break; case 2: varSize = Reader.ReadInt16(); nRead += 2; break; case 4: varSize = Reader.ReadInt32(); nRead += 4; break; default: throw new FudgeRuntimeException("Illegal number of bytes indicated for variable width encoding: " + varSizeBytes); } } FieldName = name; FieldOrdinal = ordinal; FieldType = type; MessageProcessingState currMsgProcessingState = processingStack.Peek(); currMsgProcessingState.Consumed += nRead; if (typeId == FudgeTypeDictionary.FUDGE_MSG_TYPE_ID) { CurrentElement = FudgeStreamElement.SubmessageFieldStart; FieldValue = null; MessageProcessingState subState = new MessageProcessingState(); subState.MessageSize = varSize; subState.Consumed = 0; processingStack.Push(subState); } else { CurrentElement = FudgeStreamElement.SimpleField; FieldValue = ReadFieldValue(Reader, FieldType, varSize); if (fixedWidth) { currMsgProcessingState.Consumed += type.FixedSize; } else { currMsgProcessingState.Consumed += varSize; } } }
public void HasNameChecks() { Assert.False(FudgeFieldPrefixCodec.HasName(0x20)); Assert.True(FudgeFieldPrefixCodec.HasName(0x98)); }