Ignore:
Timestamp:
Feb 8, 2012, 9:52:27 AM (13 years ago)
Author:
chronos
Message:
  • Modified: TGStream renamed to TGAbstractStream. TGMemoryStream renamed to TGStream as memory implementation will be most used class.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Generics/NativeGenerics/Units/GenericStream.pas

    r322 r323  
    99
    1010type
    11   TGStream<TItem> = class
     11  TGAbstractStream<TItem> = class
    1212  public
    1313    type
     
    2121    function GetPosition: TIndex;
    2222  public
    23     procedure Assign(Source: TGStream<TItem>); virtual;
     23    procedure Assign(Source: TGAbstractStream<TItem>); virtual;
    2424    procedure Write(Item: TItem); virtual; abstract;
    2525    procedure WriteArray(Item: array of TItem); virtual; abstract;
     
    3636  end;
    3737
    38   TGMemoryStream<TItem> = class(TGStream<TItem>)
     38  TGStream<TItem> = class(TGAbstractStream<TItem>)
    3939  private
    4040    FList: TGList<TItem>;
    4141    FPosition: TIndex;
    4242  public
    43     procedure Assign(Source: TGStream<TItem>); override;
     43    procedure Assign(Source: TGAbstractStream<TItem>); override;
    4444    procedure Write(Item: TItem); override;
    4545    procedure WriteArray(Values: array of TItem); override;
     
    6262{ TGStream }
    6363
    64 procedure TGStream<TItem>.Assign(Source: TGStream<TItem>);
     64procedure TGAbstractStream<TItem>.Assign(Source: TGAbstractStream<TItem>);
    6565begin
    6666end;
    6767
    68 procedure TGStream<TItem>.SetPosition(AValue: TIndex);
     68procedure TGAbstractStream<TItem>.SetPosition(AValue: TIndex);
    6969begin
    7070  Seek(AValue, soBeginning);
    7171end;
    7272
    73 function TGStream<TItem>.GetPosition: TIndex;
     73function TGAbstractStream<TItem>.GetPosition: TIndex;
    7474begin
    7575  Result := Seek(0, soCurrent);
    7676end;
    7777
    78 procedure TGStream<TItem>.SetSize(AValue: TIndex);
     78procedure TGAbstractStream<TItem>.SetSize(AValue: TIndex);
    7979var
    8080  StreamSize: TIndex;
     
    9494end;
    9595
    96 function TGStream<TItem>.GetSize: TIndex;
     96function TGAbstractStream<TItem>.GetSize: TIndex;
    9797var
    9898  OldPosition: Integer;
     
    103103end;
    104104
    105 constructor TGStream<TItem>.Create;
     105constructor TGAbstractStream<TItem>.Create;
    106106begin
    107107  inherited;
    108108end;
    109109
    110 { TMemoryStreamByte }
     110{ TGStream }
    111111
    112 procedure TGMemoryStream<TItem>.Assign(Source: TGStream<TItem>);
     112procedure TGStream<TItem>.Assign(Source: TGAbstractStream<TItem>);
    113113begin
    114114  inherited;
    115   if Source is TGMemoryStream<TItem> then begin
    116     FList.Assign(TGMemoryStream<TItem>(Source).FList);
    117     FPosition := TGMemoryStream<TItem>(Source).FPosition;
     115  if Source is TGStream<TItem> then begin
     116    FList.Assign(TGStream<TItem>(Source).FList);
     117    FPosition := TGStream<TItem>(Source).FPosition;
    118118  end;
    119119end;
    120120
    121 procedure TGMemoryStream<TItem>.Write(Item: TItem);
     121procedure TGStream<TItem>.Write(Item: TItem);
    122122begin
    123123  if FList.Count < (FPosition + 1) then
     
    127127end;
    128128
    129 procedure TGMemoryStream<TItem>.WriteArray(Values: array of TItem);
     129procedure TGStream<TItem>.WriteArray(Values: array of TItem);
    130130begin
    131131  if FList.Count < (FPosition + Length(Values)) then
     
    135135end;
    136136
    137 procedure TGMemoryStream<TItem>.WriteList(List: TGList<TItem>);
     137procedure TGStream<TItem>.WriteList(List: TGList<TItem>);
    138138begin
    139139  FList.ReplaceList(FPosition, List);
    140140end;
    141141
    142 function TGMemoryStream<TItem>.Read: TItem;
     142function TGStream<TItem>.Read: TItem;
    143143begin
    144144  Result := FList[FPosition];
     
    146146end;
    147147
    148 function TGMemoryStream<TItem>.ReadArray(Count: TIndex): TItemArray;
     148function TGStream<TItem>.ReadArray(Count: TIndex): TItemArray;
    149149begin
    150150  Result := FList.GetArray(FPosition, Count);
    151151end;
    152152
    153 function TGMemoryStream<TItem>.ReadList(List: TGList<TItem>; Count: TIndex): TIndex;
     153function TGStream<TItem>.ReadList(List: TGList<TItem>; Count: TIndex): TIndex;
    154154begin
    155155  if (FPosition + Count) > FList.Count then
     
    159159end;
    160160
    161 function TGMemoryStream<TItem>.Insert(Count: TIndex): TIndex;
     161function TGStream<TItem>.Insert(Count: TIndex): TIndex;
    162162begin
    163163  FList.InsertCount(FPosition, Count);
     
    165165end;
    166166
    167 function TGMemoryStream<TItem>.Remove(Count: TIndex): TIndex;
     167function TGStream<TItem>.Remove(Count: TIndex): TIndex;
    168168begin
    169169  Result := FList.Count - FPosition;
     
    172172end;
    173173
    174 function TGMemoryStream<TItem>.Seek(Offset: TIndex; Origin: TSeekOrigin): TIndex;
     174function TGStream<TItem>.Seek(Offset: TIndex; Origin: TSeekOrigin): TIndex;
    175175begin
    176176  case Origin of
     
    184184end;
    185185
    186 constructor TGMemoryStream<TItem>.Create;
     186constructor TGStream<TItem>.Create;
    187187begin
    188188  inherited;
     
    190190end;
    191191
    192 destructor TGMemoryStream<TItem>.Destroy;
     192destructor TGStream<TItem>.Destroy;
    193193begin
    194194  FList.Free;
Note: See TracChangeset for help on using the changeset viewer.