Ignore:
Timestamp:
Dec 19, 2011, 9:19:00 AM (13 years ago)
Author:
chronos
Message:
  • Added: Handling of TStream by TListByte.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Generics/TemplateGenerics/Specialized/SpecializedList.pas

    r232 r304  
    9090TListByte = class(TListByteBase)
    9191  procedure WriteToStream(Stream: TStream);
     92  procedure WriteToStreamPart(Stream: TStream; ItemIndex, ItemCount: TGListIndex);
     93  procedure ReplaceStream(Stream: TStream);
     94  procedure ReplaceStreamPart(Stream: TStream; ItemIndex, ItemCount: TGListIndex);
     95  procedure AddStream(Stream: TStream);
     96  procedure AddStreamPart(Stream: TStream; ItemCount: TGListIndex);
    9297end;
    9398
     
    338343end;
    339344
     345{ TListByte }
     346
    340347procedure TListByte.WriteToStream(Stream: TStream);
    341348var
    342349  I: Integer;
    343350begin
     351  Stream.Position := 0;
    344352  I := 0;
    345   while I < Count do
     353  while I < Count do begin
    346354    Stream.WriteByte(Items[I]);
    347 end;
    348 
     355    I := I + 1;
     356  end;
     357end;
     358
     359procedure TListByte.WriteToStreamPart(Stream: TStream; ItemIndex, ItemCount: Integer);
     360var
     361  I: Integer;
     362begin
     363  I := ItemIndex;
     364  while I < ItemCount do begin
     365    Stream.WriteByte(Items[I]);
     366    I := I + 1;
     367  end;
     368end;
     369
     370procedure TListByte.ReplaceStream(Stream: TStream);
     371var
     372  I: Integer;
     373begin
     374  Stream.Position := 0;
     375  I := 0;
     376  while I < Count do begin
     377    Items[I] := Stream.ReadByte;
     378    I := I + 1;
     379  end;
     380end;
     381
     382procedure TListByte.ReplaceStreamPart(Stream: TStream; ItemIndex,
     383  ItemCount: Integer);
     384var
     385  I: Integer;
     386begin
     387  I := ItemIndex;
     388  while I < ItemCount do begin
     389    Items[I] := Stream.ReadByte;
     390    I := I + 1;
     391  end;
     392end;
     393
     394procedure TListByte.AddStream(Stream: TStream);
     395var
     396  I: Integer;
     397begin
     398  Stream.Position := 0;
     399  I := Count;
     400  Count := Count + Stream.Size;
     401  while I < Count do begin
     402    Items[I] := Stream.ReadByte;
     403    I := I + 1;
     404  end;
     405end;
     406
     407procedure TListByte.AddStreamPart(Stream: TStream; ItemCount: Integer);
     408var
     409  I: Integer;
     410begin
     411  I := Count;
     412  Count := Count + ItemCount;
     413  while I < Count do begin
     414    Items[I] := Stream.ReadByte;
     415    I := I + 1;
     416  end;
     417end;
    349418
    350419end.
Note: See TracChangeset for help on using the changeset viewer.