Sign in Join
FPDoc Onlineexperiment

TResourceDataStream class

In unit resdatastream

Stream class that provides copy-on-write functionality

Declaration

pascal
TResourceDataStream = class(TStream)

Inheritance

  1. TResourceDataStream
  2. TStream
  3. TObject

Description

This class provides the copy-on-write mechanism of TAbstractResource.RawData, via more levels of indirection.

It uses an underlying stream, to which it redirects operations.

The underlying stream can be a TCachedDataStream descendant, a memory stream or a custom stream. Usually when a resource is loaded from a stream, the underlying stream is a TCachedDataStream descendant, which provides a read-only stream-like interface over a portion of the original stream (that is, the part of the original stream where resource data resides). When TResourceDataStream is requested to write data, it replaces the underlying stream with a memory stream, whose contents are copied from the previous underlying stream: this way, copy-on-write functionality can be achieved.

As said before, third possibility is to have a custom stream as the underlying stream: a user can set this stream via TAbstractResource.SetCustomRawDataStream method, which in turn calls SetCustomStream

Figure: Levels of indirection

.
                     TResourceDataStream
                              |
       _______________________|_______________________________
      |                       |                               |
TMemoryStream     TCachedDataStream descendant          custom stream
                         /           \
 _______________________|_____________|______________________________
|                o r i g|i n a l   s t|r e a m                       |
|_______________________|_____________|______________________________|

See also

Properties

CachedpublicControls the copy-on-write behaviour of the stream

Methods

GetPositionprotected
SetPositionprotected
GetSizeprotectedReturn the size of the stream.
SetSize64protected
CreatepublicCreates a new object
DestroypublicTObject destructor.
ComparepublicCompares the stream to another one
SetCustomStreampublicSets a custom stream as the underlying stream
ReadpublicRead data from stream to buffer.
WritepublicWrite a number of bytes to the stream.
SeekpublicSet stream position.

Inherited

From TObject (40)

AfterConstruction BeforeDestruction CheckDisposed ClassInfo ClassName ClassNameIs ClassParent ClassType CleanupInstance DefaultHandler DefaultHandlerStr Dispatch DispatchStr Disposed DisposeOf Equals FieldAddress Free FreeInstance GetDisposed GetHashCode GetInterface GetInterfaceByStr GetInterfaceEntry GetInterfaceEntryByStr GetInterfaceTable GetInterfaceWeak GetLastCastErrorInfo InheritsFrom InitInstance InstanceSize MethodAddress MethodName newinstance QualifiedClassName SafeCallException StringMessageTable SystemHasExtendedRTTI ToString UnitName

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.