Changeset 323
- Timestamp:
- Feb 8, 2012, 9:52:27 AM (13 years ago)
- Location:
- Generics/NativeGenerics
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
Generics/NativeGenerics/Demo/Demo.lpi
r322 r323 60 60 <EditorIndex Value="0"/> 61 61 <WindowIndex Value="0"/> 62 <TopLine Value="1 91"/>63 <CursorPos X="1 " Y="205"/>62 <TopLine Value="178"/> 63 <CursorPos X="15" Y="191"/> 64 64 <UsageCount Value="233"/> 65 65 <Bookmarks Count="1"> … … 462 462 <EditorIndex Value="1"/> 463 463 <WindowIndex Value="0"/> 464 <TopLine Value="1 48"/>465 <CursorPos X=" 3" Y="150"/>464 <TopLine Value="102"/> 465 <CursorPos X="20" Y="117"/> 466 466 <UsageCount Value="15"/> 467 467 <Loaded Value="True"/> … … 558 558 </Unit58> 559 559 </Units> 560 <JumpHistory Count="30" HistoryIndex="2 8">560 <JumpHistory Count="30" HistoryIndex="29"> 561 561 <Position1> 562 562 <Filename Value="UMainForm.pas"/> 563 <Caret Line=" 23" Column="22" TopLine="10"/>563 <Caret Line="443" Column="1" TopLine="429"/> 564 564 </Position1> 565 565 <Position2> 566 566 <Filename Value="UMainForm.pas"/> 567 <Caret Line=" 669" Column="21" TopLine="656"/>567 <Caret Line="442" Column="3" TopLine="429"/> 568 568 </Position2> 569 569 <Position3> 570 570 <Filename Value="UMainForm.pas"/> 571 <Caret Line=" 185" Column="19" TopLine="179"/>571 <Caret Line="656" Column="20" TopLine="643"/> 572 572 </Position3> 573 573 <Position4> 574 574 <Filename Value="UMainForm.pas"/> 575 <Caret Line=" 49" Column="14" TopLine="36"/>575 <Caret Line="189" Column="3" TopLine="182"/> 576 576 </Position4> 577 577 <Position5> 578 578 <Filename Value="../Units/GenericStream.pas"/> 579 <Caret Line="4 5" Column="48" TopLine="27"/>579 <Caret Line="43" Column="15" TopLine="30"/> 580 580 </Position5> 581 581 <Position6> 582 582 <Filename Value="UMainForm.pas"/> 583 <Caret Line="19 8" Column="25" TopLine="185"/>583 <Caret Line="191" Column="1" TopLine="182"/> 584 584 </Position6> 585 585 <Position7> 586 586 <Filename Value="UMainForm.pas"/> 587 <Caret Line=" 669" Column="21" TopLine="656"/>587 <Caret Line="192" Column="1" TopLine="182"/> 588 588 </Position7> 589 589 <Position8> 590 590 <Filename Value="UMainForm.pas"/> 591 <Caret Line="1 64" Column="1" TopLine="151"/>591 <Caret Line="193" Column="1" TopLine="182"/> 592 592 </Position8> 593 593 <Position9> 594 594 <Filename Value="UMainForm.pas"/> 595 <Caret Line=" 442" Column="1" TopLine="429"/>595 <Caret Line="194" Column="1" TopLine="182"/> 596 596 </Position9> 597 597 <Position10> 598 598 <Filename Value="UMainForm.pas"/> 599 <Caret Line=" 443" Column="1" TopLine="429"/>599 <Caret Line="195" Column="1" TopLine="182"/> 600 600 </Position10> 601 601 <Position11> 602 602 <Filename Value="UMainForm.pas"/> 603 <Caret Line=" 442" Column="3" TopLine="429"/>603 <Caret Line="196" Column="1" TopLine="182"/> 604 604 </Position11> 605 605 <Position12> 606 606 <Filename Value="UMainForm.pas"/> 607 <Caret Line=" 656" Column="20" TopLine="643"/>607 <Caret Line="197" Column="1" TopLine="182"/> 608 608 </Position12> 609 609 <Position13> 610 610 <Filename Value="UMainForm.pas"/> 611 <Caret Line="1 89" Column="3" TopLine="182"/>611 <Caret Line="198" Column="1" TopLine="182"/> 612 612 </Position13> 613 613 <Position14> 614 <Filename Value=" ../Units/GenericStream.pas"/>615 <Caret Line=" 43" Column="15" TopLine="30"/>614 <Filename Value="UMainForm.pas"/> 615 <Caret Line="199" Column="1" TopLine="182"/> 616 616 </Position14> 617 617 <Position15> 618 618 <Filename Value="UMainForm.pas"/> 619 <Caret Line=" 191" Column="1" TopLine="182"/>619 <Caret Line="200" Column="1" TopLine="182"/> 620 620 </Position15> 621 621 <Position16> 622 622 <Filename Value="UMainForm.pas"/> 623 <Caret Line=" 192" Column="1" TopLine="182"/>623 <Caret Line="201" Column="1" TopLine="182"/> 624 624 </Position16> 625 625 <Position17> 626 626 <Filename Value="UMainForm.pas"/> 627 <Caret Line=" 193" Column="1" TopLine="182"/>627 <Caret Line="202" Column="1" TopLine="191"/> 628 628 </Position17> 629 629 <Position18> 630 630 <Filename Value="UMainForm.pas"/> 631 <Caret Line=" 194" Column="1" TopLine="182"/>631 <Caret Line="203" Column="1" TopLine="191"/> 632 632 </Position18> 633 633 <Position19> 634 634 <Filename Value="UMainForm.pas"/> 635 <Caret Line=" 195" Column="1" TopLine="182"/>635 <Caret Line="204" Column="1" TopLine="191"/> 636 636 </Position19> 637 637 <Position20> 638 638 <Filename Value="UMainForm.pas"/> 639 <Caret Line=" 196" Column="1" TopLine="182"/>639 <Caret Line="205" Column="1" TopLine="191"/> 640 640 </Position20> 641 641 <Position21> 642 <Filename Value=" UMainForm.pas"/>643 <Caret Line="1 97" Column="1" TopLine="182"/>642 <Filename Value="../Units/GenericStream.pas"/> 643 <Caret Line="11" Column="19" TopLine="1"/> 644 644 </Position21> 645 645 <Position22> 646 <Filename Value=" UMainForm.pas"/>647 <Caret Line=" 198" Column="1" TopLine="182"/>646 <Filename Value="../Units/GenericStream.pas"/> 647 <Caret Line="23" Column="32" TopLine="10"/> 648 648 </Position22> 649 649 <Position23> 650 <Filename Value=" UMainForm.pas"/>651 <Caret Line=" 199" Column="1" TopLine="182"/>650 <Filename Value="../Units/GenericStream.pas"/> 651 <Caret Line="38" Column="43" TopLine="25"/> 652 652 </Position23> 653 653 <Position24> 654 <Filename Value=" UMainForm.pas"/>655 <Caret Line=" 200" Column="1" TopLine="182"/>654 <Filename Value="../Units/GenericStream.pas"/> 655 <Caret Line="43" Column="40" TopLine="30"/> 656 656 </Position24> 657 657 <Position25> 658 <Filename Value=" UMainForm.pas"/>659 <Caret Line=" 201" Column="1" TopLine="182"/>658 <Filename Value="../Units/GenericStream.pas"/> 659 <Caret Line="64" Column="52" TopLine="51"/> 660 660 </Position25> 661 661 <Position26> 662 <Filename Value=" UMainForm.pas"/>663 <Caret Line=" 202" Column="1" TopLine="191"/>662 <Filename Value="../Units/GenericStream.pas"/> 663 <Caret Line="105" Column="23" TopLine="90"/> 664 664 </Position26> 665 665 <Position27> 666 <Filename Value=" UMainForm.pas"/>667 <Caret Line=" 203" Column="1" TopLine="191"/>666 <Filename Value="../Units/GenericStream.pas"/> 667 <Caret Line="38" Column="11" TopLine="25"/> 668 668 </Position27> 669 669 <Position28> 670 <Filename Value=" UMainForm.pas"/>671 <Caret Line=" 204" Column="1" TopLine="191"/>670 <Filename Value="../Units/GenericStream.pas"/> 671 <Caret Line="199" Column="15" TopLine="174"/> 672 672 </Position28> 673 673 <Position29> 674 674 <Filename Value="UMainForm.pas"/> 675 <Caret Line=" 205" Column="1" TopLine="191"/>675 <Caret Line="744" Column="81" TopLine="1"/> 676 676 </Position29> 677 677 <Position30> 678 <Filename Value=" ../Units/GenericStream.pas"/>679 <Caret Line="1 50" Column="3" TopLine="148"/>678 <Filename Value="UMainForm.pas"/> 679 <Caret Line="184" Column="13" TopLine="171"/> 680 680 </Position30> 681 681 </JumpHistory> -
Generics/NativeGenerics/Demo/UMainForm.pas
r322 r323 182 182 procedure TMainForm.ButtonStreamByteClick(Sender: TObject); 183 183 var 184 Stream: TG MemoryStream<Byte>;184 Stream: TGStream<Byte>; 185 185 I: Integer; 186 186 ByteArray: array of Byte; … … 189 189 ListViewOutput.Clear; 190 190 LabelTestName.Caption := 'TStreamByte test'; 191 Stream := TG MemoryStream<Byte>.Create;191 Stream := TGStream<Byte>.Create; 192 192 with Stream do try 193 193 WriteOutput('Size := ', IntToStr(Stream.Size)); -
Generics/NativeGenerics/Units/GenericStream.pas
r322 r323 9 9 10 10 type 11 TG Stream<TItem> = class11 TGAbstractStream<TItem> = class 12 12 public 13 13 type … … 21 21 function GetPosition: TIndex; 22 22 public 23 procedure Assign(Source: TG Stream<TItem>); virtual;23 procedure Assign(Source: TGAbstractStream<TItem>); virtual; 24 24 procedure Write(Item: TItem); virtual; abstract; 25 25 procedure WriteArray(Item: array of TItem); virtual; abstract; … … 36 36 end; 37 37 38 TG MemoryStream<TItem> = class(TGStream<TItem>)38 TGStream<TItem> = class(TGAbstractStream<TItem>) 39 39 private 40 40 FList: TGList<TItem>; 41 41 FPosition: TIndex; 42 42 public 43 procedure Assign(Source: TG Stream<TItem>); override;43 procedure Assign(Source: TGAbstractStream<TItem>); override; 44 44 procedure Write(Item: TItem); override; 45 45 procedure WriteArray(Values: array of TItem); override; … … 62 62 { TGStream } 63 63 64 procedure TG Stream<TItem>.Assign(Source: TGStream<TItem>);64 procedure TGAbstractStream<TItem>.Assign(Source: TGAbstractStream<TItem>); 65 65 begin 66 66 end; 67 67 68 procedure TG Stream<TItem>.SetPosition(AValue: TIndex);68 procedure TGAbstractStream<TItem>.SetPosition(AValue: TIndex); 69 69 begin 70 70 Seek(AValue, soBeginning); 71 71 end; 72 72 73 function TG Stream<TItem>.GetPosition: TIndex;73 function TGAbstractStream<TItem>.GetPosition: TIndex; 74 74 begin 75 75 Result := Seek(0, soCurrent); 76 76 end; 77 77 78 procedure TG Stream<TItem>.SetSize(AValue: TIndex);78 procedure TGAbstractStream<TItem>.SetSize(AValue: TIndex); 79 79 var 80 80 StreamSize: TIndex; … … 94 94 end; 95 95 96 function TG Stream<TItem>.GetSize: TIndex;96 function TGAbstractStream<TItem>.GetSize: TIndex; 97 97 var 98 98 OldPosition: Integer; … … 103 103 end; 104 104 105 constructor TG Stream<TItem>.Create;105 constructor TGAbstractStream<TItem>.Create; 106 106 begin 107 107 inherited; 108 108 end; 109 109 110 { T MemoryStreamByte}110 { TGStream } 111 111 112 procedure TG MemoryStream<TItem>.Assign(Source: TGStream<TItem>);112 procedure TGStream<TItem>.Assign(Source: TGAbstractStream<TItem>); 113 113 begin 114 114 inherited; 115 if Source is TG MemoryStream<TItem> then begin116 FList.Assign(TG MemoryStream<TItem>(Source).FList);117 FPosition := TG MemoryStream<TItem>(Source).FPosition;115 if Source is TGStream<TItem> then begin 116 FList.Assign(TGStream<TItem>(Source).FList); 117 FPosition := TGStream<TItem>(Source).FPosition; 118 118 end; 119 119 end; 120 120 121 procedure TG MemoryStream<TItem>.Write(Item: TItem);121 procedure TGStream<TItem>.Write(Item: TItem); 122 122 begin 123 123 if FList.Count < (FPosition + 1) then … … 127 127 end; 128 128 129 procedure TG MemoryStream<TItem>.WriteArray(Values: array of TItem);129 procedure TGStream<TItem>.WriteArray(Values: array of TItem); 130 130 begin 131 131 if FList.Count < (FPosition + Length(Values)) then … … 135 135 end; 136 136 137 procedure TG MemoryStream<TItem>.WriteList(List: TGList<TItem>);137 procedure TGStream<TItem>.WriteList(List: TGList<TItem>); 138 138 begin 139 139 FList.ReplaceList(FPosition, List); 140 140 end; 141 141 142 function TG MemoryStream<TItem>.Read: TItem;142 function TGStream<TItem>.Read: TItem; 143 143 begin 144 144 Result := FList[FPosition]; … … 146 146 end; 147 147 148 function TG MemoryStream<TItem>.ReadArray(Count: TIndex): TItemArray;148 function TGStream<TItem>.ReadArray(Count: TIndex): TItemArray; 149 149 begin 150 150 Result := FList.GetArray(FPosition, Count); 151 151 end; 152 152 153 function TG MemoryStream<TItem>.ReadList(List: TGList<TItem>; Count: TIndex): TIndex;153 function TGStream<TItem>.ReadList(List: TGList<TItem>; Count: TIndex): TIndex; 154 154 begin 155 155 if (FPosition + Count) > FList.Count then … … 159 159 end; 160 160 161 function TG MemoryStream<TItem>.Insert(Count: TIndex): TIndex;161 function TGStream<TItem>.Insert(Count: TIndex): TIndex; 162 162 begin 163 163 FList.InsertCount(FPosition, Count); … … 165 165 end; 166 166 167 function TG MemoryStream<TItem>.Remove(Count: TIndex): TIndex;167 function TGStream<TItem>.Remove(Count: TIndex): TIndex; 168 168 begin 169 169 Result := FList.Count - FPosition; … … 172 172 end; 173 173 174 function TG MemoryStream<TItem>.Seek(Offset: TIndex; Origin: TSeekOrigin): TIndex;174 function TGStream<TItem>.Seek(Offset: TIndex; Origin: TSeekOrigin): TIndex; 175 175 begin 176 176 case Origin of … … 184 184 end; 185 185 186 constructor TG MemoryStream<TItem>.Create;186 constructor TGStream<TItem>.Create; 187 187 begin 188 188 inherited; … … 190 190 end; 191 191 192 destructor TG MemoryStream<TItem>.Destroy;192 destructor TGStream<TItem>.Destroy; 193 193 begin 194 194 FList.Free;
Note:
See TracChangeset
for help on using the changeset viewer.