Summary
TBinaryDeserializer is a specialized TDeserializer class type for reading data from standard VCL TStream object, previously serialized into it by NG.Serialization.Binary.TBinarySerializer object.
Syntax
TBinaryDeserializer = class(TDeserializer)
Properties
Methods
Name | Description | |
DoBeginArray | ||
DoBeginObject | ||
DoEndArray | ||
DoEndObject | ||
DoIsNull | ||
DoNext | ||
DoRead | ||
DoSkip | ||
FlushBuffer | FlushBuffer method synchronizes used stream position with really read bytes count. |
Remarks
TBinaryDeserializer object should be created providing a reference to existing TStream object from which it will read serialized data. The content of provided stream object should be previously written by NG.Serialization.Binary.TBinarySerializer object.
For improving performance, TBinaryDeserializer use its own internal buffer; thus real reading from TStream is performed in advance by big chunks. Buffer flush, which is essentially a synchronization of stream object position with really read bytes count, is performed automatically, when the de-serializer object is destroyed, but if TStream.Position is needed to be valid before de-serializer destruction, its required to call NG.Serialization.Binary.TBinaryDeserializer.FlushBuffer method to synchronize stream position.
If the resulting stream contains more data, and TBinarySerializer.WriteEndMark method has been called while writing serializing data, then de-serializer will be able to stop correctly on this end-mark, allowing subsequent correct reading of this additional data.
Examples
Delphi | Copy Code |
---|---|
stream := TFileStream.Create(...); bindsr := TBinaryDeserializer.Create(stream); try obj := bindsr.Value<TMyObject>; finally bindsr.Free; stream.Free; end; |