public override IFieldValue Decode(Stream inStream, Group decodeTemplate, Context context, BitVectorReader pmapReader) { try { if (!UsesPresenceMapBit || pmapReader.Read()) { if (context.TraceEnabled) { context.DecodeTrace.GroupStart(this); } var groupValue = new GroupValue(this, DecodeFieldValues(inStream, decodeTemplate, context)); if (context.TraceEnabled) { context.DecodeTrace.GroupEnd(); } return(groupValue); } return(null); } catch (DynErrorException e) { throw new DynErrorException(e, e.Error, "Error occurred while decoding {0}", this); } }
public Message ReadMessage() { var bitVectorValue = (BitVectorValue)TypeCodec.BIT_VECTOR.Decode(in_Renamed); if (bitVectorValue == null) { return null; // Must have reached end of stream; } var pmap = bitVectorValue.value_Renamed; var presenceMapReader = new BitVectorReader(pmap); // if template id is not present, use previous, else decode template id int templateId = (presenceMapReader.Read())?((IntegerValue) TypeCodec.UINT.Decode(in_Renamed)).value_Renamed:context.LastTemplateId; var template = context.GetTemplate(templateId); if (template == null) { return null; } context.NewMessage(template); context.LastTemplateId = templateId; return template.Decode(in_Renamed, templateId, presenceMapReader, context); }
public void TestRead() { var reader = new BitVectorReader(new BitVector(ByteUtil.ConvertBitStringToFastByteArray("11000000"))); Assert.IsTrue(reader.Read()); Assert.IsFalse(reader.Read()); Assert.IsFalse(reader.HasMoreBitsSet); }
public Message ReadMessage() { var bitVectorValue = (BitVectorValue)TypeCodec.BIT_VECTOR.Decode(in_Renamed); if (bitVectorValue == null) { return(null); // Must have reached end of stream; } var pmap = bitVectorValue.value_Renamed; var presenceMapReader = new BitVectorReader(pmap); // if template id is not present, use previous, else decode template id int templateId = (presenceMapReader.Read())?((IntegerValue)TypeCodec.UINT.Decode(in_Renamed)).value_Renamed:context.LastTemplateId; var template = context.GetTemplate(templateId); if (template == null) { return(null); } context.NewMessage(template); context.LastTemplateId = templateId; return(template.Decode(in_Renamed, templateId, presenceMapReader, context)); }
public Message ReadMessage() { var bitVectorValue = (BitVectorValue)TypeCodec.BitVector.Decode(_inStream); if (bitVectorValue == null) { return(null); // Must have reached end of stream; } BitVector pmap = bitVectorValue.Value; var presenceMapReader = new BitVectorReader(pmap); // if template id is not present, use previous, else decode template id int templateId = (presenceMapReader.Read()) ? ((IntegerValue)TypeCodec.Uint.Decode(_inStream)).Value : _context.LastTemplateId; MessageTemplate template = _context.GetTemplate(templateId); if (template == null) { return(null); } _context.NewMessage(template); _context.LastTemplateId = templateId; return(template.Decode(_inStream, templateId, presenceMapReader, _context)); }
public override IFieldValue Decode(Stream inStream, Group decodeTemplate, Context context, BitVectorReader presenceMapReader) { var values = new IFieldValue[_fields.Length]; for (int i = 0; i < _fields.Length; i++) { values[i] = _fields[i].Decode(inStream, decodeTemplate, context, presenceMapReader); if (i == 0 && values[0] == null) { return(null); } } return(_valueConverter.Compose(values)); }
public Message Decode(System.IO.Stream in_Renamed, int templateId, BitVectorReader presenceMapReader, Context context) { try { if (context.TraceEnabled) context.DecodeTrace.GroupStart(this); FieldValue[] fieldValues = DecodeFieldValues(in_Renamed, this, presenceMapReader, context); fieldValues[0] = new IntegerValue(templateId); var message = new Message(this, fieldValues); if (context.TraceEnabled) context.DecodeTrace.GroupEnd(); return message; } catch (FastException e) { throw new FastException("An error occurred while decoding " + this, e.Code, e); } }
protected IFieldValue[] DecodeFieldValues(Stream inStream, Group template, BitVectorReader pmapReader, Context context) { var values = new IFieldValue[_fields.Length]; int start = this is MessageTemplate ? 1 : 0; for (int fieldIndex = start; fieldIndex < _fields.Length; fieldIndex++) { Field field = _fields[fieldIndex]; values[fieldIndex] = field.Decode(inStream, field.MessageTemplate ?? template, context, pmapReader); } if (pmapReader.HasMoreBitsSet) { Global.ErrorHandler.OnError(null, RepError.PmapTooManyBits, "The presence map {0} has too many bits for the group {1}", pmapReader, this); } return(values); }
public override IFieldValue Decode(Stream inStream, Group decodeTemplate, Context context, BitVectorReader pmapReader) { var sequenceValue = new SequenceValue(this); IFieldValue lengthValue = _length.Decode(inStream, decodeTemplate, context, pmapReader); if ((lengthValue == ScalarValue.Null) || (lengthValue == null)) { return(null); } int len = ((IntegerValue)lengthValue).Value; for (int i = 0; i < len; i++) { sequenceValue.Add( (GroupValue)_group.Decode(inStream, decodeTemplate, context, BitVectorReader.InfiniteTrue)); } return(sequenceValue); }
public Message Decode(Stream inStream, int templateId, BitVectorReader presenceMapReader, Context context) { try { if (context.TraceEnabled) { context.DecodeTrace.GroupStart(this); } IFieldValue[] fieldValues = DecodeFieldValues(inStream, this, presenceMapReader, context); fieldValues[0] = new IntegerValue(templateId); var message = new Message(this, fieldValues); if (context.TraceEnabled) { context.DecodeTrace.GroupEnd(); } return(message); } catch (DynErrorException e) { throw new DynErrorException(e, e.Error, "An error occurred while decoding {0}", this); } }
public Message Decode(System.IO.Stream in_Renamed, int templateId, BitVectorReader presenceMapReader, Context context) { try { if (context.TraceEnabled) { context.DecodeTrace.GroupStart(this); } FieldValue[] fieldValues = DecodeFieldValues(in_Renamed, this, presenceMapReader, context); fieldValues[0] = new IntegerValue(templateId); var message = new Message(this, fieldValues); if (context.TraceEnabled) { context.DecodeTrace.GroupEnd(); } return(message); } catch (FastException e) { throw new FastException("An error occurred while decoding " + this, e.Code, e); } }
public override FieldValue Decode(System.IO.Stream in_Renamed, Group decodeTemplate, Context context, BitVectorReader presenceMapReader) { var values = new FieldValue[fields.Length]; for (var i = 0; i < fields.Length; i++) { values[i] = fields[i].Decode(in_Renamed, decodeTemplate, context, presenceMapReader); if (i == 0 && values[0] == null) { return(null); } } return(valueConverter.Compose(values)); }
public override IFieldValue Decode(Stream inStream, Group decodeTemplate, Context context, BitVectorReader presenceMapReader) { try { ScalarValue priorValue = null; IDictionary dict = null; QName key = Key; ScalarValue value; int pmapIndex = presenceMapReader.Index; if (IsPresent(presenceMapReader)) { if (context.TraceEnabled) { inStream = new RecordingInputStream(inStream); } if (!_operatorCodec.ShouldDecodeType) { return(_operatorCodec.DecodeValue(null, null, this)); } if (_operatorCodec.DecodeNewValueNeedsPrevious) { dict = context.GetDictionary(Dictionary); priorValue = context.Lookup(dict, decodeTemplate, key); ValidateDictionaryTypeAgainstFieldType(priorValue, _fastType); } ScalarValue decodedValue = _typeCodec.Decode(inStream); value = _operatorCodec.DecodeValue(decodedValue, priorValue, this); if (context.TraceEnabled) { context.DecodeTrace.Field(this, value, decodedValue, ((RecordingInputStream)inStream).Buffer, pmapIndex); } } else { if (_operatorCodec.DecodeEmptyValueNeedsPrevious) { dict = context.GetDictionary(Dictionary); priorValue = context.Lookup(dict, decodeTemplate, key); ValidateDictionaryTypeAgainstFieldType(priorValue, _fastType); } value = _operatorCodec.DecodeEmptyValue(priorValue, this); } ValidateDecodedValueIsCorrectForType(value, _fastType); #warning TODO: Review if this previous "if" statement is needed. // if (Operator != Template.Operator.Operator.DELTA || value != null) if (value != null && (_operatorCodec.DecodeNewValueNeedsPrevious || _operatorCodec.DecodeEmptyValueNeedsPrevious)) { context.Store(dict ?? context.GetDictionary(Dictionary), decodeTemplate, key, value); } return(value); } catch (DynErrorException e) { throw new DynErrorException(e, e.Error, "Error occurred while decoding {0}", this); } }
public override FieldValue Decode(System.IO.Stream in_Renamed, Group decodeTemplate, Context context, BitVectorReader pmapReader) { var sequenceValue = new SequenceValue(this); FieldValue lengthValue = length.Decode(in_Renamed, decodeTemplate, context, pmapReader); if ((lengthValue == ScalarValue.NULL) || (lengthValue == null)) { return(null); } int len = ((IntegerValue)lengthValue).value_Renamed; for (var i = 0; i < len; i++) { sequenceValue.Add((GroupValue)group.Decode(in_Renamed, decodeTemplate, context, BitVectorReader.INFINITE_TRUE)); } return(sequenceValue); }
public abstract IFieldValue Decode(Stream inStream, Group decodeTemplate, Context context, BitVectorReader presenceMapReader);
public override FieldValue Decode(System.IO.Stream in_Renamed, Group decodeTemplate, Context context, BitVectorReader pmapReader) { try { if (!UsesPresenceMapBit() || pmapReader.Read()) { if (context.TraceEnabled) { context.DecodeTrace.GroupStart(this); } var groupValue = new GroupValue(this, DecodeFieldValues(in_Renamed, decodeTemplate, context)); if (context.TraceEnabled) context.DecodeTrace.GroupEnd(); return groupValue; } return null; } catch (FastException e) { throw new FastException("Error occurred while decoding " + this, e.Code, e); } }
public override FieldValue Decode(System.IO.Stream in_Renamed, Group decodeTemplate, Context context, BitVectorReader pmapReader) { return(null); }
static BitVectorReader() { NULL = new NullBitVectorReader(null); INFINITE_TRUE = new InfiniteBitVectorReader(null); }
public override FieldValue Decode(System.IO.Stream in_Renamed, Group decodeTemplate, Context context, BitVectorReader pmapReader) { return null; }
public override FieldValue Decode(System.IO.Stream in_Renamed, Group decodeTemplate, Context context, BitVectorReader presenceMapReader) { var values = new FieldValue[fields.Length]; for (var i = 0; i < fields.Length; i++) { values[i] = fields[i].Decode(in_Renamed, decodeTemplate, context, presenceMapReader); if (i == 0 && values[0] == null) return null; } return valueConverter.Compose(values); }
public override IFieldValue Decode(Stream inStream, Group decodeTemplate, Context context, BitVectorReader pmapReader) { return new FastDecoder(context, inStream).ReadMessage(); }
public override IFieldValue Decode(Stream inStream, Group decodeTemplate, Context context, BitVectorReader presenceMapReader) { try { ScalarValue priorValue = null; IDictionary dict = null; QName key = Key; ScalarValue value; int pmapIndex = presenceMapReader.Index; if (IsPresent(presenceMapReader)) { if (context.TraceEnabled) { inStream = new RecordingInputStream(inStream); } if (!OperatorCodec.ShouldDecodeType) { return(OperatorCodec.DecodeValue(null, null, this)); } if (OperatorCodec.DecodeNewValueNeedsPrevious) { dict = context.GetDictionary(Dictionary); priorValue = context.Lookup(dict, decodeTemplate, key); ValidateDictionaryTypeAgainstFieldType(priorValue, FastType); } ScalarValue decodedValue = TypeCodec.Decode(inStream); value = OperatorCodec.DecodeValue(decodedValue, priorValue, this); if (context.TraceEnabled) { context.DecodeTrace.Field(this, value, decodedValue, ((RecordingInputStream)inStream).Buffer, pmapIndex); } } else { if (OperatorCodec.DecodeEmptyValueNeedsPrevious) { dict = context.GetDictionary(Dictionary); priorValue = context.Lookup(dict, decodeTemplate, key); ValidateDictionaryTypeAgainstFieldType(priorValue, FastType); } value = OperatorCodec.DecodeEmptyValue(priorValue, this); } ValidateDecodedValueIsCorrectForType(value, FastType); // Delta the only operator that ALWAYS return true on IsPresent(presenceMapReader) (UsesPresenceMapBit from AlwaysPresentOperatorCodec always return false) and need previous if ((value != null || !(Operator is Operator.DeltaOperator)) && (OperatorCodec.DecodeNewValueNeedsPrevious || OperatorCodec.DecodeEmptyValueNeedsPrevious)) { context.Store(dict ?? context.GetDictionary(Dictionary), decodeTemplate, key, value); } return(value); } catch (DynErrorException e) { throw new DynErrorException(e, e.Error, "Error occurred while decoding {0}", this); } }
protected IFieldValue[] DecodeFieldValues(Stream inStream, Group template, BitVectorReader pmapReader, Context context) { var values = new IFieldValue[_fields.Length]; int start = this is MessageTemplate ? 1 : 0; for (int fieldIndex = start; fieldIndex < _fields.Length; fieldIndex++) { Field field = _fields[fieldIndex]; values[fieldIndex] = field.Decode(inStream, field.MessageTemplate ?? template, context, pmapReader); } if (pmapReader.HasMoreBitsSet) { Global.ErrorHandler.OnError(null, RepError.PmapTooManyBits, "The presence map {0} has too many bits for the group {1}", pmapReader, this); } return values; }
protected internal virtual bool IsPresent(BitVectorReader presenceMapReader) { return((!UsesPresenceMapBit()) || presenceMapReader.Read()); }
protected internal virtual bool IsPresent(BitVectorReader presenceMapReader) { return (!UsesPresenceMapBit()) || presenceMapReader.Read(); }
public abstract FieldValue Decode(System.IO.Stream in_Renamed, Group decodeTemplate, Context context, BitVectorReader presenceMapReader);
public override IFieldValue Decode(Stream inStream, Group decodeTemplate, Context context, BitVectorReader presenceMapReader) { try { ScalarValue priorValue = null; IDictionary dict = null; QName key = Key; ScalarValue value; int pmapIndex = presenceMapReader.Index; if (IsPresent(presenceMapReader)) { if (context.TraceEnabled) inStream = new RecordingInputStream(inStream); if (!_operatorCodec.ShouldDecodeType) return _operatorCodec.DecodeValue(null, null, this); if (_operatorCodec.DecodeNewValueNeedsPrevious) { dict = context.GetDictionary(Dictionary); priorValue = context.Lookup(dict, decodeTemplate, key); ValidateDictionaryTypeAgainstFieldType(priorValue, _fastType); } ScalarValue decodedValue = _typeCodec.Decode(inStream); value = _operatorCodec.DecodeValue(decodedValue, priorValue, this); if (context.TraceEnabled) context.DecodeTrace.Field(this, value, decodedValue, ((RecordingInputStream) inStream).Buffer, pmapIndex); } else { if (_operatorCodec.DecodeEmptyValueNeedsPrevious) { dict = context.GetDictionary(Dictionary); priorValue = context.Lookup(dict, decodeTemplate, key); ValidateDictionaryTypeAgainstFieldType(priorValue, _fastType); } value = _operatorCodec.DecodeEmptyValue(priorValue, this); } ValidateDecodedValueIsCorrectForType(value, _fastType); #warning TODO: Review if this previous "if" statement is needed. // if (Operator != Template.Operator.Operator.DELTA || value != null) if (value != null && (_operatorCodec.DecodeNewValueNeedsPrevious || _operatorCodec.DecodeEmptyValueNeedsPrevious)) { context.Store(dict ?? context.GetDictionary(Dictionary), decodeTemplate, key, value); } return value; } catch (DynErrorException e) { throw new DynErrorException(e, e.Error, "Error occurred while decoding {0}", this); } }
protected bool IsPresent(BitVectorReader presenceMapReader) { return((!UsesPresenceMapBit) || presenceMapReader.Read()); }
public override FieldValue Decode(System.IO.Stream in_Renamed, Group decodeTemplate, Context context, BitVectorReader presenceMapReader) { try { ScalarValue previousValue = null; if (operator_Renamed.UsesDictionary()) { previousValue = context.Lookup(Dictionary, decodeTemplate, Key); ValidateDictionaryTypeAgainstFieldType(previousValue, type); } ScalarValue value_Renamed; int pmapIndex = presenceMapReader.Index; if (IsPresent(presenceMapReader)) { if (context.TraceEnabled) in_Renamed = new RecordingInputStream(in_Renamed); if (!operatorCodec.ShouldDecodeType()) { return operatorCodec.DecodeValue(null, null, this); } ScalarValue decodedValue = typeCodec.Decode(in_Renamed); value_Renamed = DecodeValue(decodedValue, previousValue); if (context.TraceEnabled) context.DecodeTrace.Field(this, value_Renamed, decodedValue, ((RecordingInputStream) in_Renamed).Buffer, pmapIndex); } else { value_Renamed = Decode(previousValue); } ValidateDecodedValueIsCorrectForType(value_Renamed, type); if (!((Operator == Template.Operator.Operator.DELTA) && (value_Renamed == null))) { context.Store(Dictionary, decodeTemplate, Key, value_Renamed); } return value_Renamed; } catch (FastException e) { throw new FastException("Error occurred while decoding " + this, e.Code, e); } }
public override FieldValue Decode(System.IO.Stream in_Renamed, Group decodeTemplate, Context context, BitVectorReader presenceMapReader) { try { ScalarValue previousValue = null; if (operator_Renamed.UsesDictionary()) { previousValue = context.Lookup(Dictionary, decodeTemplate, Key); ValidateDictionaryTypeAgainstFieldType(previousValue, type); } ScalarValue value_Renamed; int pmapIndex = presenceMapReader.Index; if (IsPresent(presenceMapReader)) { if (context.TraceEnabled) { in_Renamed = new RecordingInputStream(in_Renamed); } if (!operatorCodec.ShouldDecodeType()) { return(operatorCodec.DecodeValue(null, null, this)); } ScalarValue decodedValue = typeCodec.Decode(in_Renamed); value_Renamed = DecodeValue(decodedValue, previousValue); if (context.TraceEnabled) { context.DecodeTrace.Field(this, value_Renamed, decodedValue, ((RecordingInputStream)in_Renamed).Buffer, pmapIndex); } } else { value_Renamed = Decode(previousValue); } ValidateDecodedValueIsCorrectForType(value_Renamed, type); if (!((Operator == Template.Operator.Operator.DELTA) && (value_Renamed == null))) { context.Store(Dictionary, decodeTemplate, Key, value_Renamed); } return(value_Renamed); } catch (FastException e) { throw new FastException("Error occurred while decoding " + this, e.Code, e); } }
public override FieldValue Decode(System.IO.Stream in_Renamed, Group decodeTemplate, Context context, BitVectorReader pmapReader) { return(new FastDecoder(context, in_Renamed).ReadMessage()); }
public override IFieldValue Decode(Stream inStream, Group decodeTemplate, Context context, BitVectorReader pmapReader) { return(null); }
public override IFieldValue Decode(Stream inStream, Group decodeTemplate, Context context, BitVectorReader presenceMapReader) { var values = new IFieldValue[_fields.Length]; for (int i = 0; i < _fields.Length; i++) { values[i] = _fields[i].Decode(inStream, decodeTemplate, context, presenceMapReader); if (i == 0 && values[0] == null) return null; } return _valueConverter.Compose(values); }
public override IFieldValue Decode(Stream inStream, Group decodeTemplate, Context context, BitVectorReader pmapReader) { return(new FastDecoder(context, inStream).ReadMessage()); }
public virtual FieldValue[] DecodeFieldValues(System.IO.Stream in_Renamed, Group template, BitVectorReader pmapReader, Context context) { var values = new FieldValue[fields.Length]; var start = this is MessageTemplate?1:0; for (var fieldIndex = start; fieldIndex < fields.Length; fieldIndex++) { var field = GetField(fieldIndex); values[fieldIndex] = field.Decode(in_Renamed, template, context, pmapReader); } if (pmapReader.HasMoreBitsSet()) { Global.HandleError(Error.FastConstants.R8_PMAP_TOO_MANY_BITS, "The presence map " + pmapReader + " has too many bits for the group " + this); } return values; }
public override IFieldValue Decode(Stream inStream, Group decodeTemplate, Context context, BitVectorReader pmapReader) { var sequenceValue = new SequenceValue(this); IFieldValue lengthValue = _length.Decode(inStream, decodeTemplate, context, pmapReader); if ((lengthValue == ScalarValue.Null) || (lengthValue == null)) { return null; } int len = ((IntegerValue) lengthValue).Value; for (int i = 0; i < len; i++) sequenceValue.Add( (GroupValue) _group.Decode(inStream, decodeTemplate, context, BitVectorReader.InfiniteTrue)); return sequenceValue; }
public override FieldValue Decode(System.IO.Stream in_Renamed, Group decodeTemplate, Context context, BitVectorReader pmapReader) { return new FastDecoder(context, in_Renamed).ReadMessage(); }
public override IFieldValue Decode(Stream inStream, Group decodeTemplate, Context context, BitVectorReader pmapReader) { try { if (!UsesPresenceMapBit || pmapReader.Read()) { if (context.TraceEnabled) context.DecodeTrace.GroupStart(this); var groupValue = new GroupValue(this, DecodeFieldValues(inStream, decodeTemplate, context)); if (context.TraceEnabled) context.DecodeTrace.GroupEnd(); return groupValue; } return null; } catch (DynErrorException e) { throw new DynErrorException(e, e.Error, "Error occurred while decoding {0}", this); } }
public override FieldValue Decode(System.IO.Stream in_Renamed, Group decodeTemplate, Context context, BitVectorReader pmapReader) { var sequenceValue = new SequenceValue(this); FieldValue lengthValue = length.Decode(in_Renamed, decodeTemplate, context, pmapReader); if ((lengthValue == ScalarValue.NULL) || (lengthValue == null)) { return null; } int len = ((IntegerValue) lengthValue).value_Renamed; for (var i = 0; i < len; i++) sequenceValue.Add((GroupValue) group.Decode(in_Renamed, decodeTemplate, context, BitVectorReader.INFINITE_TRUE)); return sequenceValue; }
public override FieldValue Decode(System.IO.Stream in_Renamed, Group decodeTemplate, Context context, BitVectorReader pmapReader) { try { if (!UsesPresenceMapBit() || pmapReader.Read()) { if (context.TraceEnabled) { context.DecodeTrace.GroupStart(this); } var groupValue = new GroupValue(this, DecodeFieldValues(in_Renamed, decodeTemplate, context)); if (context.TraceEnabled) { context.DecodeTrace.GroupEnd(); } return(groupValue); } return(null); } catch (FastException e) { throw new FastException("Error occurred while decoding " + this, e.Code, e); } }
public virtual FieldValue[] DecodeFieldValues(System.IO.Stream in_Renamed, Group template, BitVectorReader pmapReader, Context context) { var values = new FieldValue[fields.Length]; var start = this is MessageTemplate?1:0; for (var fieldIndex = start; fieldIndex < fields.Length; fieldIndex++) { var field = GetField(fieldIndex); values[fieldIndex] = field.Decode(in_Renamed, template, context, pmapReader); } if (pmapReader.HasMoreBitsSet()) { Global.HandleError(Error.FastConstants.R8_PMAP_TOO_MANY_BITS, "The presence map " + pmapReader + " has too many bits for the group " + this); } return(values); }
public override IFieldValue Decode(Stream inStream, Group decodeTemplate, Context context, BitVectorReader pmapReader) { return null; }