-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathLightCore.Types.pas
More file actions
230 lines (183 loc) · 6.65 KB
/
LightCore.Types.pas
File metadata and controls
230 lines (183 loc) · 6.65 KB
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
UNIT LightCore.Types;
{=============================================================================================================
2026.01.30
www.GabrielMoraru.com
=============================================================================================================}
INTERFACE
USES
System.SysUtils,
System.Classes,
System.Generics.Collections;
{ Extra VK constants that are missing from Delphi's Windows API interface (Windows.pas unit)
More virtual keys here: http://delphi.about.com/od/objectpascalide/l/blvkc.htm }
CONST
VK_NULL = 0;
VK_PRIOR = $21; { PAGE UP }
VK_NEXT = $22; { PAGE DOWN }
VK_pgUp = $21; { PAGE UP }
VK_pgDwn = $22; { PAGE DOWN }
VK_COPYRIGHT = 169; { Type ALT 0169 to get © }
VK_REGISTERED = 174; { Type ALT 0174 to get ® }
VK_SEMICOLON = 186;
VK_EQUAL = 187;
VK_COMMA = 188;
VK_MINUS = 189;
VK_PERIOD = 190;
VK_SLASH = 191;
VK_BACKQUOTE = 192;
VK_LEFTBRACKET = 219;
VK_BACKSLASH = 220;
VK_RIGHTBRACKET = 221;
VK_QUOTE = 222;
{ Note: VK_ENTER = VK_RETURN ($0D / 13) is defined in Winapi.Windows }
CONST
Numbers = ['0'..'9'];
LettersLowCase = ['a'..'z'];
LettersUpCase = ['A'..'Z'];
LettersSigns = [' ', '~', '`', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-', '_', '+', '=', '[', ']', '{', '}', ';', ':', '''', '"', '<', '>', ',', '.', '/', '?', '\', '|'];
Alphabet = ['a'..'z', 'A'..'Z'];
AlphabetNo = ['a'..'z', 'A'..'Z', '0'..'9'];
Vowels = ['a', 'e', 'i','o', 'u', 'y', 'A', 'E', 'I', 'O', 'U', 'Y'];
LettersSpecial = [#10, #13, #9]; { LF, CR, TAB }
{ Indexes }
CONST
IndexedIn1 = 1;
IndexedIn0 = 0;
IndexDiff = 1;
HeaderOverhead = 1;
HeaderRow = 0;
UnInitialized = -7777777;
{ Mine }
CONST
SHOW = TRUE;
HIDE = FALSE;
OFF = FALSE;
&ON = TRUE;
OwnObjects = TRUE;
{ Units }
CONST
KB = 1024;
MB = 1048576;
GB = 1073741824;
TB = 1099511627776;
CONST
HexNumbers = ['0'..'9', 'a'..'f', 'A'..'F'];
CONST
// Use 'Segoe UI Symbol' or 'Segoe UI' for monochrome symbol glyphs.
// Use 'Segoe UI Emoji' for color emoji.
IconRecycleBin = #$D83D + #$DDD1; // Recycle basket
IconRecycleBinBW = #9851; // BLACK UNIVERSAL RECYCLING SYMBOL
IconCancel = '❌'; // #10006 Red
IconCancelPurple = '✖'; // Purple
IconCheckMark = '✔';
IconBackArrow = #$2B05;
IconUndo = #$21BA; // ANTICLOCKWISE OPEN CIRCLE ARROW— good for "reverse direction / undo order"
IconSettingsGear = '⚙'; // U+2699
IconSettingsKey = '🔧'; // U+1F527 (WRENCH)
IconPlay = '▶'; // U+25B6
IconPause = '⏸'; // U+23F8
IconStop = '⏹'; // U+23F9
IconRecord = '⏺'; // U+23FA
IconFastForward = '⏩'; // U+23E9
IconRewind = '⏪'; // U+23EA
IconSkipNext = '⏭'; // U+23ED
IconSkipPrev = '⏮'; // U+23EE
IconStopwatch = '⏱'; // U+23F1: Stopwatch
IconClock = '⏲'; // U+23F2: Timer Clock
IconAlarm = '⏰'; // U+23F0: Alarm Clock
IconHourglass = '⏳'; // U+23F3: Hourglass with Flowing Sand
IconWatch = '⌚'; // U+231A: Watch
TYPE
TStringArray = array of string;
TSingleArray = array of Single;
TBytesArray = System.SysUtils.TBytes;
TNotifyMsgEvent = procedure(Sender: TObject; Msg: string) of object; { For general use }
WebURL = string;
TDoubleArray = array of Double;
TDoubleArrayHelper= record helper for TDoubleArray
public
procedure Add(const Element: Double);
procedure Sort;
end;
TIntegerArray = array of Integer;
TIntegerArrayHelper= record helper for TIntegerArray
public
function Average: Single;
procedure Add(const Element: Integer);
end;
{=============================================================================================================
TIME
=============================================================================================================}
TYPE
{ Returns the next day in the week }
TWeekDays = (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday); // Days enumeration
TWeekDaysHelper = record helper for TWeekDays
function NextDay: TWeekDays;
function ToString: string;
end;
CONST
NullDate = -700000; { https://stackoverflow.com/questions/14985037/delphi-how-to-determine-and-empty-tdatetime-value }
Second = 1000; { Milliseconds per second. See also: MSecsPerSec }
Minute = 60; { Seconds per minute. See also: System.SysUtils.SecsPerMin }
Hour = 3600; { Seconds per hour }
Day = 86400; { Seconds per day }
MSecsPerMin = 60000; { Milliseconds per minute }
MinutesPerDay= 24 * 60; { Minutes per day (1440) }
NanosPerMicroSec= 1000;
NanosPerMileSec = 1000000;
NanosPerSecond = 1000000000;
NanosPerMinute = Int64(60) * NanosPerSecond;
IMPLEMENTATION
{ TIntegerArrayHelper }
procedure TIntegerArrayHelper.Add(const Element: Integer);
var Len: Integer;
begin
Len:= Length(Self);
SetLength(Self, Len + 1);
Self[len]:= Element;
end;
function TIntegerArrayHelper.Average: Single;
VAR i, Sum: Integer;
begin
if Length(Self) = 0 then EXIT(0);
Sum:= 0;
for i in Self do
Sum:= Sum + i;
Result:= Sum / Length(Self);
end;
{ Returns the next day in the week }
function TWeekDaysHelper.NextDay: TWeekDays;
var Next: Integer;
begin
Next := Ord(Self) + 1;
if Next <= Ord(High(TWeekDays))
then Result := TWeekDays(Next)
else Result := TWeekDays.Monday;
end;
function TWeekDaysHelper.ToString: string;
begin
case Self of
Monday : Result:= 'Monday';
Tuesday : Result:= 'Tuesday';
Wednesday : Result:= 'Wednesday';
Thursday : Result:= 'Thursday';
Friday : Result:= 'Friday';
Saturday : Result:= 'Saturday';
Sunday : Result:= 'Sunday';
else
RAISE Exception.Create('TWeekDaysHelper - Unknown type');
end;
end;
{ TDoubleArrayHelper }
procedure TDoubleArrayHelper.Add(const Element: Double);
var Len: Integer;
begin
Len:= Length(Self);
SetLength(Self, Len + 1);
Self[len]:= Element;
end;
procedure TDoubleArrayHelper.Sort;
begin
TArray.Sort<Double>(Self);
end;
end.