-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcautils.pas
4607 lines (4126 loc) · 135 KB
/
cautils.pas
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
unit caUtils;
{$INCLUDE ca.inc}
interface
uses
// Standard Delphi units
Windows,
Messages,
SysUtils,
Classes,
Controls,
Graphics,
Math,
FileCtrl,
Masks,
ActiveX,
ComObj,
TypInfo,
Dialogs,
Forms,
StdCtrls,
ExtCtrls,
Registry,
Clipbrd,
DB,
// ca units
caTypes,
caConsts,
caTimer,
caClasses;
type
EcaIEEEMath = class(EcaException);
TcaFileSearchEvent = procedure(Sender: TObject; var Continue: Boolean) of object;
//---------------------------------------------------------------------------
// IcaUtils
//---------------------------------------------------------------------------
IcaUtils = interface
['{45103F38-42ED-4B98-AE75-6F46A66ECE8B}']
// Property methods
function GetOnContinueFileSearch: TcaFileSearchEvent;
procedure SetOnContinueFileSearch(const Value: TcaFileSearchEvent);
// Conversion methods
// To string
function ArrayToString(AList: array of string; Delimiter: string; Shrink: Boolean = False): string;
function BooleanToString(ABoolean: Boolean): string;
function DateTimeToString(ADateTime: TDateTime; const ADateFormat: string): string;
function DoubleToString(ADouble: Double; const AFloatFormat: string): string;
function ExtendedToString(AExtended: Extended; const AFloatFormat: string): string;
function IntegerToString(AInteger: Integer; const AIntegerFormat: string): string;
function Int64ToString(AInt64: Int64; const AIntegerFormat: string): string;
function MemoToString(AMemo: TStrings): string;
function ObjectToString(AObject: TObject): string;
function SingleToString(ASingle: Single; const AFloatFormat: string): string;
// From string
function StringToBoolean(const ABooleanStr: string): Boolean;
function StringToDateTime(const ADateTimeStr: string): TDateTime;
function StringToDouble(const ADoubleStr: string): Double;
function StringToExtended(const AExtendedStr: string): Extended;
function StringToInt64(const AInt64Str: string): Int64;
function StringToInteger(const AIntegerStr: string): Integer;
function StringToSingle(const ASingleStr: string): Single;
function StrToFloat(const AFloatStr: string): Extended;
procedure StringToMemo(const AMemoStr: string; AMemo: TStrings);
// Other conversions
function ExtendedToDateTime(AExtended: Extended): TDateTime;
function IntegerToDateTime(AInteger: Integer): TDateTime;
function SingleToDateTime(ASingle: Single): TDateTime;
function Str2Float(const S: string; Default: Extended): Extended;
function Str2Int(const S: string; Default: Integer): Integer;
function IntToShortMonth(AIndex: Integer): string;
function IntToLongMonth(AIndex: Integer): string;
function ShortMonthToInt(AShortMonth: string): Integer;
function LongMonthToInt(ALongMonth: string): Integer;
function StreamToString(AStream: TStream): string;
// Comparison menthods
function CompareBooleans(const B1, B2: Boolean): TcaCompareResult;
function CompareDateTimes(const D1, D2: TDateTime): TcaCompareResult;
function CompareDoubles(const D1, D2: Double): TcaCompareResult;
function CompareExtendeds(const E1, E2: Extended): TcaCompareResult;
function CompareIntegers(const I1, I2: Integer): TcaCompareResult;
function CompareInt64s(const I1, I2: Int64): TcaCompareResult;
function CompareSingles(const S1, S2: Single): TcaCompareResult;
function CompareStrings(const S1, S2: string; ACaseInsensitive: Boolean = False): TcaCompareResult;
function OperatorToString(AOperator: TcaOperator): string;
// Array comparison menthods
function DoubleArraysEqual(A1, A2: array of Double): Boolean;
// string methods
function BuildString(Ch: Char; Count: Integer): string;
function CopyUntilChar(var S: string; Ch: Char; DeleteAfter: Boolean = False): string;
function DoubleQuoted(const S: string): string;
function FastCharPos(const ASource: string; const C: Char; StartPos: Integer = 1): Integer;
function FastPos(const ASourceString, AFindString: string; StartPos: Integer = 1; CaseSensitive: Boolean = False): Integer;
function Format(const Format: string): string; overload;
function Format(const Format: string; const Args: array of const): string; overload;
function Format(const Format: string; const Args: array of const; AUseEscapes: Boolean): string; overload;
function GetNextToken(var S: string; Delim: Char): string;
function Hash(const S: string): Integer;
function Indent(const S: string; N: Integer): string;
function IsBlankOrZero(const S: string): Boolean;
function IsInteger(const s: string): Boolean;
function IsNumeric(const S: string): Boolean;
function LastChar(const S: string): Char;
function LeftStr(const S: string; N: Integer; ACase: TcaLetterCase = caAny): string;
function PadInt(N: Integer; Ch: Char; Len: Integer): string;
function PadLeft(const S: string; Ch: Char; Len: Integer): string;
function PadRight(const S: string; Ch: Char; Len: Integer): string;
function PadZero(N: Integer; Len: Integer): string;
function PosFromEnd(const SubS, S: string): Integer;
function PosFromStart(const SubS, S: string): Integer;
function RightStr(const S: string; N: Integer; ACase: TcaLetterCase = caAny): string;
function StartsWith(AString: string; SearchString: string; ACaseInsensitive: boolean = false): boolean;
procedure ChangeCase(var S: string; ACase: TcaLetterCase);
procedure CleanFilenameString(var S: string);
procedure CleanIntString(var S: string);
procedure CleanNumString(var S: string);
procedure CleanString(var S: string);
procedure DeleteFromChar(var S: string; Ch: Char; IncludeChar: Boolean; N: Integer = 0);
procedure DeleteFromEnd(var S: string; N: Integer);
procedure DeleteFromStart(var S: string; N: Integer);
procedure DeleteUntilChar(var S: string; Ch: Char; IncludeChar: Boolean);
procedure EnsureLastChar(var S: string; Ch: Char);
procedure EnsureBackslash(var S: string);
procedure MoveStr(const Source: string; SourcePos: Integer; var Dest: string; const DestPos, Count: Integer);
procedure ReadStringFromBuffer(var S: string; var Buffer: PChar);
procedure Replace(var S: string; const OldSub, NewSub: string; CaseSensitive: Boolean = False);
procedure ReplaceChar(var S: string; const OldChar, NewChar: Char);
procedure SplitCamelCaps(var S: string);
procedure SortStrings(AStrings: TStrings);
procedure StripChar(C: Char; var S: string);
procedure StripLastCRLF(var S: string);
procedure StripLeadingLowerCase(var S: string);
procedure StripDoubleQuotes(var S: string);
procedure WriteStringToBuffer(const S: string; var Buffer: PChar);
// TStrings support
function MultiReplace(const S: string; AReplaceStrings: TStrings): string; overload;
procedure MaskDelete(AStrings, AMasks: TStrings);
procedure MultiReplace(AStrings, AReplaceStrings: TStrings); overload;
// Record support
procedure FillRecordFalse(var Rec; Size: Integer);
procedure FillRecordTrue(var Rec; Size: Integer);
// File methods
function RemoveExt(const AFileName: string): string;
function ExtractFileName(const FileName: string; IncludeExt: boolean = true): string;
procedure GetFileList(const APath, AFileSpec: string; AFileList: TcaStringList; IncludeDotRefs: Boolean = False); overload;
procedure GetFileList(const APath, AFileSpec: string; AFileList: IcaStringList; IncludeDotRefs: Boolean = False); overload;
procedure GetFileList(const APath, AFileSpec: string; AFileList: TStrings; IncludeDotRefs: Boolean = False); overload;
procedure SearchForFiles(const APath, AFileSpec: string; AOutList: TStrings); overload;
procedure SearchForFiles(const APath, AFileSpec: string; AOutList: IcaStringList); overload;
// Math evaluator methods
function GetOperatorPrecedence(const AOperator, AReferenceOperator: string): TcaOperatorPrecedence;
function IsBracket(const S: string): Boolean;
function IsFunction(const S: string): Boolean;
function IsOperand(const S: string): Boolean;
function IsOperator(const S: string): Boolean;
// Graphics methods
function GetBitmapRect(ABitmap: TBitmap): TRect;
function HTMLColorToColor(const AHTMLColor: string): TColor;
// Font methods
function FontsEqual(AFont1, AFont2: TFont): Boolean;
// TRect methods
function InRect(X, Y: Integer; Rect: TRect): Boolean; overload;
function InRect(APoint: TPoint; Rect: TRect): Boolean; overload;
procedure AdjustRect(var ARect: TRect; const dL, dT, dR, dB: Integer);
procedure DecodeRect(const ARect: TRect; var ALeft, ATop, AWidth, AHeight: Integer);
// Dialog methods
function QueryDeleteData(AHandle: HWND; const ADataSynonym: string = ''): TcaMsgDialogResponse;
function QuerySaveData(AHandle: HWND): TcaMsgDialogResponse;
function QueryCloseApp(AHandle: HWND; const ACloseSynonym: string = ''): TcaMsgDialogResponse;
// System methods cautils
function AltKeyDown: Boolean;
function ControlKeyDown: Boolean;
function ShiftKeyDown: Boolean;
function IsKeyDown(AKeyCode: Word): Boolean;
function IsLargeFonts: Boolean;
function EnableDebugPrivilege(const Enable: Boolean): Boolean;
function FolderExists(const AFolder: string): Boolean;
function GetComputerName: string;
function GetEnvironmentVariable(const AName: string): string;
function GetFileVersion(const AFileName: string; ABlockCount: Word = 4): string;
function GetSystemMenuFont: TFont;
function GetGUIDAsString: string;
function GetUserName: string;
function GetWindowClass(Wnd: HWND): string;
function GetWindowProcess(Wnd: HWND): string;
function GetWindowsFolder: string;
function GetWindowsVersion: TcaWinVersion;
function WinExecAndWait32(FileName: string; Visibility: Integer): Integer;
procedure AppClose(AHandle: HWND);
procedure AppMaximize(AHandle: HWND);
procedure AppMinimize(AHandle: HWND);
procedure AppMove(AHandle: HWND);
procedure AppRestore(AHandle: HWND);
procedure AppSize(AHandle: HWND);
procedure AppToggleNormalAndMaximized(AHandle: HWND);
procedure SendKey(AHandle: HWND; AKey: Word; const shift: TShiftState; IsSpecialKey: Boolean);
procedure SetEnvironmentVariable(const AName, AValue: string; ABroadcast: Boolean = True);
procedure SetWindowStayOnTop(AHandle: HWND; IsStayOnTop: Boolean);
// Application path methods - works with EXEs and DLLs
function AppName: string;
function AppPath: string;
function AppPathAndName: string;
function ConfigPath: string;
function DataPath: string;
function IsTestApp: Boolean;
// Development/Debugging
function ApplicationIsDelphi: Boolean;
function DelphiIsRunning: Boolean;
// IEEE-754 Support for NANs and INFs
function NAN: Double;
function PositiveInfinity: Double;
function NegativeInfinity: Double;
function IsNAN(const N: Double): Boolean;
function IsInfinity(const N: Double): Boolean;
function DoubleToHex(const N: Double): string;
function HexToDouble(const Hex: string): Double;
// Excel related methods
function A1Ref(C: Byte; R: Integer): string;
function CRRef(const A1Ref: string): TcaColRow;
// Component / TPersistent support
function CopyPublishedProperties(Src, Dest: TPersistent; CopyClassPointers, CopyChildren: Boolean): Boolean;
function DeepCopy(Src, Dest: TPersistent): Boolean;
function PersistentAsString(AObject: TPersistent): string;
function PublishedPropertiesMatch(AItem1, AItem2: TPersistent; ACompareClassPointers: Boolean = False): Boolean;
function ShallowCopy(Src, Dest: TPersistent; CopyClassPointers: Boolean = False): Boolean;
// Design by Contract constructs
function FailsAll(AConditions: array of Boolean): Boolean;
function FailsAny(AConditions: array of Boolean): Boolean;
// Interface support
function GetImplementingObject(const Intf: IUnknown): TObject;
// Method support
function MethodsMatch(AMethod1, AMethod2: TMethod): Boolean;
// Time support methods
function CurrentYear: Word;
function DateTimeToTimePoint(ADateTime: TDateTime): TcaTimePoint;
function Now: TcaTimePoint;
// Message dialog methods
function MessageDialog(const ACaption, AMsg: string; ADlgType: TMsgDlgType;
AButtonCaptions: array of string; ADefaultIndex: Integer; AHelpCtx: Longint): TcaMessageDialogResponse;
// Visual control support
procedure SetControlFont(AControl: TControl; AColor: TColor; ASize: Integer; AStyle: TFontStyles);
// Events - FileSearch cancel
property OnContinueFileSearch: TcaFileSearchEvent read GetOnContinueFileSearch write SetOnContinueFileSearch;
// Clipboard methods
procedure CopyDatasetToClipboard(ADataset: TDataset);
end;
//---------------------------------------------------------------------------
// IcaKeys
//---------------------------------------------------------------------------
IcaKeys = interface
['{DD51F155-6119-411D-83CC-C439845CD351}']
// Property methods
function GetAllKeys: TcaByteSet;
function GetAlphaKeys: TcaByteSet;
function GetControlKeys: TcaByteSet;
function GetDecimalKeys: TcaByteSet;
function GetHexKeys: TcaByteSet;
function GetIntegerKeys: TcaByteSet;
function GetNumericKeys: TcaByteSet;
function GetVisibleKeys: TcaByteSet;
// Properties
property AllKeys: TcaByteSet read GetAllKeys;
property AlphaKeys: TcaByteSet read GetAlphaKeys;
property ControlKeys: TcaByteSet read GetControlKeys;
property DecimalKeys: TcaByteSet read GetDecimalKeys;
property HexKeys: TcaByteSet read GetHexKeys;
property IntegerKeys: TcaByteSet read GetIntegerKeys;
property NumericKeys: TcaByteSet read GetNumericKeys;
property VisibleKeys: TcaByteSet read GetVisibleKeys;
end;
//---------------------------------------------------------------------------
// IcaMathUtils
//---------------------------------------------------------------------------
IcaMathUtils = interface
['{E2CA737A-80EC-42C4-98EC-35730C2C8E27}']
// Property methods
function GetUseCheck8087: Boolean;
function GetZeroTolerance: Extended;
procedure SetUseCheck8087(const Value: Boolean);
procedure SetZeroTolerance(const Value: Extended);
// Public methods
function BankersRound(const X: Extended): Integer;
function Equal(const N1, N2: Double): Boolean; overload;
function Equal(const N1, N2: Extended): Boolean; overload;
function Equal(const N1, N2: Single): Boolean; overload;
function EquiRound(const X: Extended): Integer;
function Exp(const N: Double): Double;
function FloatDiv(const Numerator, Divisor, Default: Extended): Extended;
function FloatPower(const ABase, AExponent: Extended): Extended;
function IntPower(const ABase: Extended; AExponent: Integer): Extended;
function RoundTo(const Value: Extended; Places: Integer): Extended;
function SafeFrac(const X: Extended): Extended;
function SafeRound(const X: Extended): Integer;
function SafeStrToInt(const AStrVal: string): Integer;
function SafeTrunc(const X: Extended): Integer;
function Sign(const N: Double): Integer;
function Sqr(X: Extended): Extended;
function Trunc(X: Extended): Int64;
function VBInt(X: Extended): Int64;
// Comparisons
function IsGreaterThanZero(const AValue: Double): Boolean; overload;
function IsGreaterThanZero(const AValue: Extended): Boolean; overload;
function IsGreaterThanZero(const AValue: Single): Boolean; overload;
function IsNonZero(const AValue: Double): Boolean; overload;
function IsNonZero(const AValue: Extended): Boolean; overload;
function IsNonZero(const AValue: Single): Boolean; overload;
function IsZero(const AValue: Double): Boolean; overload;
function IsZero(const AValue: Extended): Boolean; overload;
function IsZero(const AValue: Single): Boolean; overload;
// Is Equal to
function IsEq(const AValue1, AValue2: Double): Boolean; overload;
function IsEq(const AValue1, AValue2: Extended): Boolean; overload;
function IsEq(const AValue1, AValue2: Single): Boolean; overload;
// Is Not Equal to
function IsNEq(const AValue1, AValue2: Double): Boolean; overload;
function IsNEq(const AValue1, AValue2: Extended): Boolean; overload;
function IsNEq(const AValue1, AValue2: Single): Boolean; overload;
// Is Greater Than
function IsGT(const AValue1, AValue2: Double): Boolean; overload;
function IsGT(const AValue1, AValue2: Extended): Boolean; overload;
function IsGT(const AValue1, AValue2: Single): Boolean; overload;
// Is Greater Than or Equal
function IsGTE(const AValue1, AValue2: Double): Boolean; overload;
function IsGTE(const AValue1, AValue2: Extended): Boolean; overload;
function IsGTE(const AValue1, AValue2: Single): Boolean; overload;
// Is Less Than
function IsLT(const AValue1, AValue2: Double): Boolean; overload;
function IsLT(const AValue1, AValue2: Extended): Boolean; overload;
function IsLT(const AValue1, AValue2: Single): Boolean; overload;
// Is Less Than or Equal
function IsLTE(const AValue1, AValue2: Double): Boolean; overload;
function IsLTE(const AValue1, AValue2: Extended): Boolean; overload;
function IsLTE(const AValue1, AValue2: Single): Boolean; overload;
// Is Greater Than Zero
function IsGT0(const AValue: Double): Boolean; overload;
function IsGT0(const AValue: Extended): Boolean; overload;
function IsGT0(const AValue: Single): Boolean; overload;
// Is Greater Than or Equal to Zero
function IsGTE0(const AValue: Double): Boolean; overload;
function IsGTE0(const AValue: Extended): Boolean; overload;
function IsGTE0(const AValue: Single): Boolean; overload;
// Is Less Than Zero
function IsLT0(const AValue: Double): Boolean; overload;
function IsLT0(const AValue: Extended): Boolean; overload;
function IsLT0(const AValue: Single): Boolean; overload;
// Is Less Than or Equal to Zero
function IsLTE0(const AValue: Double): Boolean; overload;
function IsLTE0(const AValue: Extended): Boolean; overload;
function IsLTE0(const AValue: Single): Boolean; overload;
// Is Zero
function Is0(const AValue: Double): Boolean; overload;
function Is0(const AValue: Extended): Boolean; overload;
function Is0(const AValue: Single): Boolean; overload;
// Is Non Zero
function IsN0(const AValue: Double): Boolean; overload;
function IsN0(const AValue: Extended): Boolean; overload;
function IsN0(const AValue: Single): Boolean; overload;
// Is Multiple of
function IsMultipleOf(const AValue1, AValue2: Integer): Boolean; overload;
function IsMultipleOf(const AValue1, AValue2: Double): Boolean; overload;
function IsMultipleOf(const AValue1, AValue2: Extended): Boolean; overload;
function IsMultipleOf(const AValue1, AValue2: Single): Boolean; overload;
// Log methods
function Ln(const N: Double): Double;
// Zero tolerance
procedure RestoreDefaultZeroTolerance;
procedure RestoreSavedZeroTolerance;
procedure SaveCurrentZeroTolerance;
// Other math methods
function IsNAN(const N: Double): Boolean;
function Stirling2(AElements, ASubsets: Integer): Double;
// 8087 FPU Methods
function Get8087ControlWord: Word;
function Valid8087ControlWord: Boolean;
procedure Check8087;
procedure Check8087ControlWord;
procedure Fix8087ControlWord;
procedure Clear8087StatusWord;
// Properties
property UseCheck8087: Boolean read GetUseCheck8087 write SetUseCheck8087;
property ZeroTolerance: Extended read GetZeroTolerance write SetZeroTolerance;
end;
//---------------------------------------------------------------------------
// IcaFastMath
//---------------------------------------------------------------------------
{$IFDEF USE_FAST_MATH}
IcaFastMath = interface
['{B97EF6A1-6030-4504-B36D-3D095A14AF95}']
function Exp(N: Double): Double;
function ExpVar(var N: Double): Double;
function Ln(N: Double): Double;
function FloatPower(const ABase, AExponent: Double): Double;
function Sqrt(const N: Double): Double;
end;
{$ENDIF}
//---------------------------------------------------------------------------
// IcaParser
//---------------------------------------------------------------------------
IcaParser = interface
['{3FA58161-458F-4490-95AF-271B7014DF8D}']
// Property methods
function GetIgnoreBlanks: Boolean;
function GetStringToParse: string;
function GetTokenCount: Integer;
function GetTokenDelimiters: string;
procedure SetIgnoreBlanks(const Value: Boolean);
procedure SetStringToParse(const Value: string);
procedure SetTokenDelimiters(const Value: string);
// Public methods
function GetToken(Index: Integer; FromEnd: Boolean = False): string;
function HasMoreTokens: Boolean;
function NextToken: string;
procedure GetTokens(TokenList: TStrings); overload;
procedure GetTokens(TokenList: IcaStringList); overload;
procedure Initialize;
// Properties
property IgnoreBlanks: Boolean read GetIgnoreBlanks write SetIgnoreBlanks;
property StringToParse: string read GetStringToParse write SetStringToParse;
property TokenCount: Integer read GetTokenCount;
property TokenDelimiters: string read GetTokenDelimiters write SetTokenDelimiters;
end;
//---------------------------------------------------------------------------
// IcaMouseUtils
//---------------------------------------------------------------------------
IcaMouseUtils = interface
['{E7873E94-AE51-4226-B5D9-3307896B9763}']
// Property methods
function GetButtonDown: Boolean;
function GetLeftButtonDown: Boolean;
function GetMiddleButtonDown: Boolean;
function GetMouseTrackerActive: Boolean;
function GetRightButtonDown: Boolean;
procedure SetMouseTrackerActive(const Value: Boolean);
// Event property methods
function GetOnMouseDown: TMouseEvent;
procedure SetOnMouseDown(const Value: TMouseEvent);
// Public methods
procedure MouseStateChanged(AMouseDownButton: TMouseButton; Shift: TShiftState; X, Y: Integer);
// Properties
property LeftButtonDown: Boolean read GetLeftButtonDown;
property MiddleButtonDown: Boolean read GetMiddleButtonDown;
property MouseTrackerActive: Boolean read GetMouseTrackerActive write SetMouseTrackerActive;
property RightButtonDown: Boolean read GetRightButtonDown;
property ButtonDown: Boolean read GetButtonDown;
// Event properties
property OnMouseDown: TMouseEvent read GetOnMouseDown write SetOnMouseDown;
end;
//---------------------------------------------------------------------------
// TcaUtils
//---------------------------------------------------------------------------
TcaUtils = class(TInterfacedObject, IcaUtils,
IcaKeys,
IcaMathUtils,
{$IFDEF USE_FAST_MATH}
IcaFastMath,
{$ENDIF}
IcaParser,
IcaMouseUtils)
private
// Private fields (IcaKeys)
FAllKeys: TcaByteSet;
FAlphaKeys: TcaByteSet;
FControlKeys: TcaByteSet;
FDecimalKeys: TcaByteSet;
FHexKeys: TcaByteSet;
FIntegerKeys: TcaByteSet;
FNumericKeys: TcaByteSet;
FVisibleKeys: TcaByteSet;
// Private fields (IcaMathUtils)
FSavedZeroTolerance: Extended;
FUseCheck8087: Boolean;
FZeroTolerance: Extended;
// Private fields (IcaParser)
FIgnoreBlanks: Boolean;
FStringToParse: string;
FTokenDelimiters: string;
FTokens: TStrings;
FTokenIndex: Integer;
// Event property fields
FOnContinueFileSearch: TcaFileSearchEvent;
// IcaMouseUtils - Private fields
FMouseIsDown: Boolean;
FMouseTrackerTimer: TcaTimer;
FOnMouseDown: TMouseEvent;
// Property methods (IcaKeys)
function GetAllKeys: TcaByteSet;
function GetAlphaKeys: TcaByteSet;
function GetControlKeys: TcaByteSet;
function GetDecimalKeys: TcaByteSet;
function GetHexKeys: TcaByteSet;
function GetIntegerKeys: TcaByteSet;
function GetNumericKeys: TcaByteSet;
function GetVisibleKeys: TcaByteSet;
// Private methods (IcaKeys)
procedure InitializeKeys;
// Property methods (IcaMathUtils)
function GetUseCheck8087: Boolean;
function GetZeroTolerance: Extended;
procedure SetUseCheck8087(const Value: Boolean);
procedure SetZeroTolerance(const Value: Extended);
// Private methods (IcaMathUtils)
procedure CheckZeroTolerance;
// Property methods (IcaParser)
function GetIgnoreBlanks: Boolean;
function GetStringToParse: string;
function GetTokenCount: Integer;
function GetTokenDelimiters: string;
procedure SetIgnoreBlanks(const Value: Boolean);
procedure SetStringToParse(const Value: string);
procedure SetTokenDelimiters(const Value: string);
// Private methods (IcaParser)
procedure InitializeParser;
// Private methods - Delphi replacements
function Pos(Substr: string; S: string): Integer;
// Event property methods
function GetOnContinueFileSearch: TcaFileSearchEvent;
procedure SetOnContinueFileSearch(const Value: TcaFileSearchEvent);
public
// Create/Destroy
constructor Create;
destructor Destroy; override;
// Conversion methods
// To string
function ArrayToString(AList: array of string; Delimiter: string; Shrink: Boolean = False): string;
function BooleanToString(ABoolean: Boolean): string;
function DateTimeToString(ADateTime: TDateTime; const ADateFormat: string): string;
function DoubleToString(ADouble: Double; const AFloatFormat: string): string;
function ExtendedToString(AExtended: Extended; const AFloatFormat: string): string;
function IntegerToString(AInteger: Integer; const AIntegerFormat: string): string;
function Int64ToString(AInt64: Int64; const AIntegerFormat: string): string;
function MemoToString(AMemo: TStrings): string;
function ObjectToString(AObject: TObject): string;
function SingleToString(ASingle: Single; const AFloatFormat: string): string;
// From string
function StringToBoolean(const ABooleanStr: string): Boolean;
function StringToDateTime(const ADateTimeStr: string): TDateTime;
function StringToDouble(const ADoubleStr: string): Double;
function StringToExtended(const AExtendedStr: string): Extended;
function StringToInt64(const AInt64Str: string): Int64;
function StringToInteger(const AIntegerStr: string): Integer;
function StringToSingle(const ASingleStr: string): Single;
function StrToFloat(const AFloatStr: string): Extended;
procedure StringToMemo(const AMemoStr: string; AMemo: TStrings);
// Other conversions
function ExtendedToDateTime(AExtended: Extended): TDateTime;
function IntegerToDateTime(AInteger: Integer): TDateTime;
function SingleToDateTime(ASingle: Single): TDateTime;
function Str2Float(const S: string; Default: Extended): Extended;
function Str2Int(const S: string; Default: Integer): Integer;
function IntToShortMonth(AIndex: Integer): string;
function IntToLongMonth(AIndex: Integer): string;
function ShortMonthToInt(AShortMonth: string): Integer;
function LongMonthToInt(ALongMonth: string): Integer;
function StreamToString(AStream: TStream): string;
// Comparison menthods
function CompareBooleans(const B1, B2: Boolean): TcaCompareResult;
function CompareDateTimes(const D1, D2: TDateTime): TcaCompareResult;
function CompareDoubles(const D1, D2: Double): TcaCompareResult;
function CompareExtendeds(const E1, E2: Extended): TcaCompareResult;
function CompareIntegers(const I1, I2: Integer): TcaCompareResult;
function CompareInt64s(const I1, I2: Int64): TcaCompareResult;
function CompareSingles(const S1, S2: Single): TcaCompareResult;
function CompareStrings(const S1, S2: string; ACaseInsensitive: Boolean = False): TcaCompareResult;
function OperatorToString(AOperator: TcaOperator): string;
// Array comparison menthods
function DoubleArraysEqual(A1, A2: array of Double): Boolean;
// string methods
function BuildString(Ch: Char; Count: Integer): string;
function CopyUntilChar(var S: string; Ch: Char; DeleteAfter: Boolean = False): string;
function DoubleQuoted(const S: string): string;
function FastCharPos(const ASource: string; const C: Char; StartPos: Integer = 1): Integer;
function FastPos(const ASourceString, AFindString: string; StartPos: Integer = 1; CaseSensitive: Boolean = False): Integer;
function Format(const Format: string): string; overload;
function Format(const Format: string; const Args: array of const): string; overload;
function Format(const Format: string; const Args: array of const; AUseEscapes: Boolean): string; overload;
function GetNextToken(var S: string; Delim: Char): string;
function Hash(const S: string): Integer;
function Indent(const S: string; N: Integer): string;
function IsBlankOrZero(const S: string): Boolean;
function IsInteger(const s: string): Boolean;
function IsNumeric(const S: string): Boolean;
function LastChar(const S: string): Char;
function LeftStr(const S: string; N: Integer; ACase: TcaLetterCase = caAny): string;
function PadInt(N: Integer; Ch: Char; Len: Integer): string;
function PadLeft(const S: string; Ch: Char; Len: Integer): string;
function PadRight(const S: string; Ch: Char; Len: Integer): string;
function PadZero(N: Integer; Len: Integer): string;
function PosFromStart(const SubS, S: string): Integer;
function PosFromEnd(const SubS, S: string): Integer;
function RightStr(const S: string; N: Integer; ACase: TcaLetterCase = caAny): string;
function StartsWith(AString: string; SearchString: string; ACaseInsensitive: boolean = false): boolean;
procedure ChangeCase(var S: string; ACase: TcaLetterCase);
procedure CleanFilenameString(var S: string);
procedure CleanIntString(var S: string);
procedure CleanNumString(var S: string);
procedure CleanString(var S: string);
procedure DeleteFromStart(var S: string; N: Integer);
procedure DeleteUntilChar(var S: string; Ch: Char; IncludeChar: Boolean);
procedure DeleteFromChar(var S: string; Ch: Char; IncludeChar: Boolean; N: Integer = 0);
procedure DeleteFromEnd(var S: string; N: Integer);
procedure EnsureLastChar(var S: string; Ch: Char);
procedure EnsureBackslash(var S: string);
procedure MoveStr(const Source: string; SourcePos: Integer; var Dest: string; const DestPos, Count: Integer);
procedure ReadStringFromBuffer(var S: string; var Buffer: PChar);
procedure Replace(var S: string; const OldSub, NewSub: string; CaseSensitive: Boolean = False);
procedure ReplaceChar(var S: string; const OldChar, NewChar: Char);
procedure SplitCamelCaps(var S: string);
procedure SortStrings(AStrings: TStrings);
procedure StripChar(C: Char; var S: string);
procedure StripLastCRLF(var S: string);
procedure StripLeadingLowerCase(var S: string);
procedure StripDoubleQuotes(var S: string);
procedure WriteStringToBuffer(const S: string; var Buffer: PChar);
// TStrings support
function MultiReplace(const S: string; AReplaceStrings: TStrings): string; overload;
procedure MaskDelete(AStrings, AMasks: TStrings);
procedure MultiReplace(AStrings, AReplaceStrings: TStrings); overload;
// Record support
procedure FillRecordFalse(var Rec; Size: Integer);
procedure FillRecordTrue(var Rec; Size: Integer);
// File methods
function RemoveExt(const AFileName: string): string;
function ExtractFileName(const FileName: string; IncludeExt: boolean = true): string;
procedure GetFileList(const APath, AFileSpec: string; AFileList: TcaStringList; IncludeDotRefs: Boolean = False); overload;
procedure GetFileList(const APath, AFileSpec: string; AFileList: IcaStringList; IncludeDotRefs: Boolean = False); overload;
procedure GetFileList(const APath, AFileSpec: string; AFileList: TStrings; IncludeDotRefs: Boolean = False); overload;
procedure SearchForFiles(const APath, AFileSpec: string; AOutList: TStrings); overload;
procedure SearchForFiles(const APath, AFileSpec: string; AOutList: IcaStringList); overload;
// IcaMathUtils
function BankersRound(const X: Extended): Integer;
function Equal(const N1, N2: Double): Boolean; overload;
function Equal(const N1, N2: Extended): Boolean; overload;
function Equal(const N1, N2: Single): Boolean; overload;
function EquiRound(const X: Extended): Integer;
function Exp(const N: Double): Double;
function FloatDiv(const Numerator, Divisor, Default: Extended): Extended;
function FloatPower(const ABase, AExponent: Extended): Extended;
function RoundTo(const Value: Extended; Places: Integer): Extended;
function IntPower(const ABase: Extended; AExponent: Integer): Extended;
function SafeFrac(const X: Extended): Extended;
function SafeRound(const X: Extended): Integer;
function SafeStrToInt(const AStrVal: string): Integer;
function SafeTrunc(const X: Extended): Integer;
function Sign(const N: Double): Integer;
function Sqr(X: Extended): Extended;
function Trunc(X: Extended): Int64;
function VBInt(X: Extended): Int64;
// Comparisons
function IsGreaterThanZero(const AValue: Double): Boolean; overload;
function IsGreaterThanZero(const AValue: Extended): Boolean; overload;
function IsGreaterThanZero(const AValue: Single): Boolean; overload;
function IsNonZero(const AValue: Double): Boolean; overload;
function IsNonZero(const AValue: Extended): Boolean; overload;
function IsNonZero(const AValue: Single): Boolean; overload;
function IsZero(const AValue: Double): Boolean; overload;
function IsZero(const AValue: Extended): Boolean; overload;
function IsZero(const AValue: Single): Boolean; overload;
// Is Equal to
function IsEq(const AValue1, AValue2: Double): Boolean; overload;
function IsEq(const AValue1, AValue2: Extended): Boolean; overload;
function IsEq(const AValue1, AValue2: Single): Boolean; overload;
// Is Equal to
function IsNEq(const AValue1, AValue2: Double): Boolean; overload;
function IsNEq(const AValue1, AValue2: Extended): Boolean; overload;
function IsNEq(const AValue1, AValue2: Single): Boolean; overload;
// Is Greater Than
function IsGT(const AValue1, AValue2: Double): Boolean; overload;
function IsGT(const AValue1, AValue2: Extended): Boolean; overload;
function IsGT(const AValue1, AValue2: Single): Boolean; overload;
// Is Greater Than or Equal
function IsGTE(const AValue1, AValue2: Double): Boolean; overload;
function IsGTE(const AValue1, AValue2: Extended): Boolean; overload;
function IsGTE(const AValue1, AValue2: Single): Boolean; overload;
// Is Less Than
function IsLT(const AValue1, AValue2: Double): Boolean; overload;
function IsLT(const AValue1, AValue2: Extended): Boolean; overload;
function IsLT(const AValue1, AValue2: Single): Boolean; overload;
// Is Less Than or Equal
function IsLTE(const AValue1, AValue2: Double): Boolean; overload;
function IsLTE(const AValue1, AValue2: Extended): Boolean; overload;
function IsLTE(const AValue1, AValue2: Single): Boolean; overload;
// Is Greater Than Zero
function IsGT0(const AValue: Double): Boolean; overload;
function IsGT0(const AValue: Extended): Boolean; overload;
function IsGT0(const AValue: Single): Boolean; overload;
// Is Greater Than or Equal to Zero
function IsGTE0(const AValue: Double): Boolean; overload;
function IsGTE0(const AValue: Extended): Boolean; overload;
function IsGTE0(const AValue: Single): Boolean; overload;
// Is Less Than Zero
function IsLT0(const AValue: Double): Boolean; overload;
function IsLT0(const AValue: Extended): Boolean; overload;
function IsLT0(const AValue: Single): Boolean; overload;
// Is Less Than or Equal to Zero
function IsLTE0(const AValue: Double): Boolean; overload;
function IsLTE0(const AValue: Extended): Boolean; overload;
function IsLTE0(const AValue: Single): Boolean; overload;
// Is Zero
function Is0(const AValue: Double): Boolean; overload;
function Is0(const AValue: Extended): Boolean; overload;
function Is0(const AValue: Single): Boolean; overload;
// Is Non Zero
function IsN0(const AValue: Double): Boolean; overload;
function IsN0(const AValue: Extended): Boolean; overload;
function IsN0(const AValue: Single): Boolean; overload;
// Is Multiple of
function IsMultipleOf(const AValue1, AValue2: Integer): Boolean; overload;
function IsMultipleOf(const AValue1, AValue2: Double): Boolean; overload;
function IsMultipleOf(const AValue1, AValue2: Extended): Boolean; overload;
function IsMultipleOf(const AValue1, AValue2: Single): Boolean; overload;
// Log methods
function Ln(const N: Double): Double;
// Zero tolerance
procedure RestoreDefaultZeroTolerance;
procedure RestoreSavedZeroTolerance;
procedure SaveCurrentZeroTolerance;
// IcaFastMath
{$IFDEF USE_FAST_MATH}
// Method resolution clause
function IcaFastMath.Exp = FastExp;
function IcaFastMath.ExpVar = FastExpVar;
function IcaFastMath.Ln = FastLn;
function IcaFastMath.FloatPower = FastFloatPower;
function IcaFastMath.Sqrt = FastSqrt;
// Methods
function FastExp(X: Double): Double;
function FastExpVar(var N: Double): Double;
function FastLn(X: Double): Double;
function FastFloatPower(const ABase, AExponent: Double): Double;
function FastSqrt(const N: Double): Double;
{$ENDIF}
// Other math methods
function Stirling2(AElements, ASubsets: Integer): Double;
// 8087 FPU Methods
function Get8087ControlWord: Word;
function Valid8087ControlWord: Boolean;
procedure Check8087;
procedure Check8087ControlWord;
procedure Fix8087ControlWord;
procedure Clear8087StatusWord;
// Math evaluator methods
function GetOperatorPrecedence(const AOperator, AReferenceOperator: string): TcaOperatorPrecedence;
function IsBracket(const S: string): Boolean;
function IsFunction(const S: string): Boolean;
function IsOperand(const S: string): Boolean;
function IsOperator(const S: string): Boolean;
// Graphics methods
function GetBitmapRect(ABitmap: TBitmap): TRect;
function HTMLColorToColor(const AHTMLColor: string): TColor;
// Font methods
function FontsEqual(AFont1, AFont2: TFont): Boolean;
// TRect methods
function InRect(X, Y: Integer; Rect: TRect): Boolean; overload;
function InRect(APoint: TPoint; Rect: TRect): Boolean; overload;
procedure AdjustRect(var ARect: TRect; const dL, dT, dR, dB: Integer);
procedure DecodeRect(const ARect: TRect; var ALeft, ATop, AWidth, AHeight: Integer);
// Dialog methods
function QueryDeleteData(AHandle: HWND; const ADataSynonym: string = ''): TcaMsgDialogResponse;
function QuerySaveData(AHandle: HWND): TcaMsgDialogResponse;
function QueryCloseApp(AHandle: HWND; const ACloseSynonym: string = ''): TcaMsgDialogResponse;
// System methods
function AltKeyDown: Boolean;
function ControlKeyDown: Boolean;
function ShiftKeyDown: Boolean;
function IsKeyDown(AKeyCode: Word): Boolean;
function IsLargeFonts: Boolean;
function EnableDebugPrivilege(const Enable: Boolean): Boolean;
function FolderExists(const AFolder: string): Boolean;
function GetComputerName: string;
function GetWindowClass(Wnd: HWND): string;
function GetWindowProcess(Wnd: HWND): string;
function GetWindowsFolder: string;
function GetWindowsVersion: TcaWinVersion;
function GetEnvironmentVariable(const AName: string): string;
function GetFileVersion(const AFileName: string; ABlockCount: Word = 4): string;
function GetSystemMenuFont: TFont;
function GetGUIDAsString: string;
function GetUserName: string;
function WinExecAndWait32(FileName: string; Visibility: Integer): Integer;
procedure AppClose(AHandle: HWND);
procedure AppMaximize(AHandle: HWND);
procedure AppMinimize(AHandle: HWND);
procedure AppMove(AHandle: HWND);
procedure AppRestore(AHandle: HWND);
procedure AppSize(AHandle: HWND);
procedure AppToggleNormalAndMaximized(AHandle: HWND);
procedure SendKey(AHandle: HWND; AKey: Word; const shift: TShiftState; IsSpecialKey: Boolean);
procedure SetEnvironmentVariable(const AName, AValue: string; ABroadcast: Boolean = True);
procedure SetWindowStayOnTop(AHandle: HWND; IsStayOnTop: Boolean);
// Application path methods - works with EXEs and DLLs
function AppName: string;
function AppPath: string;
function AppPathAndName: string;
function ConfigPath: string;
function DataPath: string;
function IsTestApp: Boolean;
// Development/Debugging
function ApplicationIsDelphi: Boolean;
function DelphiIsRunning: Boolean;
// IEEE-754 Support for NANs and INFs
function DoubleToHex(const N: Double): string;
function HexToDouble(const Hex: string): Double;
function IsInfinity(const N: Double): Boolean;
function IsNAN(const N: Double): Boolean;
function NAN: Double;
function NegativeInfinity: Double;
function PositiveInfinity: Double;
// Excel related methods
function A1Ref(C: Byte; R: Integer): string;
function CRRef(const A1Ref: string): TcaColRow;
// Component / TPersistent support
function CopyPublishedProperties(Src, Dest: TPersistent; CopyClassPointers, CopyChildren: Boolean): Boolean;
function DeepCopy(Src, Dest: TPersistent): Boolean;
function PersistentAsString(AObject: TPersistent): string;
function PublishedPropertiesMatch(AItem1, AItem2: TPersistent; ACompareClassPointers: Boolean = False): Boolean;
function ShallowCopy(Src, Dest: TPersistent; CopyClassPointers: Boolean = False): Boolean;
// Design by Contract constructs
function FailsAll(AConditions: array of Boolean): Boolean;
function FailsAny(AConditions: array of Boolean): Boolean;
// Interface support
function GetImplementingObject(const Intf: IUnknown): TObject;
// Method support
function MethodsMatch(AMethod1, AMethod2: TMethod): Boolean;
// Time support methods
function CurrentYear: Word;
function DateTimeToTimePoint(ADateTime: TDateTime): TcaTimePoint;
function Now: TcaTimePoint;
// Message dialog methods
function MessageDialog(const ACaption, AMsg: string; ADlgType: TMsgDlgType;
AButtonCaptions: array of string; ADefaultIndex: Integer; AHelpCtx: Longint): TcaMessageDialogResponse;
// Visual control support
procedure SetControlFont(AControl: TControl; AColor: TColor; ASize: Integer; AStyle: TFontStyles);
// Public methods (IcaParser)
function GetToken(Index: Integer; FromEnd: Boolean = False): string;
function HasMoreTokens: Boolean;
function NextToken: string;
procedure GetTokens(TokenList: TStrings); overload;
procedure GetTokens(TokenList: IcaStringList); overload;
procedure IcaParser.Initialize = InitializeParser;
// Properties (IcaKeys)
property AllKeys: TcaByteSet read GetAllKeys;
property AlphaKeys: TcaByteSet read GetAlphaKeys;
property ControlKeys: TcaByteSet read GetControlKeys;
property DecimalKeys: TcaByteSet read GetDecimalKeys;
property HexKeys: TcaByteSet read GetHexKeys;
property IntegerKeys: TcaByteSet read GetIntegerKeys;
property NumericKeys: TcaByteSet read GetNumericKeys;
property VisibleKeys: TcaByteSet read GetVisibleKeys;
// Properties (IcaMathUtils)
property UseCheck8087: Boolean read GetUseCheck8087 write SetUseCheck8087;
property ZeroTolerance: Extended read GetZeroTolerance write SetZeroTolerance;
// Properties (IcaParser)
property IgnoreBlanks: Boolean read GetIgnoreBlanks write SetIgnoreBlanks;
property StringToParse: string read GetStringToParse write SetStringToParse;
property TokenDelimiters: string read GetTokenDelimiters write SetTokenDelimiters;
// Events - FileSearch cancel
property OnContinueFileSearch: TcaFileSearchEvent read GetOnContinueFileSearch write SetOnContinueFileSearch;
// Clipboard methods
procedure CopyDatasetToClipboard(ADataset: TDataset);
//---------------
// IcaMouseUtils
//---------------
// Public methods
procedure MouseStateChanged(AMouseDownButton: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure MouseTrackerTimerEvent(Sender: TObject);
// Property methods
function GetButtonDown: Boolean;
function GetLeftButtonDown: Boolean;
function GetMiddleButtonDown: Boolean;
function GetMouseTrackerActive: Boolean;
function GetRightButtonDown: Boolean;
procedure SetMouseTrackerActive(const Value: Boolean);
// Event property methods
function GetOnMouseDown: TMouseEvent;
procedure SetOnMouseDown(const Value: TMouseEvent);
// Properties
property ButtonDown: Boolean read GetButtonDown;
property LeftButtonDown: Boolean read GetLeftButtonDown;
property MiddleButtonDown: Boolean read GetMiddleButtonDown;
property MouseTrackerActive: Boolean read GetMouseTrackerActive write SetMouseTrackerActive;
property RightButtonDown: Boolean read GetRightButtonDown;
// Event properties
property OnMouseDown: TMouseEvent read GetOnMouseDown write SetOnMouseDown;
end;
//---------------------------------------------------------------------------
// CoUtilsFactory
//---------------------------------------------------------------------------
CoUtilsFactory = class
public
class function Instance: IcaUtils;
end;
var
Utils: IcaUtils = nil;
procedure Pass;
implementation
uses
caLog,
caProcesses,
caFastStrings,
caFastFuncs,
caRTTI;
procedure Pass;
begin
end;
//---------------------------------------------------------------------------
// TcaUtils
//---------------------------------------------------------------------------
constructor TcaUtils.Create;
begin
inherited;
Check8087;
FTokens := TStringList.Create;
InitializeParser;
InitializeKeys;
CheckZeroTolerance;
FMouseTrackerTimer := TcaTimer.Create(nil);
FMouseTrackerTimer.OnTimer := MouseTrackerTimerEvent;
end;
destructor TcaUtils.Destroy;
begin
FTokens.Free;
FMouseTrackerTimer.Free;
inherited;
end;
//---------------------------------------------------------------------------
// Conversion methods
//---------------------------------------------------------------------------
// To string
function TcaUtils.ArrayToString(AList: array of string; Delimiter: string; Shrink: Boolean = False): string;
var
Index: Integer;
begin
Result := '';
for Index := 0 to Length(AList) -1 do
begin
if Shrink then
begin
if (AList[Index] <> '') then
begin
if Result <> '' then
Result := Result + Delimiter;
Result := Result + AList[Index];
end
end
else
begin
if Index <> 0 then
Result := Result + Delimiter;
Result := Result + AList[Index];
end;
end;
end;
function TcaUtils.BooleanToString(ABoolean: Boolean): string;
begin
if ABoolean then Result := 'True' else Result := 'False';
end;
function TcaUtils.DateTimeToString(ADateTime: TDateTime; const ADateFormat: string): string;
begin
if ADateFormat <> '' then
begin
if ADateFormat = ' ' then
Result := ''
else