Changeset 323


Ignore:
Timestamp:
Feb 8, 2012, 9:52:27 AM (13 years ago)
Author:
chronos
Message:
  • Modified: TGStream renamed to TGAbstractStream. TGMemoryStream renamed to TGStream as memory implementation will be most used class.
Location:
Generics/NativeGenerics
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • Generics/NativeGenerics/Demo/Demo.lpi

    r322 r323  
    6060        <EditorIndex Value="0"/>
    6161        <WindowIndex Value="0"/>
    62         <TopLine Value="191"/>
    63         <CursorPos X="1" Y="205"/>
     62        <TopLine Value="178"/>
     63        <CursorPos X="15" Y="191"/>
    6464        <UsageCount Value="233"/>
    6565        <Bookmarks Count="1">
     
    462462        <EditorIndex Value="1"/>
    463463        <WindowIndex Value="0"/>
    464         <TopLine Value="148"/>
    465         <CursorPos X="3" Y="150"/>
     464        <TopLine Value="102"/>
     465        <CursorPos X="20" Y="117"/>
    466466        <UsageCount Value="15"/>
    467467        <Loaded Value="True"/>
     
    558558      </Unit58>
    559559    </Units>
    560     <JumpHistory Count="30" HistoryIndex="28">
     560    <JumpHistory Count="30" HistoryIndex="29">
    561561      <Position1>
    562562        <Filename Value="UMainForm.pas"/>
    563         <Caret Line="23" Column="22" TopLine="10"/>
     563        <Caret Line="443" Column="1" TopLine="429"/>
    564564      </Position1>
    565565      <Position2>
    566566        <Filename Value="UMainForm.pas"/>
    567         <Caret Line="669" Column="21" TopLine="656"/>
     567        <Caret Line="442" Column="3" TopLine="429"/>
    568568      </Position2>
    569569      <Position3>
    570570        <Filename Value="UMainForm.pas"/>
    571         <Caret Line="185" Column="19" TopLine="179"/>
     571        <Caret Line="656" Column="20" TopLine="643"/>
    572572      </Position3>
    573573      <Position4>
    574574        <Filename Value="UMainForm.pas"/>
    575         <Caret Line="49" Column="14" TopLine="36"/>
     575        <Caret Line="189" Column="3" TopLine="182"/>
    576576      </Position4>
    577577      <Position5>
    578578        <Filename Value="../Units/GenericStream.pas"/>
    579         <Caret Line="45" Column="48" TopLine="27"/>
     579        <Caret Line="43" Column="15" TopLine="30"/>
    580580      </Position5>
    581581      <Position6>
    582582        <Filename Value="UMainForm.pas"/>
    583         <Caret Line="198" Column="25" TopLine="185"/>
     583        <Caret Line="191" Column="1" TopLine="182"/>
    584584      </Position6>
    585585      <Position7>
    586586        <Filename Value="UMainForm.pas"/>
    587         <Caret Line="669" Column="21" TopLine="656"/>
     587        <Caret Line="192" Column="1" TopLine="182"/>
    588588      </Position7>
    589589      <Position8>
    590590        <Filename Value="UMainForm.pas"/>
    591         <Caret Line="164" Column="1" TopLine="151"/>
     591        <Caret Line="193" Column="1" TopLine="182"/>
    592592      </Position8>
    593593      <Position9>
    594594        <Filename Value="UMainForm.pas"/>
    595         <Caret Line="442" Column="1" TopLine="429"/>
     595        <Caret Line="194" Column="1" TopLine="182"/>
    596596      </Position9>
    597597      <Position10>
    598598        <Filename Value="UMainForm.pas"/>
    599         <Caret Line="443" Column="1" TopLine="429"/>
     599        <Caret Line="195" Column="1" TopLine="182"/>
    600600      </Position10>
    601601      <Position11>
    602602        <Filename Value="UMainForm.pas"/>
    603         <Caret Line="442" Column="3" TopLine="429"/>
     603        <Caret Line="196" Column="1" TopLine="182"/>
    604604      </Position11>
    605605      <Position12>
    606606        <Filename Value="UMainForm.pas"/>
    607         <Caret Line="656" Column="20" TopLine="643"/>
     607        <Caret Line="197" Column="1" TopLine="182"/>
    608608      </Position12>
    609609      <Position13>
    610610        <Filename Value="UMainForm.pas"/>
    611         <Caret Line="189" Column="3" TopLine="182"/>
     611        <Caret Line="198" Column="1" TopLine="182"/>
    612612      </Position13>
    613613      <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"/>
    616616      </Position14>
    617617      <Position15>
    618618        <Filename Value="UMainForm.pas"/>
    619         <Caret Line="191" Column="1" TopLine="182"/>
     619        <Caret Line="200" Column="1" TopLine="182"/>
    620620      </Position15>
    621621      <Position16>
    622622        <Filename Value="UMainForm.pas"/>
    623         <Caret Line="192" Column="1" TopLine="182"/>
     623        <Caret Line="201" Column="1" TopLine="182"/>
    624624      </Position16>
    625625      <Position17>
    626626        <Filename Value="UMainForm.pas"/>
    627         <Caret Line="193" Column="1" TopLine="182"/>
     627        <Caret Line="202" Column="1" TopLine="191"/>
    628628      </Position17>
    629629      <Position18>
    630630        <Filename Value="UMainForm.pas"/>
    631         <Caret Line="194" Column="1" TopLine="182"/>
     631        <Caret Line="203" Column="1" TopLine="191"/>
    632632      </Position18>
    633633      <Position19>
    634634        <Filename Value="UMainForm.pas"/>
    635         <Caret Line="195" Column="1" TopLine="182"/>
     635        <Caret Line="204" Column="1" TopLine="191"/>
    636636      </Position19>
    637637      <Position20>
    638638        <Filename Value="UMainForm.pas"/>
    639         <Caret Line="196" Column="1" TopLine="182"/>
     639        <Caret Line="205" Column="1" TopLine="191"/>
    640640      </Position20>
    641641      <Position21>
    642         <Filename Value="UMainForm.pas"/>
    643         <Caret Line="197" Column="1" TopLine="182"/>
     642        <Filename Value="../Units/GenericStream.pas"/>
     643        <Caret Line="11" Column="19" TopLine="1"/>
    644644      </Position21>
    645645      <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"/>
    648648      </Position22>
    649649      <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"/>
    652652      </Position23>
    653653      <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"/>
    656656      </Position24>
    657657      <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"/>
    660660      </Position25>
    661661      <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"/>
    664664      </Position26>
    665665      <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"/>
    668668      </Position27>
    669669      <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"/>
    672672      </Position28>
    673673      <Position29>
    674674        <Filename Value="UMainForm.pas"/>
    675         <Caret Line="205" Column="1" TopLine="191"/>
     675        <Caret Line="744" Column="81" TopLine="1"/>
    676676      </Position29>
    677677      <Position30>
    678         <Filename Value="../Units/GenericStream.pas"/>
    679         <Caret Line="150" Column="3" TopLine="148"/>
     678        <Filename Value="UMainForm.pas"/>
     679        <Caret Line="184" Column="13" TopLine="171"/>
    680680      </Position30>
    681681    </JumpHistory>
  • Generics/NativeGenerics/Demo/UMainForm.pas

    r322 r323  
    182182procedure TMainForm.ButtonStreamByteClick(Sender: TObject);
    183183var
    184   Stream: TGMemoryStream<Byte>;
     184  Stream: TGStream<Byte>;
    185185  I: Integer;
    186186  ByteArray: array of Byte;
     
    189189  ListViewOutput.Clear;
    190190  LabelTestName.Caption := 'TStreamByte test';
    191   Stream := TGMemoryStream<Byte>.Create;
     191  Stream := TGStream<Byte>.Create;
    192192  with Stream do try
    193193    WriteOutput('Size := ', IntToStr(Stream.Size));
  • Generics/NativeGenerics/Units/GenericStream.pas

    r322 r323  
    99
    1010type
    11   TGStream<TItem> = class
     11  TGAbstractStream<TItem> = class
    1212  public
    1313    type
     
    2121    function GetPosition: TIndex;
    2222  public
    23     procedure Assign(Source: TGStream<TItem>); virtual;
     23    procedure Assign(Source: TGAbstractStream<TItem>); virtual;
    2424    procedure Write(Item: TItem); virtual; abstract;
    2525    procedure WriteArray(Item: array of TItem); virtual; abstract;
     
    3636  end;
    3737
    38   TGMemoryStream<TItem> = class(TGStream<TItem>)
     38  TGStream<TItem> = class(TGAbstractStream<TItem>)
    3939  private
    4040    FList: TGList<TItem>;
    4141    FPosition: TIndex;
    4242  public
    43     procedure Assign(Source: TGStream<TItem>); override;
     43    procedure Assign(Source: TGAbstractStream<TItem>); override;
    4444    procedure Write(Item: TItem); override;
    4545    procedure WriteArray(Values: array of TItem); override;
     
    6262{ TGStream }
    6363
    64 procedure TGStream<TItem>.Assign(Source: TGStream<TItem>);
     64procedure TGAbstractStream<TItem>.Assign(Source: TGAbstractStream<TItem>);
    6565begin
    6666end;
    6767
    68 procedure TGStream<TItem>.SetPosition(AValue: TIndex);
     68procedure TGAbstractStream<TItem>.SetPosition(AValue: TIndex);
    6969begin
    7070  Seek(AValue, soBeginning);
    7171end;
    7272
    73 function TGStream<TItem>.GetPosition: TIndex;
     73function TGAbstractStream<TItem>.GetPosition: TIndex;
    7474begin
    7575  Result := Seek(0, soCurrent);
    7676end;
    7777
    78 procedure TGStream<TItem>.SetSize(AValue: TIndex);
     78procedure TGAbstractStream<TItem>.SetSize(AValue: TIndex);
    7979var
    8080  StreamSize: TIndex;
     
    9494end;
    9595
    96 function TGStream<TItem>.GetSize: TIndex;
     96function TGAbstractStream<TItem>.GetSize: TIndex;
    9797var
    9898  OldPosition: Integer;
     
    103103end;
    104104
    105 constructor TGStream<TItem>.Create;
     105constructor TGAbstractStream<TItem>.Create;
    106106begin
    107107  inherited;
    108108end;
    109109
    110 { TMemoryStreamByte }
     110{ TGStream }
    111111
    112 procedure TGMemoryStream<TItem>.Assign(Source: TGStream<TItem>);
     112procedure TGStream<TItem>.Assign(Source: TGAbstractStream<TItem>);
    113113begin
    114114  inherited;
    115   if Source is TGMemoryStream<TItem> then begin
    116     FList.Assign(TGMemoryStream<TItem>(Source).FList);
    117     FPosition := TGMemoryStream<TItem>(Source).FPosition;
     115  if Source is TGStream<TItem> then begin
     116    FList.Assign(TGStream<TItem>(Source).FList);
     117    FPosition := TGStream<TItem>(Source).FPosition;
    118118  end;
    119119end;
    120120
    121 procedure TGMemoryStream<TItem>.Write(Item: TItem);
     121procedure TGStream<TItem>.Write(Item: TItem);
    122122begin
    123123  if FList.Count < (FPosition + 1) then
     
    127127end;
    128128
    129 procedure TGMemoryStream<TItem>.WriteArray(Values: array of TItem);
     129procedure TGStream<TItem>.WriteArray(Values: array of TItem);
    130130begin
    131131  if FList.Count < (FPosition + Length(Values)) then
     
    135135end;
    136136
    137 procedure TGMemoryStream<TItem>.WriteList(List: TGList<TItem>);
     137procedure TGStream<TItem>.WriteList(List: TGList<TItem>);
    138138begin
    139139  FList.ReplaceList(FPosition, List);
    140140end;
    141141
    142 function TGMemoryStream<TItem>.Read: TItem;
     142function TGStream<TItem>.Read: TItem;
    143143begin
    144144  Result := FList[FPosition];
     
    146146end;
    147147
    148 function TGMemoryStream<TItem>.ReadArray(Count: TIndex): TItemArray;
     148function TGStream<TItem>.ReadArray(Count: TIndex): TItemArray;
    149149begin
    150150  Result := FList.GetArray(FPosition, Count);
    151151end;
    152152
    153 function TGMemoryStream<TItem>.ReadList(List: TGList<TItem>; Count: TIndex): TIndex;
     153function TGStream<TItem>.ReadList(List: TGList<TItem>; Count: TIndex): TIndex;
    154154begin
    155155  if (FPosition + Count) > FList.Count then
     
    159159end;
    160160
    161 function TGMemoryStream<TItem>.Insert(Count: TIndex): TIndex;
     161function TGStream<TItem>.Insert(Count: TIndex): TIndex;
    162162begin
    163163  FList.InsertCount(FPosition, Count);
     
    165165end;
    166166
    167 function TGMemoryStream<TItem>.Remove(Count: TIndex): TIndex;
     167function TGStream<TItem>.Remove(Count: TIndex): TIndex;
    168168begin
    169169  Result := FList.Count - FPosition;
     
    172172end;
    173173
    174 function TGMemoryStream<TItem>.Seek(Offset: TIndex; Origin: TSeekOrigin): TIndex;
     174function TGStream<TItem>.Seek(Offset: TIndex; Origin: TSeekOrigin): TIndex;
    175175begin
    176176  case Origin of
     
    184184end;
    185185
    186 constructor TGMemoryStream<TItem>.Create;
     186constructor TGStream<TItem>.Create;
    187187begin
    188188  inherited;
     
    190190end;
    191191
    192 destructor TGMemoryStream<TItem>.Destroy;
     192destructor TGStream<TItem>.Destroy;
    193193begin
    194194  FList.Free;
Note: See TracChangeset for help on using the changeset viewer.