Changeset 342 for Generics/TemplateGenerics/Specialized
- Timestamp:
- Apr 3, 2012, 7:35:26 AM (13 years ago)
- Location:
- Generics/TemplateGenerics/Specialized
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Generics/TemplateGenerics/Specialized/SpecializedList.pas
r304 r342 95 95 procedure AddStream(Stream: TStream); 96 96 procedure AddStreamPart(Stream: TStream; ItemCount: TGListIndex); 97 procedure WriteBuffer(var Buffer; Count: Integer); 98 procedure ReadBuffer(var Buffer; Count: Integer); 97 99 end; 98 100 … … 417 419 end; 418 420 421 procedure TListByte.WriteBuffer(var Buffer; Count: Integer); 422 begin 423 424 end; 425 426 procedure TListByte.ReadBuffer(var Buffer; Count: Integer); 427 begin 428 429 end; 430 419 431 end. -
Generics/TemplateGenerics/Specialized/SpecializedStream.pas
r312 r342 6 6 7 7 uses 8 Classes, SysUtils, SpecializedList ;8 Classes, SysUtils, SpecializedList, DateUtils; 9 9 10 10 type … … 29 29 {$DEFINE TGStreamItem := Byte} 30 30 {$DEFINE TGStreamList := TListStreamByte} 31 {$DEFINE TGStream := T StreamByte}31 {$DEFINE TGStream := TBaseStreamByte} 32 32 {$DEFINE TGStreamSortCompare := TStreamByteSortCompare} 33 33 {$DEFINE TGStreamToStringConverter := TStreamByteToStringConverter} … … 49 49 {$I 'GenericStream.inc'} 50 50 51 TStreamByte = class(TBaseStreamByte) 52 function ReadBuffer(var Buffer; Count: Integer): Integer; virtual; abstract; 53 function WriteBuffer(var Buffer; Count: Integer): Integer; virtual; abstract; 54 end; 55 56 { TMemoryStreamByte } 57 58 TMemoryStreamByte = class(TStreamByte) 59 private 60 FList: TListByte; 61 FOwnsList: Boolean; 62 FPosition: Integer; 63 public 64 procedure Assign(Source: TBaseStreamByte); override; 65 procedure Write(Item: Byte); override; 66 procedure WriteArray(Values: array of Byte); override; 67 procedure WriteList(List: TListByte); 68 function WriteBuffer(var Buffer; Count: Integer): Integer; override; 69 procedure WriteStream(Stream: TBaseStreamByte; Count: Integer); override; 70 function Read: Byte; override; 71 function ReadArray(Count: Integer): TStreamByteItemArray; override; 72 function ReadList(List: TListByte; Count: Integer): Integer; 73 function ReadBuffer(var Buffer; Count: Integer): Integer; override; 74 function ReadStream(Stream: TBaseStreamByte; Count: Integer): Integer; override; 75 function Insert(Count: Integer): Integer; override; 76 function Remove(Count: Integer): Integer; override; 77 function Seek(Offset: Integer; Origin: TSeekOrigin = soCurrent): Integer; override; 78 constructor Create; override; overload; 79 constructor Create(AList: TListByte); overload; 80 destructor Destroy; override; 81 property OwnsList: Boolean read FOwnsList write FOwnsList; 82 property List: TListByte read FList; 83 end; 84 85 86 implementation 87 51 88 { TMemoryStreamByte } 52 89 53 TMemoryStreamByte = class(TStreamByte) 54 private 55 FList: TListByte; 56 FPosition: Integer; 57 public 58 procedure Assign(Source: TStreamByte); override; 59 procedure Write(Item: Byte); override; 60 procedure WriteArray(Values: array of Byte); override; 61 procedure WriteList(List: TListByte); 62 function Read: Byte; override; 63 function ReadArray(Count: Integer): TStreamByteItemArray; override; 64 function ReadList(List: TListByte; Count: Integer): Integer; 65 function Insert(Count: Integer): Integer; override; 66 function Remove(Count: Integer): Integer; override; 67 function Seek(Offset: Integer; Origin: TSeekOrigin = soCurrent): Integer; override; 68 constructor Create; override; 69 destructor Destroy; override; 70 property List: TListByte read FList; 71 end; 72 73 74 implementation 75 76 { TMemoryStreamByte } 77 78 procedure TMemoryStreamByte.Assign(Source: TStreamByte); 90 procedure TMemoryStreamByte.Assign(Source: TBaseStreamByte); 79 91 begin 80 92 inherited; … … 106 118 end; 107 119 120 procedure TMemoryStreamByte.WriteStream(Stream: TBaseStreamByte; Count: Integer); 121 begin 122 123 end; 124 125 function TMemoryStreamByte.WriteBuffer(var Buffer; Count: Integer): Integer; 126 begin 127 128 end; 129 108 130 function TMemoryStreamByte.Read: Byte; 109 131 begin … … 125 147 end; 126 148 149 function TMemoryStreamByte.ReadBuffer(var Buffer; Count: Integer): Integer; 150 begin 151 152 end; 153 154 function TMemoryStreamByte.ReadStream(Stream: TBaseStreamByte; Count: Integer 155 ): Integer; 156 begin 157 158 end; 159 127 160 function TMemoryStreamByte.Insert(Count: Integer): Integer; 128 161 begin … … 154 187 inherited; 155 188 FList := TListByte.Create; 189 OwnsList := True; 190 end; 191 192 constructor TMemoryStreamByte.Create(AList: TListByte); 193 begin 194 inherited Create; 195 FList := AList; 196 OwnsList := False; 156 197 end; 157 198 158 199 destructor TMemoryStreamByte.Destroy; 159 200 begin 160 FList.Free;201 if OwnsList then FList.Free; 161 202 inherited Destroy; 162 203 end; … … 181 222 {$DEFINE TGStreamItem := Byte} 182 223 {$DEFINE TGStreamList := TListStreamByte} 183 {$DEFINE TGStream := T StreamByte}224 {$DEFINE TGStream := TBaseStreamByte} 184 225 {$DEFINE TGStreamSortCompare := TStreamByteSortCompare} 185 226 {$DEFINE TGStreamToStringConverter := TStreamByteToStringConverter} … … 200 241 {$DEFINE IMPLEMENTATION} 201 242 {$I 'GenericStream.inc'} 243 244 245 202 246 end.
Note:
See TracChangeset
for help on using the changeset viewer.