source: oup/current/FileClasses/_DataTypes.pas@ 125

Last change on this file since 125 was 124, checked in by alloc, 18 years ago
File size: 1.2 KB
Line 
1unit _DataTypes;
2
3interface
4
5type
6 TDataType = class
7 private
8 function GetDataLength: Integer; virtual; abstract;
9 function GetValueAsString: String; virtual; abstract;
10 published
11 property DataLength: Integer read GetDataLength;
12// property DataLength: Integer;
13 property ValueAsString: String read GetValueAsString;
14 end;
15
16
17 TDataField = record
18 Offset: Integer;
19 Data: TDataType;
20 end;
21 TDataFields = array of TDataField;
22
23
24 TInt32 = class(TDataType)
25 private
26 FValue: LongWord;
27 function GetDataLength: Integer; override;
28 function GetValueAsString: String; override;
29 end;
30
31 TString = class(TDataType)
32 private
33 FString: String;
34 function GetDataLength: Integer; override;
35 function GetValueAsString: String; override;
36 end;
37
38implementation
39
40uses
41 SysUtils;
42
43{ TInt32 }
44
45function TInt32.GetDataLength: Integer;
46begin
47 Result := 4;
48end;
49
50function TInt32.GetValueAsString: String;
51begin
52 Result := IntToStr(FValue);
53end;
54
55{ TString }
56
57function TString.GetDataLength: Integer;
58begin
59 Result := Length(FString);
60end;
61
62function TString.GetValueAsString: String;
63begin
64 Result := FString;
65end;
66
67end.
Note: See TracBrowser for help on using the repository browser.