Changeset 405 for CoolStreaming


Ignore:
Timestamp:
Aug 14, 2012, 7:04:04 AM (12 years ago)
Author:
chronos
Message:
  • Modified: TemplateGenerics TBinarySerializer now use TListByte class instead TStreamByte.
Location:
CoolStreaming
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • CoolStreaming/CoolStreaming.lpk

    r379 r405  
    5050    </Files>
    5151    <Type Value="RunAndDesignTime"/>
    52     <RequiredPkgs Count="3">
     52    <RequiredPkgs Count="2">
    5353      <Item1>
    5454        <PackageName Value="Common"/>
    5555      </Item1>
    5656      <Item2>
    57         <PackageName Value="TemplateGenerics"/>
    58       </Item2>
    59       <Item3>
    6057        <PackageName Value="FCL"/>
    6158        <MinVersion Major="1" Valid="True"/>
    62       </Item3>
     59      </Item2>
    6360    </RequiredPkgs>
    6461    <UsageOptions>
  • CoolStreaming/UVarBlockSerializer.pas

    r384 r405  
    3838    procedure WriteVarStream(AStream: TStream);
    3939    procedure ReadVarStream(AStream: TStream);
     40    procedure WriteVarList(List: TListByte);
     41    procedure ReadVarList(List: TListByte);
    4042    function GetVarSize: Integer;
    4143    function GetVarCount: Integer;
     
    8082    procedure WriteVarStream(Index: Integer; Stream: TStream);
    8183    procedure ReadVarStream(Index: Integer; Stream: TStream);
     84    procedure WriteVarList(Index: Integer; List: TListByte);
     85    procedure ReadVarList(Index: Integer; List: TListByte);
    8286    procedure WriteVarIndexedBlock(Index: Integer; Block: TVarBlockIndexed);
    8387    procedure ReadVarIndexedBlock(Index: Integer; Block: TVarBlockIndexed);
     
    101105    procedure WriteToStream(Stream: TStream);
    102106    procedure ReadFromStream(Stream: TStream);
     107    procedure WriteToList(List: TListByte);
     108    procedure ReadFromList(List: TListByte);
    103109    constructor Create;
    104110    destructor Destroy; override;
     
    413419end;
    414420
     421procedure TVarBlockSerializer.WriteVarList(List: TListByte);
     422var
     423  Mem: TMemoryStream;
     424begin
     425  try
     426    Mem := TMemoryStream.Create;
     427    List.WriteToStream(Mem);
     428    WriteVarStream(Mem);
     429  finally
     430    Mem.Free
     431  end;
     432end;
     433
     434procedure TVarBlockSerializer.ReadVarList(List: TListByte);
     435var
     436  Mem: TMemoryStream;
     437begin
     438  try
     439    Mem := TMemoryStream.Create;
     440    ReadVarStream(Mem);
     441    List.Count := Mem.Size;
     442    List.ReplaceStream(Mem);
     443  finally
     444    Mem.Free
     445  end;
     446end;
     447
    415448function TVarBlockSerializer.GetVarSize: Integer;
    416449var
     
    697730end;
    698731
     732procedure TVarBlockIndexed.WriteVarList(Index: Integer; List: TListByte);
     733begin
     734  CheckItem(Index);
     735  TVarBlockSerializer(Items[Index]).WriteVarList(List);
     736end;
     737
     738procedure TVarBlockIndexed.ReadVarList(Index: Integer; List: TListByte);
     739begin
     740  TVarBlockSerializer(Items[Index]).ReadVarList(List);
     741end;
     742
    699743procedure TVarBlockIndexed.WriteVarIndexedBlock(Index: Integer;
    700744  Block: TVarBlockIndexed);
     
    915959end;
    916960
     961procedure TVarBlockIndexed.WriteToList(List: TListByte);
     962var
     963  Mem: TMemoryStream;
     964begin
     965  try
     966    Mem := TMemoryStream.Create;
     967    WriteToStream(Mem);
     968    List.Count := Mem.Size;
     969    List.ReplaceStream(Mem);
     970  finally
     971    Mem.Free;
     972  end;
     973end;
     974
     975procedure TVarBlockIndexed.ReadFromList(List: TListByte);
     976var
     977  Mem: TMemoryStream;
     978begin
     979  try
     980    Mem := TMemoryStream.Create;
     981    List.WriteToStream(Mem);
     982    ReadFromStream(Mem);
     983  finally
     984    Mem.Free;
     985  end;
     986end;
     987
    917988constructor TVarBlockIndexed.Create;
    918989begin
Note: See TracChangeset for help on using the changeset viewer.