Changeset 262


Ignore:
Timestamp:
Aug 15, 2011, 11:57:32 AM (13 years ago)
Author:
george
Message:
  • Added: GetVarCount method to get count of varblock in stream.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • CoolStreaming/UVarBlockSerializer.pas

    r247 r262  
    3939    procedure ReadVarStream(AStream: TStream);
    4040    function GetVarSize: Integer;
     41    function GetVarCount: Integer;
    4142
    4243    // Advanced data types
     
    423424end;
    424425
     426function TVarBlockSerializer.GetVarCount: Integer;
     427var
     428  Data: Byte;
     429  StoredPosition: Integer;
     430  Skip: Integer;
     431begin
     432  StoredPosition := Stream.Position;
     433  Result := 0;
     434  while Stream.Position < Stream.Size do begin
     435    Data := Stream.ReadByte;
     436    if Data = $ff then Skip := ReadVarUInt
     437      else Skip := DecodeUnaryLength(Data) - 1;
     438    Stream.Seek(Skip, soCurrent);
     439    Inc(Result);
     440  end;
     441  Stream.Position := StoredPosition;
     442end;
     443
    425444procedure TVarBlockSerializer.WriteVarSInt(Value: Int64);
    426445begin
Note: See TracChangeset for help on using the changeset viewer.