{$MODE OBJFPC}
{$MODESWITCH result}
{$MODESWITCH autoderef}
unit dstreamresource;

interface

uses
  dresource,
  dstream,
  dstreammem;

type
PStreamResource = ^TStreamResource;
TStreamResource = object(TStreamMem)
public
  constructor Init(Resource: PDojResource);
  function Create(Resource: PDojResource): PStreamResource; static;
end;

operator := (const Resource: TDojResource): TData;

implementation

constructor TStreamResource.Init(Resource: PDojResource);
begin
  inherited Init(Resource^.Data, Resource^.Size, False);
  FWritable := False;
end;

function TStreamResource.Create(Resource: PDojResource): PStreamResource;
begin
  Result := New(PStreamResource, Init(Resource));
end;

operator := (const Resource: TDojResource): TData;
begin
  Result := AsData(TStreamResource.Create(@Resource));
end;

end.
