Ignore:
Timestamp:
Sep 7, 2012, 6:45:53 AM (12 years ago)
Author:
chronos
Message:
  • Upraveno: Aktualizace balíčku TemplateGenerics na novější verzi. Se starou nešel projekt správně přeložit.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/TemplateGenerics/Generic/GenericStream.inc

    r84 r90  
    11{$IFDEF INTERFACE}
    22
    3 TGStreamDataEvent = procedure (Item: TGStreamItem) of object;
     3TGStreamItemArray = array of TGStreamItem;
    44
    5 // TGStream<TStreamItem> = class
     5// TGStream<TGStreamIndex, TGStreamItem> = class
    66TGStream = class
    7   FOnData: TGStreamDataEvent;
    8   procedure Write(Item: TStreamItem);
    9   property OnData: TGStreamDataEvent read FOnData write FOnData;
     7  procedure SetSize(AValue: TGStreamIndex);
     8  function GetSize: TGStreamIndex;
     9  procedure SetPosition(AValue: TGStreamIndex);
     10  function GetPosition: TGStreamIndex;
     11public
     12  procedure Assign(Source: TGStream); virtual;
     13  procedure Write(Item: TGStreamItem); virtual; abstract;
     14  procedure WriteArray(Item: array of TGStreamItem); virtual; abstract;
     15  procedure WriteStream(Stream: TGStream; Count: TGStreamIndex); virtual; abstract;
     16  function Read: TGStreamItem; virtual; abstract;
     17  function ReadArray(Count: TGStreamIndex): TGStreamItemArray; virtual; abstract;
     18  function ReadStream(Stream: TGStream; Count: TGStreamIndex): TGStreamIndex; virtual; abstract;
     19  function Insert(Count: TGStreamIndex): TGStreamIndex; virtual; abstract;
     20  function Remove(Count: TGStreamIndex): TGStreamIndex; virtual; abstract;
     21  function Seek(Offset: TGStreamIndex; Origin: TSeekOrigin = soCurrent):
     22    TGStreamIndex; virtual; abstract;
     23  constructor Create; virtual;
     24  property Position: TGStreamIndex read GetPosition write SetPosition;
     25  property Size: TGStreamIndex read GetSize write SetSize;
    1026end;
    1127
     
    1531{$IFDEF IMPLEMENTATION}
    1632
    17 procedure TGStream.Write(Item: TGStreamItem);
     33procedure TGStream.Assign(Source: TGStream);
    1834begin
    19   if Assigned(FOnData) then
    20     FOnData(Item);
    2135end;
    2236
     37procedure TGStream.SetPosition(AValue: TGStreamIndex);
     38begin
     39  Seek(AValue, soBegin);
     40end;
     41
     42function TGStream.GetPosition: TGStreamIndex;
     43begin
     44  Result := Seek(0, soCurrent);
     45end;
     46
     47procedure TGStream.SetSize(AValue: TGStreamIndex);
     48var
     49  StreamSize: TGStreamIndex;
     50  OldPosition: TGStreamIndex;
     51begin
     52  OldPosition := Seek(0, soCurrent);
     53  StreamSize := Size;
     54  if AValue > StreamSize then begin
     55    Seek(StreamSize, soBegin);
     56    Insert(AValue - StreamSize);
     57  end else
     58  if AValue < StreamSize then begin
     59    Seek(AValue, soBegin);
     60    Remove(StreamSize - AValue);
     61  end;
     62  Position := OldPosition;
     63end;
     64
     65function TGStream.GetSize: TGStreamIndex;
     66var
     67  OldPosition: Integer;
     68begin
     69  OldPosition := Position;
     70  Result := Seek(0, soEnd);
     71  Position := OldPosition;
     72end;
     73
     74constructor TGStream.Create;
     75begin
     76  inherited;
     77end;
    2378
    2479{$UNDEF IMPLEMENTATION}
Note: See TracChangeset for help on using the changeset viewer.