blob: 497d0ef50813de133374f00fb42d3b44baae5804 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
Class Function TORDINALHELPER.Parse(const AString: string): TORDINALTYPE; inline; static;
var
Error: Integer;
begin
Val(AString,Result,Error);
if Error<>0 then
raise EConvertError.CreateFmt(SInvalidInteger,[AString]);
end;
Class Function TORDINALHELPER.Size: Integer; inline; static;
begin
Result:=SizeOf(TORDINALTYPE);
end;
Class Function TORDINALHELPER.ToString(const AValue: TORDINALTYPE): string; overload; inline; static;
begin
Str(AValue,Result);
end;
Class Function TORDINALHELPER.TryParse(const AString: string; out AValue: TORDINALTYPE): Boolean; inline; static;
Var
C : Integer;
begin
Val(AString,AValue,C);
Result:=(C=0);
end;
Function TORDINALHELPER.ToBoolean: Boolean; inline;
begin
Result:=(Self<>0);
end;
Function TORDINALHELPER.ToDouble: Double; inline;
begin
Result:=Self;
end;
Function TORDINALHELPER.ToExtended: Extended; inline;
begin
Result:=Self;
end;
Function TORDINALHELPER.ToBinString: string; inline;
begin
Result:=BinStr(Self,SizeOf(TORDINALTYPE)*8);
end;
Function TORDINALHELPER.ToHexString(const AMinDigits: Integer): string;
overload; inline;
begin
Result:=IntToHex(Self,AMinDigits);
end;
Function TORDINALHELPER.ToHexString: string; overload; inline;
begin
Result:=IntToHex(Self);
end;
Function TORDINALHELPER.ToSingle: Single; inline;
begin
Result:=Self;
end;
Function TORDINALHELPER.ToString: string; overload; inline;
begin
Str(Self,Result);
end;
Function TORDINALHELPER.SetBit(const index: TORDINALBITINDEX) : TORDINALTYPE; inline;
begin
Self := Self or (TORDINALTYPE(1) shl index);
Result:=Self;
end;
Function TORDINALHELPER.ClearBit(const index: TORDINALBITINDEX) : TORDINALTYPE; inline;
begin
Self:=Self and not TORDINALTYPE((TORDINALTYPE(1) shl index));
Result:=Self;
end;
Function TORDINALHELPER.ToggleBit(const index: TORDINALBITINDEX) : TORDINALTYPE; inline;
begin
Self := Self xor TORDINALTYPE((TORDINALTYPE(1) shl index));
Result:=Self;
end;
Function TORDINALHELPER.TestBit(const Index: TORDINALBITINDEX):Boolean; inline;
begin
Result := (Self and TORDINALTYPE((TORDINALTYPE(1) shl index)))<>0;
end;
|