Changeset 126 for oup/current
- Timestamp:
- Mar 23, 2007, 5:05:38 AM (18 years ago)
- Location:
- oup/current
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
oup/current/FileClasses/_DataTypes.pas
r124 r126 4 4 5 5 type 6 TData Type= class6 TDataField = class 7 7 private 8 function GetDataLength: Integer; virtual; abstract; 8 FOffset: Integer; 9 FName: String; 10 FDescription: String; 11 FDataLength: Integer; 9 12 function GetValueAsString: String; virtual; abstract; 10 published 11 property DataLength: Integer read GetDataLength; 12 // property DataLength: Integer; 13 public 14 constructor Create(Offset: Integer; Name, Description: String); 15 16 property Offset: Integer read FOffset; 17 property Name: String read FName; 18 property Description: String read FDescription; 19 property DataLength: Integer read FDataLength; 13 20 property ValueAsString: String read GetValueAsString; 14 21 end; 15 22 16 17 TDataField = record18 Offset: Integer;19 Data: TDataType;20 end;21 23 TDataFields = array of TDataField; 22 24 23 25 24 TInt32 = class(TData Type)26 TInt32 = class(TDataField) 25 27 private 26 FValue: LongWord; 27 function GetDataLength: Integer; override; 28 FInt: LongWord; 28 29 function GetValueAsString: String; override; 30 public 31 constructor Create(Offset: Integer; Name, Description: String); 29 32 end; 30 33 31 TString = class(TDataType) 34 35 TString = class(TDataField) 32 36 private 33 37 FString: String; 34 function GetDataLength: Integer; override;35 38 function GetValueAsString: String; override; 39 public 40 constructor Create(Offset: Integer; Name, Description: String; Length: Integer); 41 end; 42 43 44 45 TArray = class(TDataField) 46 private 47 FDataFields: TDataFields; 48 function GetFieldByOffset(Offset: Integer): TDataField; 49 function GetFieldByIndex(ID: Integer): TDataField; 50 public 51 constructor Create(Offset: Integer; Name, Description: String; Length, Count: Integer); 52 property FieldByOffset[Offset: Integer]: TDataField read GetFieldByOffset; 53 property FieldByIndex[ID: Integer]: TDataField read GetFieldByIndex; 36 54 end; 37 55 … … 41 59 SysUtils; 42 60 61 62 { TDataType } 63 64 constructor TDataField.Create(Offset: Integer; Name, Description: String); 65 begin 66 FOffset := Offset; 67 FName := Name; 68 FDescription := Description; 69 end; 70 71 72 43 73 { TInt32 } 44 74 45 function TInt32.GetDataLength: Integer;75 constructor TInt32.Create(Offset: Integer; Name, Description: String); 46 76 begin 47 Result := 4;77 inherited Create(Offset, Name, Description); 48 78 end; 49 79 50 80 function TInt32.GetValueAsString: String; 51 81 begin 52 Result := IntToStr(F Value);82 Result := IntToStr(FInt); 53 83 end; 84 85 54 86 55 87 { TString } 56 88 57 function TString.GetDataLength: Integer; 89 constructor TString.Create(Offset: Integer; Name, Description: String; 90 Length: Integer); 58 91 begin 59 Result := Length(FString); 92 inherited Create(Offset, Name, Description); 93 60 94 end; 61 95 … … 65 99 end; 66 100 101 102 103 { TArray } 104 105 constructor TArray.Create(Offset: Integer; Name, Description: String; 106 Length, Count: Integer); 107 begin 108 Exit; 109 end; 110 111 function TArray.GetFieldByIndex(ID: Integer): TDataField; 112 begin 113 if ID < Length(FDataFields) then 114 Result := FDataFields[ID] 115 else 116 Result := nil; 117 end; 118 119 function TArray.GetFieldByOffset(Offset: Integer): TDataField; 120 var 121 i: Integer; 122 begin 123 Result := nil; 124 125 if Length(FDataFields) > 0 then 126 begin 127 for i := 0 to High(FDataFields) do 128 if FDataFields[i].Offset = Offset then 129 break; 130 if i < Length(FDataFields) then 131 Result := FDataFields[i]; 132 end; 133 end; 134 135 67 136 end. -
oup/current/FileClasses/_FileTypes.pas
r124 r126 8 8 9 9 type 10 TFile Type= class10 TFile = class 11 11 private 12 FConnectionID: Integer; 13 FFileID: Integer; 14 12 15 FDatLinks: TDatLinkList; 13 16 FDataFields: TDataFields; 14 function GetDatLink(Offset: Integer): TDatLink; 15 function GetField(Offset: Integer): TDataField; 17 FRawParts: TRawDataList; 18 19 function GetDatLinkByOffset(Offset: Integer): TDatLink; 20 function GetDatLinkByIndex(ID: Integer): TDatLink; 21 function GetFieldByOffset(Offset: Integer): TDataField; 22 function GetFieldByIndex(ID: Integer): TDataField; 23 function GetRawPartByOffset(Offset: Integer): TRawDataInfo; 24 function GetRawPartByIndex(ID: Integer): TRawDataInfo; 16 25 public 17 property LinksByID[Offset: Integer]: TDatLink read GetDatLink; 18 property Fields[Offset: Integer]: TDataField read GetField; 26 constructor Create(ConnectionID, FileID: Integer); 27 28 property LinkByOffset[Offset: Integer]: TDatLink read GetDatLinkByOffset; 29 property LinkByIndex[ID: Integer]: TDatLink read GetDatLinkByIndex; 30 31 property FieldByOffset[Offset: Integer]: TDataField read GetFieldByOffset; 32 property FieldByIndex[ID: Integer]: TDataField read GetFieldByIndex; 33 34 property RawPartByOffset[Offset: Integer]: TRawDataInfo read GetRawPartByOffset; 35 property RawPartByIndex[ID: Integer]: TRawDataInfo read GetRawPartByIndex; 19 36 end; 20 37 … … 22 39 implementation 23 40 41 uses 42 DatLinks, RawList; 43 24 44 { TFileType } 25 45 26 function TFileType.GetDatLink(Offset: Integer): TDatLink; 46 constructor TFile.Create(ConnectionID, FileID: Integer); 47 begin 48 FConnectionID := ConnectionID; 49 FFileID := FileID; 50 51 FDatLinks := DatLinksManager.GetDatLinks(ConnectionID, FileID); 52 FRawParts := RawLists.GetRawList(ConnectionID, FileID); 53 end; 54 55 56 function TFile.GetDatLinkByIndex(ID: Integer): TDatLink; 57 begin 58 if ID < Length(FDatLinks) then 59 Result := FDatLinks[ID] 60 else 61 with Result do 62 begin 63 SrcOffset := -1; 64 DestID := -1; 65 PosDestExts := ''; 66 end; 67 end; 68 69 function TFile.GetDatLinkByOffset(Offset: Integer): TDatLink; 27 70 var 28 71 i: Integer; … … 42 85 end; 43 86 44 function TFileType.GetField(Offset: Integer): TDataField; 87 88 function TFile.GetFieldByIndex(ID: Integer): TDataField; 89 begin 90 if ID < Length(FDataFields) then 91 Result := FDataFields[ID] 92 else 93 Result := nil; 94 end; 95 96 function TFile.GetFieldByOffset(Offset: Integer): TDataField; 45 97 var 46 98 i: Integer; 47 99 begin 48 Result.Offset := -1; 49 Result.Data := nil; 100 Result := nil; 50 101 51 102 if Length(FDataFields) > 0 then … … 59 110 end; 60 111 112 113 function TFile.GetRawPartByIndex(ID: Integer): TRawDataInfo; 114 begin 115 if ID < Length(FRawParts) then 116 Result := FRawParts[ID] 117 else 118 with Result do 119 begin 120 SrcID := -1; 121 SrcOffset := -1; 122 RawAddr := -1; 123 RawSize := -1; 124 end; 125 end; 126 127 function TFile.GetRawPartByOffset(Offset: Integer): TRawDataInfo; 128 var 129 i: Integer; 130 begin 131 with Result do 132 begin 133 SrcID := -1; 134 SrcOffset := -1; 135 RawAddr := -1; 136 RawSize := -1; 137 end; 138 139 if Length(FRawParts) > 0 then 140 begin 141 for i := 0 to High(FRawParts) do 142 if FRawParts[i].SrcOffset = Offset then 143 break; 144 if i < Length(FRawParts) then 145 Result := FRawParts[i]; 146 end; 147 end; 148 61 149 end.
Note:
See TracChangeset
for help on using the changeset viewer.