Changeset 307
- Timestamp:
- Jan 3, 2012, 10:36:55 AM (13 years ago)
- Location:
- CoolStreaming
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
CoolStreaming/UStreamHelper.pas
r291 r307 23 23 procedure SetItem(Index: Integer; const AValue: Byte); 24 24 public 25 procedure Assign(Source: TStreamHelper); 25 26 procedure WriteByte(Data: Byte); 26 27 procedure WriteWord(Data: Word); … … 281 282 end; 282 283 284 procedure TStreamHelper.Assign(Source: TStreamHelper); 285 var 286 OldPosition: Integer; 287 begin 288 OldPosition := Source.Position; 289 Clear; 290 WriteStream(Source, Source.Size); 291 Source.Position := OldPosition; 292 Position := OldPosition; 293 end; 294 283 295 procedure TStreamHelper.WriteAnsiString(Data: string); 284 296 var -
CoolStreaming/UVarBlockSerializer.pas
r303 r307 56 56 procedure BlockEnclose; 57 57 procedure BlockUnclose; 58 procedure Assign(Source: TVarBlockSerializer); 58 59 constructor Create; 59 60 destructor Destroy; override; 60 procedure Assign(Source: TVarBlockSerializer);61 61 property Stream: TStream read FStream write SetStream; 62 62 end; … … 70 70 Enclose: Boolean; 71 71 procedure CheckItem(Index: Integer); 72 procedure Assign(Source: TVarBlockIndexed); 72 73 73 74 // Base … … 101 102 constructor Create; 102 103 destructor Destroy; override; 103 procedure Assign(Source: TVarBlockIndexed);104 104 end; 105 105 … … 568 568 end; 569 569 570 procedure TVarBlockSerializer.Assign(Source: TVarBlockSerializer); 571 var 572 OldPos: Integer; 573 begin 574 OwnsStream := Source.OwnsStream; 575 FStream.Size := 0; 576 OldPos := Source.FStream.Position; 577 FStream.CopyFrom(Source.FStream, Source.FStream.Size); 578 Source.FStream.Position := OldPos; 579 FStream.Position := OldPos; 580 end; 581 570 582 constructor TVarBlockSerializer.Create; 571 583 begin … … 582 594 end; 583 595 inherited Destroy; 584 end;585 586 procedure TVarBlockSerializer.Assign(Source: TVarBlockSerializer);587 var588 Helper: TStreamHelper;589 LastPos: Integer;590 begin591 OwnsStream := Source.OwnsStream;592 FStream.Size := 0;593 try594 Helper := TStreamHelper.Create(Source.FStream);595 LastPos := Source.FStream.Position;596 Source.FStream.Position := 0;597 Helper.ReadStream(FStream, Source.FStream.Size);598 Source.FStream.Position := LastPos;599 finally600 Helper.Free;601 end;602 FStream.Position := Source.FStream.Position;603 596 end; 604 597 … … 617 610 end; 618 611 612 procedure TVarBlockIndexed.Assign(Source: TVarBlockIndexed); 613 var 614 I: Integer; 615 begin 616 Enclose := Source.Enclose; 617 Items.Count := 0; 618 Items.Count := Source.Items.Count; 619 for I := 0 to Items.Count - 1 do begin 620 Items[I] := TVarBlockSerializer.Create; 621 TVarBlockSerializer(Items[I]).Assign(TVarBlockSerializer(Source.Items[I])); 622 end; 623 end; 624 619 625 procedure TVarBlockIndexed.WriteVarUInt(Index:Integer;Value:QWord); 620 626 begin … … 798 804 if (Index >= 0) and (Index < Items.Count) then 799 805 Result := Assigned(Items[Index]) 800 else Result := False ;806 else Result := False 801 807 end; 802 808 … … 885 891 end; 886 892 887 procedure TVarBlockIndexed.Assign(Source: TVarBlockIndexed);888 var889 I: Integer;890 begin891 Enclose := Source.Enclose;892 Items.Count := Source.Items.Count;893 for I := 0 to Items.Count - 1 do begin894 CheckItem(I);895 TVarBlockSerializer(Items[I]).Assign(TVarBlockSerializer(Source.Items[I]));896 end;897 end;898 899 893 end.
Note:
See TracChangeset
for help on using the changeset viewer.