Changeset 31 for VarIntSerializer
- Timestamp:
- Jun 24, 2010, 4:18:03 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
VarIntSerializer/UVarIntSerializer.pas
r26 r31 11 11 12 12 uses 13 Classes, DateUtils, UMemoryStreamEx, Math, Dialogs, SysUtils ;13 Classes, DateUtils, UMemoryStreamEx, Math, Dialogs, SysUtils, USubStream; 14 14 15 15 const … … 42 42 43 43 // Misc methods 44 function TestMask(Mask , BitIndex: Integer): Boolean;44 function TestMask(Mask: QWord; BitIndex: Byte): Boolean; 45 45 procedure ReadItemByMaskIndex(Index: Integer; Data: TVarIntSerializer); 46 procedure ReadItemRefByMaskIndex(Index: Integer; Data: TSubStream); 46 47 procedure BlockEnclose; 47 48 procedure BlockUnclose; … … 310 311 end; 311 312 312 function TVarIntSerializer.TestMask(Mask , BitIndex: Integer): Boolean;313 function TVarIntSerializer.TestMask(Mask: QWord; BitIndex: Byte): Boolean; 313 314 begin 314 315 Result := ((Mask shr BitIndex) and 1) = 1; … … 322 323 begin 323 324 Position := 0; 325 Data.Size := 0; 324 326 Mask := ReadVarUInt; 325 327 I := 0; … … 330 332 if TestMask(Mask, Index) then 331 333 ReadStream(TStream(Data), GetVarSize); 334 Data.Position := 0; 335 end; 336 337 procedure TVarIntSerializer.ReadItemRefByMaskIndex(Index:Integer;Data:TSubStream 338 ); 339 var 340 Mask: Integer; 341 I: Integer; 342 begin 343 Position := 0; 344 Data.Size := 0; 345 Mask := ReadVarUInt; 346 I := 0; 347 while (Position < Size) and (I < Index) do begin 348 if TestMask(Mask, I) then Position := Position + GetVarSize; 349 Inc(I); 350 end; 351 if TestMask(Mask, Index) then begin 352 if TStream(Self) is TSubStream then begin 353 // Recalculate substream 354 Data.Source := TSubStream(Self).Source; 355 Data.SourcePosition := TSubStream(Self).SourcePosition + Position; 356 end else begin 357 Data.Source := Self; 358 Data.SourcePosition := Position; 359 end; 360 Data.Size := GetVarSize; 361 end; 362 Data.Position := 0; 332 363 end; 333 364
Note:
See TracChangeset
for help on using the changeset viewer.